Browse Source

update

master
DengBiao 2 years ago
parent
commit
f3480e4b1f
2 changed files with 22 additions and 18 deletions
  1. +2
    -1
      internal/business/comm/db/db_user_push_for_jg.go
  2. +20
    -17
      internal/business/domain/user/service/auth.go

+ 2
- 1
internal/business/comm/db/db_user_push_for_jg.go View File

@@ -8,6 +8,7 @@ import (
"gim/internal/business/comm/utils/logx" "gim/internal/business/comm/utils/logx"
"gim/pkg/db" "gim/pkg/db"
"gim/pkg/gerrors" "gim/pkg/gerrors"
"github.com/jinzhu/gorm"
) )


type dbUserPushForJg struct{} type dbUserPushForJg struct{}
@@ -18,7 +19,7 @@ var DbUserPushForJg = new(dbUserPushForJg)
func (*dbUserPushForJg) UserPushForJgGetOne(uid string, masterId int64) (*model.UserPushForJg, error) { func (*dbUserPushForJg) UserPushForJgGetOne(uid string, masterId int64) (*model.UserPushForJg, error) {
var cfgList model.UserPushForJg var cfgList model.UserPushForJg
if err := db.DB.Where("`uid` = ? and `master_id` = ?", uid, masterId).First(&cfgList).Error; err != nil { if err := db.DB.Where("`uid` = ? and `master_id` = ?", uid, masterId).First(&cfgList).Error; err != nil {
if err.Error() != "record not found" {
if err == gorm.ErrRecordNotFound {
return nil, nil return nil, nil
} }
return nil, gerrors.WrapError(err) return nil, gerrors.WrapError(err)


+ 20
- 17
internal/business/domain/user/service/auth.go View File

@@ -2,12 +2,15 @@ package service


import ( import (
"context" "context"
"errors"
"gim/internal/business/comm/db"
"gim/internal/business/domain/user/model" "gim/internal/business/domain/user/model"
"gim/internal/business/domain/user/repo" "gim/internal/business/domain/user/repo"
"gim/pkg/gerrors" "gim/pkg/gerrors"
"gim/pkg/pb" "gim/pkg/pb"
"gim/pkg/rpc" "gim/pkg/rpc"
"gim/pkg/util" "gim/pkg/util"
"strconv"
"time" "time"
) )


@@ -58,23 +61,23 @@ func (*authService) SignIn(ctx context.Context, phoneNumber, code string, master
return false, 0, "", 0, err return false, 0, "", 0, err
} }


//if pushAlia != "" {
// userPushForJg, err := db.DbUserPushForJg.UserPushForJgGetOne(strconv.FormatInt(user.Id, 10), masterId)
// if err != nil && err.Error() != "record not found" {
// return false, 0, "", 0, err
// }
// if userPushForJg == nil {
// save := db.DbUserPushForJg.UserPushForJgInsert(user.Id, masterId, pushAlia)
// if !save {
// return false, 0, "", 0, errors.New("插入user_push_for_jg记录失败")
// }
// } else {
// update := db.DbUserPushForJg.UserPushForJgUpdate(user.Id, masterId, pushAlia)
// if !update {
// return false, 0, "", 0, errors.New("修改user_push_for_jg记录失败")
// }
// }
//}
if pushAlia != "" {
userPushForJg, err := db.DbUserPushForJg.UserPushForJgGetOne(strconv.FormatInt(user.Id, 10), masterId)
if err != nil && err.Error() != "record not found" {
return false, 0, "", 0, err
}
if userPushForJg == nil {
save := db.DbUserPushForJg.UserPushForJgInsert(user.Id, masterId, pushAlia)
if !save {
return false, 0, "", 0, errors.New("插入user_push_for_jg记录失败")
}
} else {
update := db.DbUserPushForJg.UserPushForJgUpdate(user.Id, masterId, pushAlia)
if !update {
return false, 0, "", 0, errors.New("修改user_push_for_jg记录失败")
}
}
}
return isNew, user.Id, token, masterId, nil return isNew, user.Id, token, masterId, nil
} }




Loading…
Cancel
Save