✨ 角色管理分页,并修复多甲方合同应收明细未生成
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+6
-4
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -37,6 +38,7 @@ import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
@@ -85,7 +87,7 @@ public class RoleController extends BladeController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* 分页列表(按树形根节点分页)
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@@ -93,9 +95,9 @@ public class RoleController extends BladeController {
|
||||
@Parameter(name = "roleAlias", description = "角色别名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "列表", description = "传入role")
|
||||
public R<List<RoleVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> role) {
|
||||
return R.data(roleService.selectList(role));
|
||||
@Operation(summary = "分页", description = "传入role")
|
||||
public R<IPage<RoleVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> role, Query query) {
|
||||
return R.data(roleService.selectPage(role, query));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
@@ -27,6 +27,7 @@ package org.springblade.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.system.pojo.entity.Role;
|
||||
import org.springblade.system.pojo.vo.RoleVO;
|
||||
|
||||
@@ -58,6 +59,15 @@ public interface IRoleService extends IService<Role> {
|
||||
*/
|
||||
List<RoleVO> selectList(Map<String, Object> role);
|
||||
|
||||
/**
|
||||
* 角色分页(按树形根节点分页,子节点随根节点返回)
|
||||
*
|
||||
* @param role 查询条件 Map
|
||||
* @param query 分页参数
|
||||
* @return 角色分页结果,非超管时仅命中当前会话租户
|
||||
*/
|
||||
IPage<RoleVO> selectPage(Map<String, Object> role, Query query);
|
||||
|
||||
/**
|
||||
* 自定义角色分页查询
|
||||
*
|
||||
|
||||
+22
@@ -33,6 +33,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tenant.TenantGuard;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
@@ -92,9 +93,30 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
||||
public List<RoleVO> selectList(Map<String, Object> role) {
|
||||
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class);
|
||||
applyTenantScope(queryWrapper);
|
||||
queryWrapper.lambda().orderByAsc(Role::getSort).orderByAsc(Role::getId);
|
||||
return RoleWrapper.build().listNodeVO(list(queryWrapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<RoleVO> selectPage(Map<String, Object> role, Query query) {
|
||||
List<RoleVO> tree = selectList(role);
|
||||
IPage<RoleVO> page = Condition.getPage(query);
|
||||
long total = tree.size();
|
||||
page.setTotal(total);
|
||||
if (total == 0L || page.getSize() < 1L) {
|
||||
page.setRecords(Collections.emptyList());
|
||||
return page;
|
||||
}
|
||||
int fromIndex = (int) ((page.getCurrent() - 1L) * page.getSize());
|
||||
if (fromIndex >= tree.size()) {
|
||||
page.setRecords(Collections.emptyList());
|
||||
return page;
|
||||
}
|
||||
int toIndex = (int) Math.min(fromIndex + page.getSize(), tree.size());
|
||||
page.setRecords(new ArrayList<>(tree.subList(fromIndex, toIndex)));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role) {
|
||||
return page.setRecords(baseMapper.selectRolePage(page, role));
|
||||
|
||||
Reference in New Issue
Block a user