select r.roleID,r.userTypeID,r.name,r.description,r.isDefault,r.defaultDataRange,r.recordStatus,r.createBy,r.createTime,r.updateBy,r.updateTime
, dicUserType.Name as userTypeName,dicDataRange.Name as dataRangeName
from sys_role r
left join sys_dictionary_item dicUserType on r.UserTypeID = dicUserType.Value and dicUserType.DictionaryCode='UserType'
left join sys_dictionary_item dicDataRange on r.defaultDataRange = dicDataRange.Value and dicDataRange.DictionaryCode='DataRange'
where 1=1
and r.roleId = #{roleID}
and r.name like Concat('%',#{name},'%')
and r.userTypeID = #{userTypeID}
select fc.functionCode,fc.functionName,fc.parentFunctionCode,fc.orderNo
,case when rf.FunctionCode is not null then 1 else 0 end as isPermission
,case when m.FunctionCode is not null then 1 else 0 end as isMenu
,rd.dataRangeID
from sys_function_code fc
left join sys_role_sys_function_code rf on fc.FunctionCode = rf.FunctionCode and rf.RoleID = #{roleID}
left join sys_role_datarange rd on rf.FunctionCode = rd.FunctionCode and rf.RoleID = rd.RoleID
left join (select distinct FunctionCode from sys_menu) m on fc.FunctionCode = m.FunctionCode
where 1=1
and fc.functionCode like Concat('',#{menuTopNo},'%')
order by fc.ParentFunctionCode,fc.orderNo
insert into sys_user_sys_role(UserID, RoleID)
values
(#{userID},#{roleID})
insert into sys_role_sys_function_code(RoleID, FunctionCode)
values
(#{roleID},#{item.functionCode})
insert into sys_role_datarange(RoleDataRangeID, RoleID,FunctionCode,DataRangeID,CreateBy,CreateTime)
values
(uuid(),#{roleID},#{item.functionCode},#{item.dataRangeID},#{userID},sysdate())
delete from sys_user_sys_role where 1=1
and roleID in
#{roleID}
delete from sys_role_sys_function_code where 1=1
and roleID in
#{roleID}
delete from sys_role_datarange where 1=1
and roleID in
#{roleID}
select u.userId,u.name,u.loginId
from sys_role r
inner join sys_user_sys_role ur on r.RoleID = ur.RoleID
inner join sys_user u on ur.UserID = u.UserID
where 1=1
and r.roleId = #{roleID}
and u.name like Concat('%',#{name},'%')
and u.loginId like Concat('%',#{loginID},'%')
select u.userId,u.name,u.loginId,u.userId as 'key'
from sys_user u
left join sys_user_sys_role ur on u.userId = ur.userId and ur.roleID=#{roleID}
where 1=1 and ur.roleID is null
select u.userId,u.name,u.loginId
from sys_role r
inner join sys_user_sys_role ur on r.RoleID = ur.RoleID
inner join sys_user u on ur.UserID = u.UserID
where 1=1
and r.Name in
#{rolename}