【7.6.0】【sys】【role】整理获取分页列表

pull/55/MERGE
fengshuonan 2023-06-12 20:40:04 +08:00
parent f0f738bd10
commit 10d210d1d4
2 changed files with 14 additions and 38 deletions

View File

@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
@ -76,17 +75,6 @@ public class SysRoleController {
return new SuccessResponseData<>(sysRoleService.detail(sysRoleRequest));
}
/**
*
*
* @author fengshuonan
* @date 2023/06/10 21:29
*/
@GetResource(name = "获取列表", path = "/sysRole/list")
public ResponseData<List<SysRole>> list(SysRoleRequest sysRoleRequest) {
return new SuccessResponseData<>(sysRoleService.findList(sysRoleRequest));
}
/**
*
*

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRole;
@ -16,7 +17,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
/**
@ -28,7 +28,7 @@ import java.util.List;
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
@Override
@Override
public void add(SysRoleRequest sysRoleRequest) {
SysRole sysRole = new SysRole();
BeanUtil.copyProperties(sysRoleRequest, sysRole);
@ -56,6 +56,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
@Override
public PageResult<SysRole> findPage(SysRoleRequest sysRoleRequest) {
LambdaQueryWrapper<SysRole> wrapper = createWrapper(sysRoleRequest);
// 只查询需要的字段
wrapper.select(SysRole::getRoleName, SysRole::getRoleCode, SysRole::getRoleSort, SysRole::getRoleId, BaseEntity::getCreateTime);
Page<SysRole> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
return PageResultFactory.createPageResult(sysRolePage);
}
@ -89,31 +93,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
private LambdaQueryWrapper<SysRole> createWrapper(SysRoleRequest sysRoleRequest) {
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
Long roleId = sysRoleRequest.getRoleId();
String roleName = sysRoleRequest.getRoleName();
String roleCode = sysRoleRequest.getRoleCode();
BigDecimal roleSort = sysRoleRequest.getRoleSort();
Integer dataScopeType = sysRoleRequest.getDataScopeType();
Integer statusFlag = sysRoleRequest.getStatusFlag();
String remark = sysRoleRequest.getRemark();
String roleSystemFlag = sysRoleRequest.getRoleSystemFlag();
String expandField = sysRoleRequest.getExpandField();
Long versionFlag = sysRoleRequest.getVersionFlag();
String delFlag = sysRoleRequest.getDelFlag();
Long tenantId = sysRoleRequest.getTenantId();
// 根据名称模糊搜索
String searchText = sysRoleRequest.getSearchText();
if (ObjectUtil.isNotEmpty(searchText)) {
queryWrapper.like(SysRole::getRoleName, searchText);
queryWrapper.or().like(SysRole::getRoleCode, searchText);
}
queryWrapper.eq(ObjectUtil.isNotNull(roleId), SysRole::getRoleId, roleId);
queryWrapper.like(ObjectUtil.isNotEmpty(roleName), SysRole::getRoleName, roleName);
queryWrapper.like(ObjectUtil.isNotEmpty(roleCode), SysRole::getRoleCode, roleCode);
queryWrapper.eq(ObjectUtil.isNotNull(roleSort), SysRole::getRoleSort, roleSort);
queryWrapper.eq(ObjectUtil.isNotNull(dataScopeType), SysRole::getDataScopeType, dataScopeType);
queryWrapper.eq(ObjectUtil.isNotNull(statusFlag), SysRole::getStatusFlag, statusFlag);
queryWrapper.like(ObjectUtil.isNotEmpty(remark), SysRole::getRemark, remark);
queryWrapper.like(ObjectUtil.isNotEmpty(roleSystemFlag), SysRole::getRoleSystemFlag, roleSystemFlag);
queryWrapper.like(ObjectUtil.isNotEmpty(expandField), SysRole::getExpandField, expandField);
queryWrapper.eq(ObjectUtil.isNotNull(versionFlag), SysRole::getVersionFlag, versionFlag);
queryWrapper.like(ObjectUtil.isNotEmpty(delFlag), SysRole::getDelFlag, delFlag);
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), SysRole::getTenantId, tenantId);
// 排序字段
queryWrapper.orderByAsc(SysRole::getRoleSort);
return queryWrapper;
}