- 重构了dao.GetAuthBind和dao.GetUserBindAuthInfo

- AuthBind的唯一索引调整为"AuthID", "Type", "BindType", "DeletedAt"
This commit is contained in:
gazebo
2019-09-06 16:26:47 +08:00
parent a12f15af52
commit 47a0a892b6
9 changed files with 44 additions and 48 deletions

View File

@@ -427,14 +427,14 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err e
if db == nil {
db = dao.GetDB()
}
openID := ""
openIDs := []string{}
storeID := 0
remark := ""
if !globals.DisableWXAuth1 {
wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
if err == nil {
openID = wxinfo.OpenID
openIDs = []string{wxinfo.OpenID}
storeID = wxinfo.JxStoreID
}
}
@@ -449,9 +449,11 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err e
}
}
if userID != "" {
authBind, err2 := dao.GetAuthBind(db, userID, model.AuthBindTypeAuth, weixin.AuthTypeMP, "")
authBindList, err2 := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "")
if err = err2; err == nil {
openID = authBind.AuthID
for _, v := range authBindList {
openIDs = append(openIDs, v.AuthID)
}
}
roleList, err2 := api2.RoleMan.GetUserRoleList(userID)
if err = err2; err == nil && len(roleList) > 0 {
@@ -460,7 +462,7 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err e
}
}
if openID != "" {
if len(openIDs) > 0 {
if storeID > 0 {
store := &model.Store{}
store.ID = storeID
@@ -475,7 +477,9 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err e
}
if err == nil {
if globals.EnableStoreWrite {
err = api.WeixinAPI.CBUpdateRemark(openID, remark)
for _, openID := range openIDs {
err = api.WeixinAPI.CBUpdateRemark(openID, remark)
}
}
}
}