This commit is contained in:
2023-11-14 18:46:16 +08:00
parent 1281a19bd9
commit 574c0df384
3 changed files with 14 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ import top.fatweb.api.entity.permission.Role
*/
@Mapper
interface RoleMapper : BaseMapper<Role> {
fun selectPage(page: IPage<Long>): IPage<Long>
fun selectPage(page: IPage<Long>, searchName: String?, searchRegex: Boolean): IPage<Long>
fun getWithPowerByList(roleIds: List<Long>): List<Role>?

View File

@@ -34,7 +34,8 @@ class RoleServiceImpl(
PageUtil.setPageSort(roleGetParam, roleIdsPage)
val roleIdsIPage = baseMapper.selectPage(roleIdsPage)
val roleIdsIPage =
baseMapper.selectPage(roleIdsPage, roleGetParam?.searchName, roleGetParam?.searchRegex ?: false)
val rolePage = Page<Role>(roleIdsPage.current, roleIdsIPage.size, roleIdsIPage.total)
rolePage.setRecords(baseMapper.getWithPowerByList(roleIdsIPage.records))

View File

@@ -4,7 +4,17 @@
<select id="selectPage" resultType="long">
select id
from t_role
where deleted = 0
<where>
deleted = 0
<choose>
<when test="searchRegex == true">
and t_role.name regexp #{searchName}
</when>
<otherwise>
and t_role.name like concat('%' ,#{searchName}, '%')
</otherwise>
</choose>
</where>
</select>
<select id="getWithPowerByList" resultMap="roleWithPowerMap">