paper permission
This commit is contained in:
parent
b8d1d81ac9
commit
ab117af819
@ -139,13 +139,56 @@ public class AcPermissionService {
|
||||
List<SystemAbility> abilityList = findAbilitiesByPermissionId(permissionId);
|
||||
return PermissionConvertor.convertWholePermissionRspVoFrom(permission, abilityList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取权限
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public PageVO<PermissionBasicRspVo> findByPage(FindPermissionBasicByPageReqVo req) {
|
||||
return null;
|
||||
PageVO<PermissionBasicRspVo> page = new PageVO<>();
|
||||
//
|
||||
PermissionExample permissionExample = new PermissionExample();
|
||||
if (null != req.getName() || null != req.getDes()) {
|
||||
PermissionExample.Criteria pc = permissionExample.createCriteria();
|
||||
if (null != req.getName()) {
|
||||
if (req.getNameLike()) {
|
||||
pc.andNameLike(String.format("%%%s%%", req.getName()));
|
||||
} else {
|
||||
pc.andNameEqualTo(req.getName());
|
||||
}
|
||||
}
|
||||
if (null != req.getDes()) {
|
||||
if (req.getDesLike()) {
|
||||
pc.andDesLike(String.format("%%%s%%", req.getDes()));
|
||||
} else {
|
||||
pc.andDesEqualTo(req.getDes());
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
long sum = this.permissionDAO.countByExample(permissionExample);
|
||||
page.setTotal(sum);
|
||||
page.setPageNum(req.getPageNum());
|
||||
page.setPageSize(req.getPageSize());
|
||||
page.setList(new ArrayList<>());
|
||||
if (sum > 0) {
|
||||
//
|
||||
String orderBy = req.getOrderByType().with();
|
||||
long startIndex = (req.getPageNum() - 1) * req.getPageSize();
|
||||
//
|
||||
if (req.getDesc()) {
|
||||
permissionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize()));
|
||||
} else {
|
||||
permissionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize()));
|
||||
}
|
||||
List<Permission> pContent = this.permissionDAO.selectByExample(permissionExample);
|
||||
if (!CollectionUtils.isEmpty(pContent)) {
|
||||
page.setList(pContent.stream().map(PermissionConvertor::convertPermissionBasicRspVoFrom).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) {
|
||||
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();
|
||||
psaExample.createCriteria().andPermissionIdEqualTo(permissionId);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package club.joylink.rtss.vo.permission;
|
||||
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.paper.FindPuType;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import lombok.Data;
|
||||
@ -35,12 +34,16 @@ public class FindPermissionBasicByPageReqVo extends PageQueryVO {
|
||||
*/
|
||||
private Boolean desc = true;
|
||||
/**
|
||||
* 排序类型
|
||||
* 排序类型,默认按权限创建时间排序,序列化为数值:1-权限名称,2-权限描述,3-权限创建时间,4-权限更新时间
|
||||
*/
|
||||
private OrderByType orderByType;
|
||||
private OrderByType orderByType = OrderByType.OrderByCreateTime;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
public static enum OrderByType {
|
||||
OrderByName(1, "name"),
|
||||
OrderByDes(2, "des"),
|
||||
OrderByCreateTime(3, "create_time"),
|
||||
OrderByUpdateTime(4, "update_time"),
|
||||
;
|
||||
private Integer value;
|
||||
private String orderBy;
|
||||
@ -50,7 +53,7 @@ public class FindPermissionBasicByPageReqVo extends PageQueryVO {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public String orderBy() {
|
||||
public String with() {
|
||||
return this.orderBy;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.rtss.vo.permission.convertor;
|
||||
|
||||
import club.joylink.rtss.entity.permission.Permission;
|
||||
import club.joylink.rtss.entity.permission.SystemAbility;
|
||||
import club.joylink.rtss.vo.permission.PermissionBasicRspVo;
|
||||
import club.joylink.rtss.vo.permission.WholePermissionRspVo;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@ -25,4 +26,14 @@ public class PermissionConvertor {
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
public static PermissionBasicRspVo convertPermissionBasicRspVoFrom(Permission from){
|
||||
PermissionBasicRspVo rt = new PermissionBasicRspVo();
|
||||
rt.setId(from.getId());
|
||||
rt.setDes(from.getDes());
|
||||
rt.setName(from.getName());
|
||||
rt.setCreateTime(from.getCreateTime());
|
||||
rt.setUpdateTime(from.getUpdateTime());
|
||||
rt.setCreatorId(from.getCreatorId());
|
||||
return rt;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user