diff --git a/business/auth2/authprovider/password/password.go b/business/auth2/authprovider/password/password.go index 06c472a6d..5c5f97d17 100644 --- a/business/auth2/authprovider/password/password.go +++ b/business/auth2/authprovider/password/password.go @@ -50,7 +50,7 @@ func (a *Auther) VerifySecret(userID, passMD5 string) (authBindEx *auth2.AuthBin } // 特殊接口 -func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err error) { +func (a *Auther) ChangePassword(userID, userName, oldPassMD5, newPassMD5 string) (err error) { var authBind *model.AuthBind db := dao.GetDB() salt := utils.GetUUID() @@ -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, - }, model.AdminName, nil) + }, userName, 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, }, - }, model.AdminName) + }, userName) } return err } diff --git a/business/jxcallback/orderman/order_comment.go b/business/jxcallback/orderman/order_comment.go index 54c985cb7..1c8d71141 100644 --- a/business/jxcallback/orderman/order_comment.go +++ b/business/jxcallback/orderman/order_comment.go @@ -139,7 +139,6 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) ( } if err == nil { if isNewComment { - // dao.WrapAddIDCULEntity(orderComment, model.AdminName) err = dao.CreateEntity(db, comment2) } else if comment2 != nil { _, err = dao.UpdateEntity(db, comment2) diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index 777f9e85b..55365478f 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -55,7 +55,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, - }, model.AdminName, map[string]interface{}{ + }, userID, map[string]interface{}{ "UserID": userID, }) return err @@ -64,7 +64,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, - }, model.AdminName, map[string]interface{}{ + }, userID, map[string]interface{}{ "UserID": userID, }) return err @@ -83,7 +83,8 @@ func (*UserProvider) UpdateUserType(userID string, userTypeMask int8, updateType } else { user.Type = userTypeMask } - _, err = dao.UpdateEntity(db, user, "Type") + dao.WrapUpdateULEntity(user, userID) + _, err = dao.UpdateEntity(db, user, "Type", model.FieldUpdatedAt, model.FieldLastOperator) } return err } @@ -93,7 +94,7 @@ func (*UserProvider) UpdateLastLogin(userID string, lastLoginType, fromIP string "LastLoginAt": utils.Time2Pointer(time.Now()), "LastLoginType": lastLoginType, "LastLoginIP": fromIP, - }, model.AdminName, map[string]interface{}{ + }, userID, map[string]interface{}{ "UserID": userID, }) return err @@ -126,6 +127,7 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri user.Type |= model.UserTypeStoreBoss } if err = CreateUser(user, utils.LimitUTF8StringLen(ctx.GetRealRemoteIP()+","+inAuthInfo.GetAuthID(), 32)); err == nil { + userProvider.UpdateLastLogin(user.GetID(), inAuthInfo.GetAuthType(), ctx.GetRealRemoteIP()) TryAddStoreBossRole4User(ctx, user) if outAuthInfo, err = auth2.BindUser(mobileAuth, user); err == nil && inAuthInfo != nil { err = auth2.AddAuthBind(&outAuthInfo.UserBasic, inAuthInfo) diff --git a/business/model/dao/dao_bz.go b/business/model/dao/dao_bz.go index 649ea5eb0..2af3a4ecd 100644 --- a/business/model/dao/dao_bz.go +++ b/business/model/dao/dao_bz.go @@ -107,10 +107,13 @@ func UpdateEntityLogically(db *DaoDB, item interface{}, kvs map[string]interface model.FieldDeletedAt: utils.DefaultTimeValue, }) } - return UpdateEntityByKV(db, item, utils.MergeMaps(kvs, map[string]interface{}{ - model.FieldUpdatedAt: time.Now(), - model.FieldLastOperator: userName, - }), conditions) + params := map[string]interface{}{ + model.FieldUpdatedAt: time.Now(), + } + if userName != "" { + params[model.FieldLastOperator] = userName + } + return UpdateEntityByKV(db, item, utils.MergeMaps(kvs, params), conditions) } // 此函数会更新同步标志 @@ -133,11 +136,14 @@ func UpdateEntityLogicallyAndUpdateSyncStatus(db *DaoDB, item interface{}, kvs m for i := 0; i < valueRows.Len(); i++ { value := reflect.Indirect(valueRows.Index(i)) status := value.FieldByName(syncStatusFieldName).Int() | int64(valueMask) - num2, err2 := UpdateEntityByKV(db, value.Interface(), utils.MergeMaps(kvs, map[string]interface{}{ - model.FieldUpdatedAt: time.Now(), - model.FieldLastOperator: userName, - syncStatusFieldName: status, - }), nil) + params := map[string]interface{}{ + model.FieldUpdatedAt: time.Now(), + syncStatusFieldName: status, + } + if userName != "" { + params[model.FieldLastOperator] = userName + } + num2, err2 := UpdateEntityByKV(db, value.Interface(), utils.MergeMaps(kvs, params), nil) if err = err2; err == nil { num += num2 } else { diff --git a/controllers/auth2.go b/controllers/auth2.go index 38490265e..b769865ea 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -290,7 +290,7 @@ func (c *Auth2Controller) ChangePassword() { c.callChangePassword(func(params *tAuth2ChangePasswordParams) (retVal interface{}, errCode string, err error) { authInfo, err := params.Ctx.GetV2AuthInfo() if err == nil { - err = password.AutherObj.ChangePassword(authInfo.GetID(), params.OldPwd, params.NewPwd) + err = password.AutherObj.ChangePassword(authInfo.GetID(), params.Ctx.GetUserName(), params.OldPwd, params.NewPwd) } return retVal, "", err })