From e13c4ce871ec50b914b51393eddb63d01fa2c571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Tue, 5 Jan 2021 10:16:50 +0800 Subject: [PATCH] 'commit' --- .../BaseRole/BaseRoleDao/BaseRoleDao.go | 11 +++++++++ .../BaseRoleService/BaseRoleService.go | 24 ++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go b/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go index 46c6fa00..5d283c37 100644 --- a/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go +++ b/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go @@ -66,3 +66,14 @@ func PageBaseRole(in *BaseRoleProto.QueryArg) ([]map[string]interface{}, int32, list, count, err := SqlKit.Query(sql) return list, count, err } + +//增加角色与系统的关联关系 +func AddRoleAppReleation(ms models.TBaseRoleApp) (int64, error) { + return db.Insert(ms) +} + +//删除角色与系统的关联关系 +func DeleteRoleAppRepleation(roleId string) { + sql := `update t_base_role_app set b_use=-2 where rold_id=? and b_use=1` + db.SQL(sql, roleId).Execute() +} diff --git a/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go b/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go index 2508c2c0..86258335 100644 --- a/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go +++ b/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go @@ -74,10 +74,24 @@ func (s *Rpc) AddBaseRole(ctx context.Context, in *BaseRoleProto.ModelArg) (*Bas reply.Success = false reply.Message = Const.DataBaseActionError LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddBaseRole时发生严重错误:"+err.Error()) - } else { - reply.Success = true - reply.Message = Const.SuccessDataBaseAction + return &reply, err + } + // 增加角色与系统的关联关系 + for i := 0; i < len(in.AppIds); i++ { + model2 := new(models.TBaseRoleApp) + model2.AppId = in.AppIds[i] + model2.RoleId = model.RoleId + model2.BUse = 1 + _, err = BaseRoleDao.AddRoleAppReleation(*model2) + if err != nil { + reply.Success = false + reply.Message = Const.DataBaseActionError + LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddRoleAppReleation时发生严重错误:"+err.Error()) + return &reply, err + } } + reply.Success = true + reply.Message = Const.SuccessDataBaseAction return &reply, err } @@ -101,6 +115,10 @@ func (s *Rpc) DeleteBaseRole(ctx context.Context, in *BaseRoleProto.DeleteIdsArg reply.Message = Const.DataBaseActionError return &reply, err } + //删除与系统的关联关系 + for i := 0; i < len(in.Ids); i++ { + BaseRoleDao.DeleteRoleAppRepleation(in.Ids[i]) + } reply.Success = true reply.Message = Const.SuccessDataBaseAction return &reply, err