mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 06:29:20 +08:00
更新分页查询账户信息响应数据结构
This commit is contained in:
+10
-9
@@ -6,10 +6,11 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.AccountFilterDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.AccountFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.CreateAccountDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.CreateAccountDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.UpdateAccountDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.UpdateAccountDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountPageVO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountVO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.service.AccountService;
|
import top.xyquan.ecomdmbbackend.modules.org.service.AccountService;
|
||||||
|
|
||||||
@@ -37,10 +38,10 @@ public class AccountController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "分页查询账户(超管)", description = "超级管理员分页查询所有账户")
|
@Operation(summary = "分页查询账户(超管)", description = "超级管理员分页查询所有账户")
|
||||||
@GetMapping("/page")
|
@PostMapping("/page")
|
||||||
public ApiResponse<AccountPageVO> getAccountPage(@Valid AccountFilterDTO filterDTO) {
|
public ApiResponse<PageResultVO<AccountVO>> getAccountPage(@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||||
AccountPageVO pageVO = accountService.getAccountPage(filterDTO);
|
PageResultVO<AccountVO> pageResult = accountService.getAccountPage(pageQuery);
|
||||||
return ApiResponse.success(pageVO);
|
return ApiResponse.success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 管理员接口 ====================
|
// ==================== 管理员接口 ====================
|
||||||
@@ -53,10 +54,10 @@ public class AccountController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "分页查询账户(管理员)", description = "公司管理员分页查询本公司账户")
|
@Operation(summary = "分页查询账户(管理员)", description = "公司管理员分页查询本公司账户")
|
||||||
@GetMapping("/company/page")
|
@PostMapping("/company/page")
|
||||||
public ApiResponse<AccountPageVO> getAccountPageForCompany(@Valid AccountFilterDTO filterDTO) {
|
public ApiResponse<PageResultVO<AccountVO>> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||||
AccountPageVO pageVO = accountService.getAccountPageForCompany(filterDTO);
|
PageResultVO<AccountVO> pageResult = accountService.getAccountPageForCompany(pageQuery);
|
||||||
return ApiResponse.success(pageVO);
|
return ApiResponse.success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 通用接口 ====================
|
// ==================== 通用接口 ====================
|
||||||
|
|||||||
+6
-5
@@ -1,11 +1,12 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.org.service;
|
package top.xyquan.ecomdmbbackend.modules.org.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.AccountFilterDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.AccountFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.CreateAccountDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.CreateAccountDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.UpdateAccountDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.UpdateAccountDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.po.UserPO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.po.UserPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountPageVO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountVO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,16 +57,16 @@ public interface AccountService extends IService<UserPO> {
|
|||||||
/**
|
/**
|
||||||
* 分页查询账户(超管接口)
|
* 分页查询账户(超管接口)
|
||||||
*
|
*
|
||||||
* @param filterDTO 查询条件
|
* @param pageQuery 分页查询参数
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
AccountPageVO getAccountPage(AccountFilterDTO filterDTO);
|
PageResultVO<AccountVO> getAccountPage(PageQueryDTO<AccountFilterDTO> pageQuery);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询账户(管理员接口,只能查询本公司账户)
|
* 分页查询账户(管理员接口,只能查询本公司账户)
|
||||||
*
|
*
|
||||||
* @param filterDTO 查询条件
|
* @param pageQuery 分页查询参数
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
AccountPageVO getAccountPageForCompany(AccountFilterDTO filterDTO);
|
PageResultVO<AccountVO> getAccountPageForCompany(PageQueryDTO<AccountFilterDTO> pageQuery);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-15
@@ -9,12 +9,13 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.mapper.UserMapper;
|
import top.xyquan.ecomdmbbackend.modules.sys.mapper.UserMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.AccountFilterDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.AccountFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.CreateAccountDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.CreateAccountDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.UpdateAccountDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.account.UpdateAccountDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.po.UserPO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.po.UserPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountPageVO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountVO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.vo.AccountVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.service.AccountService;
|
import top.xyquan.ecomdmbbackend.modules.org.service.AccountService;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyService;
|
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyService;
|
||||||
@@ -188,12 +189,12 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountPageVO getAccountPage(AccountFilterDTO filterDTO) {
|
public PageResultVO<AccountVO> getAccountPage(PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
LambdaQueryWrapper<UserPO> wrapper = buildQueryWrapper(filterDTO);
|
LambdaQueryWrapper<UserPO> wrapper = buildQueryWrapper(pageQuery.getFilters());
|
||||||
|
|
||||||
// 分页查询
|
// 分页查询
|
||||||
Page<UserPO> page = new Page<>(filterDTO.getPageNum(), filterDTO.getPageSize());
|
Page<UserPO> page = new Page<>(pageQuery.getPage(), pageQuery.getPageSize());
|
||||||
IPage<UserPO> pageResult = this.page(page, wrapper);
|
IPage<UserPO> pageResult = this.page(page, wrapper);
|
||||||
|
|
||||||
// 转换为VO
|
// 转换为VO
|
||||||
@@ -202,18 +203,11 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 构建分页响应
|
// 构建分页响应
|
||||||
AccountPageVO pageVO = new AccountPageVO();
|
return PageResultVO.create(records, pageResult.getTotal(), pageQuery.getPage(), pageQuery.getPageSize());
|
||||||
pageVO.setRecords(records);
|
|
||||||
pageVO.setTotal(pageResult.getTotal());
|
|
||||||
pageVO.setCurrent(pageResult.getCurrent());
|
|
||||||
pageVO.setSize(pageResult.getSize());
|
|
||||||
pageVO.setPages(pageResult.getPages());
|
|
||||||
|
|
||||||
return pageVO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountPageVO getAccountPageForCompany(AccountFilterDTO filterDTO) {
|
public PageResultVO<AccountVO> getAccountPageForCompany(PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||||
// 从用户上下文获取公司ID
|
// 从用户上下文获取公司ID
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
if (companyId == null) {
|
if (companyId == null) {
|
||||||
@@ -221,10 +215,13 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置公司ID过滤条件
|
// 设置公司ID过滤条件
|
||||||
filterDTO.setCompanyId(companyId);
|
if (pageQuery.getFilters() == null) {
|
||||||
|
pageQuery.setFilters(new AccountFilterDTO());
|
||||||
|
}
|
||||||
|
pageQuery.getFilters().setCompanyId(companyId);
|
||||||
|
|
||||||
// 调用通用分页查询方法
|
// 调用通用分页查询方法
|
||||||
return getAccountPage(filterDTO);
|
return getAccountPage(pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,6 +230,13 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
private LambdaQueryWrapper<UserPO> buildQueryWrapper(AccountFilterDTO filterDTO) {
|
private LambdaQueryWrapper<UserPO> buildQueryWrapper(AccountFilterDTO filterDTO) {
|
||||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 如果过滤条件为空,直接返回基础查询条件
|
||||||
|
if (filterDTO == null) {
|
||||||
|
wrapper.ne(UserPO::getStatus, 1);
|
||||||
|
wrapper.orderByDesc(UserPO::getCreateTime);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
// 登录账号
|
// 登录账号
|
||||||
if (StringUtils.hasText(filterDTO.getLoginCode())) {
|
if (StringUtils.hasText(filterDTO.getLoginCode())) {
|
||||||
wrapper.like(UserPO::getLoginCode, filterDTO.getLoginCode());
|
wrapper.like(UserPO::getLoginCode, filterDTO.getLoginCode());
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 362 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 336 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 297 KiB |
Reference in New Issue
Block a user