Skip to content

Commit

Permalink
Merge pull request #58 from Jzow/master
Browse files Browse the repository at this point in the history
Update rolePageList add return to character menu information
  • Loading branch information
Jzow authored Sep 28, 2023
2 parents 66dfd88 + 747bd7a commit 6ede574
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions domain/src/main/java/com/wansensoft/vo/RoleVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
Expand All @@ -41,6 +42,8 @@ public class RoleVO {

private String description;

private List<Integer> menuIds;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime createTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.wansensoft.dto.role.AddOrUpdateRoleDTO
import com.wansensoft.dto.role.RoleListDTO
import com.wansensoft.entities.role.SysRole
import com.wansensoft.entities.role.SysRoleMenuRel
import com.wansensoft.mappers.role.SysRoleMapper
import com.wansensoft.mappers.role.SysRoleMenuRelMapper
import com.wansensoft.mappers.user.SysUserRoleRelMapper
import com.wansensoft.utils.SnowflakeIdUtil
import com.wansensoft.utils.constants.CommonConstants
import com.wansensoft.utils.enums.BaseCodeEnum
Expand All @@ -15,12 +18,13 @@ import com.wansensoft.utils.response.Response
import com.wansensoft.vo.RoleVO
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
import org.springframework.util.StringUtils
import java.time.LocalDateTime

@Service
open class KtSysRoleServiceImpl(private val roleMapper: SysRoleMapper)
: ServiceImpl<SysRoleMapper, SysRole>(), KtSysRoleService {
open class KtSysRoleServiceImpl(
private val roleMapper: SysRoleMapper,
private val roleMenuRelMapper: SysRoleMenuRelMapper
) : ServiceImpl<SysRoleMapper, SysRole>(), KtSysRoleService {

override fun roleList(): Response<List<RoleVO>> {
val roles = ArrayList<RoleVO>()
Expand All @@ -37,6 +41,13 @@ open class KtSysRoleServiceImpl(private val roleMapper: SysRoleMapper)
return Response.responseData(roles)
}


/**
* 分页查询角色列表
*
* @param roleListDTO 角色列表查询条件
* @return 角色列表
*/
override fun rolePageList(roleListDTO: RoleListDTO?): Response<Page<RoleVO>> {
val rolePage = roleListDTO?.let { Page<SysRole>(it.page, it.pageSize) }
val roleWrapper = LambdaQueryWrapper<SysRole>().apply {
Expand All @@ -53,6 +64,22 @@ open class KtSysRoleServiceImpl(private val roleMapper: SysRoleMapper)
BeanUtils.copyProperties(role, this)
}
}
listVo.forEach { roleVo ->
val roleMenuRelList = roleMenuRelMapper.selectList(
LambdaQueryWrapper<SysRoleMenuRel>()
.eq(SysRoleMenuRel::getRoleId, roleVo.id)
)
val menuList = ArrayList<Int>()
roleMenuRelList.forEach { roleMenuRel ->
val menuId = roleMenuRel.menuId
val regex = "\\d+".toRegex()
val matchResult = regex.findAll(menuId)
matchResult.forEach { match ->
menuList.add(match.value.toInt())
}
}
roleVo.menuIds = menuList
}
Page<RoleVO>().apply {
records = listVo
total = this@run.total
Expand All @@ -67,7 +94,6 @@ open class KtSysRoleServiceImpl(private val roleMapper: SysRoleMapper)
return Response.responseData(result)
}


override fun updateStatus(id: String?, status: Int?): Response<String> {
if (id.isNullOrBlank() || status == null) {
return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL)
Expand Down Expand Up @@ -144,6 +170,4 @@ open class KtSysRoleServiceImpl(private val roleMapper: SysRoleMapper)
}
return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL)
}


}

0 comments on commit 6ede574

Please sign in to comment.