```
feat(user-service): 修改超级管理员ID并添加金币删除功能 - 将超级管理员ID从1改为10001 - 在用户更新时删除金币字段 - 调整异色宠物生成概率从1%到0
This commit is contained in:
@@ -82,7 +82,7 @@ func (s *BaseSysUserService) ModifyBefore(ctx context.Context, method string, pa
|
||||
// 禁止删除超级管理员
|
||||
userIds := garray.NewIntArrayFrom(gconv.Ints(param["ids"]))
|
||||
currentId, found := userIds.Get(0)
|
||||
superAdminId := 1
|
||||
superAdminId := 10001
|
||||
|
||||
if userIds.Len() == 1 && found && currentId == superAdminId {
|
||||
err = gerror.New("超级管理员不能删除")
|
||||
@@ -90,7 +90,7 @@ func (s *BaseSysUserService) ModifyBefore(ctx context.Context, method string, pa
|
||||
}
|
||||
|
||||
// 删除超级管理员
|
||||
userIds.RemoveValue(1)
|
||||
userIds.RemoveValue(10001)
|
||||
g.RequestFromCtx(ctx).SetParam("ids", userIds.Slice())
|
||||
}
|
||||
return
|
||||
@@ -113,8 +113,8 @@ func (s *BaseSysUserService) Gen(user UserAttributes) (data interface{}, err err
|
||||
lastInsertId, err := m.Data(user).Data(
|
||||
|
||||
g.Map{
|
||||
"username": user.Username,
|
||||
"headImg": user.AvatarUrl,
|
||||
"username": user.Username,
|
||||
"headImg": user.AvatarUrl,
|
||||
"departmentId": 1,
|
||||
},
|
||||
).InsertAndGetId()
|
||||
@@ -234,7 +234,7 @@ func (s *BaseSysUserService) ServiceUpdate(ctx context.Context, req *cool.Update
|
||||
}
|
||||
|
||||
// 禁止禁用超级管理员
|
||||
if userId == 1 && (!r.Get("status").IsNil() && r.Get("status").Int() == 0) {
|
||||
if userId == 10001 && (!r.Get("status").IsNil() && r.Get("status").Int() == 0) {
|
||||
err = gerror.New("禁止禁用超级管理员")
|
||||
return
|
||||
}
|
||||
@@ -261,6 +261,7 @@ func (s *BaseSysUserService) ServiceUpdate(ctx context.Context, req *cool.Update
|
||||
} else {
|
||||
delete(rMap, "password")
|
||||
}
|
||||
delete(rMap, "goldbean")
|
||||
|
||||
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
roleModel := cool.DBM(model.NewBaseSysUserRole()).TX(tx).Where("userId", userId)
|
||||
|
||||
Reference in New Issue
Block a user