分页查询客户
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
package com.fuyuanshen.fyscustomer.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.fyscustomer.domain.Customer;
|
||||
import com.fuyuanshen.fyscustomer.domain.query.UserQueryCriteria;
|
||||
import com.fuyuanshen.fyscustomer.domain.vo.ConsumerVo;
|
||||
import com.fuyuanshen.fyscustomer.service.CustomerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -31,6 +34,21 @@ public class CustomerController {
|
||||
private final CustomerService customerService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询客户(限制子客户)
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询客户")
|
||||
@GetMapping(value = "/customer")
|
||||
public ResponseVO<PageResult<ConsumerVo>> queryCustomer(UserQueryCriteria criteria) {
|
||||
Page<Customer> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
PageResult<ConsumerVo> pageUsers = customerService.queryCustomers(criteria, page);
|
||||
return ResponseVO.success(pageUsers);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/allCustomer")
|
||||
@Operation(summary = "查询所有客户")
|
||||
public ResponseVO<List<Customer>> queryAllCustomer(UserQueryCriteria criteria) {
|
||||
|
@ -37,6 +37,9 @@ public class UserQueryCriteria implements Serializable {
|
||||
@Schema(name = "ids")
|
||||
private Set<Long> ids;
|
||||
|
||||
@Schema(name = "pid")
|
||||
private Long pid;
|
||||
|
||||
@Schema(name = "多个ID")
|
||||
private Set<Long> deptIds = new HashSet<>();
|
||||
|
||||
|
@ -0,0 +1,97 @@
|
||||
package com.fuyuanshen.fyscustomer.domain.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1211:34
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConsumerVo implements Serializable {
|
||||
|
||||
@Schema(name = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(hidden = true)
|
||||
private Long deptId;
|
||||
|
||||
@Schema(hidden = true)
|
||||
private Long pid;
|
||||
|
||||
@Schema(hidden = true)
|
||||
private Byte userLevel;
|
||||
|
||||
|
||||
@Schema(name = "账号")
|
||||
private String username;
|
||||
|
||||
@Schema(name = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
@Schema(name = "邮箱")
|
||||
private String email;
|
||||
|
||||
@Schema(name = "电话号码")
|
||||
private String phone;
|
||||
|
||||
@Schema(name = "用户性别")
|
||||
private String gender;
|
||||
|
||||
@Schema(name = "头像真实名称", hidden = true)
|
||||
private String avatarName;
|
||||
|
||||
@Schema(name = "头像存储的路径", hidden = true)
|
||||
private String avatarPath;
|
||||
|
||||
@Schema(name = "密码")
|
||||
private String password;
|
||||
|
||||
@Schema(name = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(name = "是否为admin账号", hidden = true)
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
@Schema(name = "最后修改密码的时间", hidden = true)
|
||||
private Date pwdResetTime;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(hidden = true)
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
private List<ConsumerVo> children;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ConsumerVo consumer = (ConsumerVo) o;
|
||||
return Objects.equals(id, consumer.id) && Objects.equals(username, consumer.username);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -15,6 +15,23 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface CustomerMapper extends BaseMapper<Customer> {
|
||||
|
||||
/**
|
||||
* 分页查询客户
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
List<Customer> findCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 获取分页总数
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
Long countCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有客户
|
||||
*
|
||||
@ -23,7 +40,6 @@ public interface CustomerMapper extends BaseMapper<Customer> {
|
||||
*/
|
||||
List<Customer> queryAllCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询客户
|
||||
*
|
||||
@ -32,5 +48,13 @@ public interface CustomerMapper extends BaseMapper<Customer> {
|
||||
*/
|
||||
List<Customer> queryCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据id查询客户
|
||||
*
|
||||
* @param customerId
|
||||
* @return
|
||||
*/
|
||||
Customer queryCustomerById(@Param("customerId") Long customerId, @Param("pid") Long pid);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.fuyuanshen.fyscustomer.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.fyscustomer.domain.Customer;
|
||||
import com.fuyuanshen.fyscustomer.domain.query.UserQueryCriteria;
|
||||
import com.fuyuanshen.fyscustomer.domain.vo.ConsumerVo;
|
||||
import io.undertow.util.BadRequestException;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,6 +16,17 @@ import java.util.Set;
|
||||
*/
|
||||
public interface CustomerService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询客户
|
||||
*
|
||||
* @param criteria
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
PageResult<ConsumerVo> queryCustomers(UserQueryCriteria criteria, Page<Customer> page);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有客户
|
||||
*
|
||||
|
@ -1,10 +1,15 @@
|
||||
package com.fuyuanshen.fyscustomer.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.core.utils.PageUtil;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.fyscustomer.domain.Customer;
|
||||
import com.fuyuanshen.fyscustomer.domain.query.UserQueryCriteria;
|
||||
import com.fuyuanshen.fyscustomer.domain.vo.ConsumerVo;
|
||||
import com.fuyuanshen.fyscustomer.mapper.CustomerMapper;
|
||||
import com.fuyuanshen.fyscustomer.service.CustomerService;
|
||||
import io.undertow.util.BadRequestException;
|
||||
@ -26,6 +31,24 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
private final CustomerMapper customerMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询客户
|
||||
*
|
||||
* @param criteria
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ConsumerVo> queryCustomers(UserQueryCriteria criteria, Page<Customer> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
criteria.setPid(LoginHelper.getUserId());
|
||||
List<Customer> users = customerMapper.findCustomers(criteria);
|
||||
List<ConsumerVo> consumerVoList = BeanUtil.copyToList(users, ConsumerVo.class);
|
||||
Long total = customerMapper.countCustomers(criteria);
|
||||
return PageUtil.toPage(consumerVoList, total);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有客户
|
||||
*
|
||||
|
Reference in New Issue
Block a user