- replace literal 'admin' with const

This commit is contained in:
gazebo
2019-03-12 15:53:13 +08:00
parent c46f1597f1
commit 3113e9d603
8 changed files with 14 additions and 9 deletions

View File

@@ -77,7 +77,7 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType string, unionAuthTypeList []st
authBindEx = &auth2.AuthBindEx{
AuthBind: *authBind,
}
err = a.AddAuthBind(authBindEx, "admin") // 自动绑定
err = a.AddAuthBind(authBindEx, model.AdminName) // 自动绑定
} else if dao.IsNoRowsError(err) {
err = nil
}

View File

@@ -60,7 +60,7 @@ func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err erro
_, err = dao.UpdateEntityLogically(db, authBind, map[string]interface{}{
"AuthSecret": encryptPwd,
"AuthSecret2": salt,
}, "admin", nil)
}, model.AdminName, nil)
}
} else if dao.IsNoRowsError(err) {
err = a.AddAuthBind(&auth2.AuthBindEx{
@@ -71,7 +71,7 @@ func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err erro
AuthSecret: encryptPwd,
AuthSecret2: salt,
},
}, "admin")
}, model.AdminName)
}
return err
}

View File

@@ -126,7 +126,7 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
}
if err == nil {
if isNewComment {
// dao.WrapAddIDCULEntity(orderComment, "admin")
// dao.WrapAddIDCULEntity(orderComment, model.AdminName)
err = dao.CreateEntity(db, comment2)
} else if comment2 != nil {
_, err = dao.UpdateEntity(db, comment2)

View File

@@ -46,7 +46,7 @@ func (*UserProvider) GetUser(authID, authIDType string) (user auth2.IUser) {
func (*UserProvider) UpdateUserMobile(userID string, mobile string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Mobile": mobile,
}, "admin", map[string]interface{}{
}, model.AdminName, map[string]interface{}{
"UserID": userID,
})
return err
@@ -55,7 +55,7 @@ func (*UserProvider) UpdateUserMobile(userID string, mobile string) (err error)
func (*UserProvider) UpdateUserEmail(userID string, email string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Email": email,
}, "admin", map[string]interface{}{
}, model.AdminName, map[string]interface{}{
"UserID": userID,
})
return err

View File

@@ -39,7 +39,7 @@ var (
)
func init() {
AdminCtx = NewWithUserName(nil, "jxadmin", nil, nil)
AdminCtx = NewWithUserName(nil, model.AdminName, nil, nil)
}
func NewWithUserName(rootTask tasksch.ITask, userName string, w http.ResponseWriter, r *http.Request) (ctx *Context) {

View File

@@ -3,6 +3,7 @@ package tasks
import (
"time"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
"git.rosy.net.cn/jx-callback/globals/api"
@@ -187,7 +188,7 @@ func SaveWeimobToken(token *weimobapi.TokenInfo) (err error) {
Thirdparty: "weimob",
Token: string(utils.MustMarshal(token)),
Date: utils.Time2Str(time.Now().Add((time.Duration(token.ExpiresIn) - weimobTokenExpires/time.Second) * time.Second)),
LastOperator: "admin",
LastOperator: model.AdminName,
}
return dao.CreateOrUpdate(db, config)
}

View File

@@ -5,6 +5,10 @@ const (
AuthBindStatusDisabled = 2
)
const (
AdminName = "jxadmin"
)
type AuthBind struct {
ModelIDCULD

View File

@@ -69,7 +69,7 @@ func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err
result2 string
err2 error
)
task := tasksch.NewParallelTask("jd GetOrder", nil, "admin", func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, errInner error) {
task := tasksch.NewParallelTask("jd GetOrder", nil, model.AdminName, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, errInner error) {
taskIndex := batchItemList[0].(int)
switch taskIndex {
case 0: