后台授权模块调整
This commit is contained in:
@@ -51,10 +51,6 @@ func (l *DeleteLdapGroupLogic) DeleteLdapGroup(req *types.DeleteLdapGroupReq, us
|
||||
if resLdapGroupDel.Error != nil {
|
||||
return resLdapGroupDel.Error
|
||||
}
|
||||
resLdapUserGroupDel := tx.Where("group_id IN ?", req.Ids).Delete(&gmodel.LdapUserGroup{})
|
||||
if resLdapUserGroupDel.Error != nil {
|
||||
return resLdapUserGroupDel.Error
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if txErr != nil {
|
||||
|
||||
@@ -52,6 +52,9 @@ func (l *SaveLdapGroupLogic) SaveLdapGroup(req *types.SaveLdapGroupReq, userinfo
|
||||
if req.Name != "" {
|
||||
updateMap["name"] = req.Name
|
||||
}
|
||||
if req.Type != "" {
|
||||
updateMap["type"] = req.Type
|
||||
}
|
||||
if req.Keyword != "" {
|
||||
updateMap["keyword"] = req.Keyword
|
||||
}
|
||||
@@ -67,6 +70,7 @@ func (l *SaveLdapGroupLogic) SaveLdapGroup(req *types.SaveLdapGroupReq, userinfo
|
||||
err1 = l.svcCtx.AllModels.LdapGroup.UpdateOne(l.ctx, resOne, updateMap)
|
||||
} else {
|
||||
err1 = l.svcCtx.AllModels.LdapGroup.InsertOne(l.ctx, gmodel.LdapGroup{
|
||||
Type: &req.Type,
|
||||
Name: &req.Name,
|
||||
Keyword: &req.Keyword,
|
||||
Remark: &req.Remark,
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewSetLdapGroupUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
||||
func (l *SetLdapGroupUserLogic) SetLdapGroupUser(req *types.SetLdapGroupUserReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
resLdapGroupInfo, err := l.svcCtx.AllModels.LdapGroup.FindOneById(l.ctx, req.GroupId)
|
||||
_, err := l.svcCtx.AllModels.LdapGroup.FindOneById(l.ctx, req.GroupId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
basic.CodeServiceErr.Message = "权限组记录不存在"
|
||||
@@ -45,11 +45,10 @@ func (l *SetLdapGroupUserLogic) SetLdapGroupUser(req *types.SetLdapGroupUserReq,
|
||||
}
|
||||
return resp.SetStatus(basic.CodeServiceErr)
|
||||
}
|
||||
resCreateInBatches := l.svcCtx.MysqlConn.WithContext(l.ctx).Create(gmodel.LdapUserGroup{
|
||||
GroupId: &resLdapGroupInfo.Id,
|
||||
UserId: &req.UserId,
|
||||
err = l.svcCtx.AllModels.LdapUser.UpdateById(l.ctx, req.UserId, &gmodel.LdapUser{
|
||||
GroupId: &req.GroupId,
|
||||
})
|
||||
if resCreateInBatches.Error != nil {
|
||||
if err != nil {
|
||||
basic.CodeServiceErr.Message = "系统出错"
|
||||
return resp.SetStatus(basic.CodeServiceErr)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ type GetLdapGroupsReq struct {
|
||||
|
||||
type SaveLdapGroupReq struct {
|
||||
Id int64 `json:"id"` //id
|
||||
Type string `json:"type"` //类型
|
||||
Name string `json:"name"` //名称
|
||||
Keyword string `json:"keyword"` //关键词
|
||||
Remark string `json:"remark"` // 备注
|
||||
|
||||
Reference in New Issue
Block a user