diff --git a/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go b/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go index 1a08bf6e..4c570adc 100644 --- a/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go +++ b/dsBaseRpc/RpcService/BaseRole/BaseRoleDao/BaseRoleDao.go @@ -17,9 +17,9 @@ func AddBaseRole(ms models.TBaseRole) (int64, error) { } //检查一个角色编码是不是已存在 -func ExistRoleCode(roleCode string) (bool, error) { - sql := `select count(1) as c from t_base_role where b_use=1 and role_code=?` - list, err := db.SQL(sql, roleCode).Query().List() +func ExistRoleCode(roleId string, roleCode string) (bool, error) { + sql := `select count(1) as c from t_base_role where b_use=1 and role_code=? and role_id<>?` + list, err := db.SQL(sql, roleCode, roleId).Query().List() if err != nil { return false, err } @@ -81,7 +81,7 @@ func DeleteRoleAppRepleation(roleId string) { //获取角色与系统的关联关系 func GetRoleAppRepleation(roleId string) ([]map[string]interface{}, error) { var myBuilder = builder.Dialect(builder.MYSQL).Select("t1.*,t2.app_name").From("t_base_role_app as t1") - myBuilder.InnerJoin("t_app_base as t2","t1.app_id=t2.app_id") + myBuilder.InnerJoin("t_app_base as t2", "t1.app_id=t2.app_id") myBuilder.And(builder.Eq{"t1.app_id": roleId}) myBuilder.And(builder.Eq{"t1.b_use": 1}) //获取拼接完成的SQL语句 diff --git a/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go b/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go index 0145d9d1..973c46d2 100644 --- a/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go +++ b/dsBaseRpc/RpcService/BaseRole/BaseRoleService/BaseRoleService.go @@ -52,7 +52,7 @@ func (s *Rpc) AddBaseRole(ctx context.Context, in *BaseRoleProto.ModelArg) (*Bas //调用dao model := new(models.TBaseRole) //检查一下RoleCode是不是已存在 - exist, err := BaseRoleDao.ExistRoleCode(in.RoleCode) + exist, err := BaseRoleDao.ExistRoleCode(in.RoleId,in.RoleCode) if err != nil { reply.Success = false reply.Message = "检查角色代码是否存在时发生严重错误!"