master
黄海 5 years ago
parent b7e64ee1b6
commit 6d607a7e68

@ -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语句

@ -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 = "检查角色代码是否存在时发生严重错误!"

Loading…
Cancel
Save