feat():新增返回结果集对象
parent
bb0b502e0c
commit
085f64e7cb
|
@ -24,7 +24,7 @@ public class CustomerListReq {
|
||||||
/**
|
/**
|
||||||
* 服务/客户编码
|
* 服务/客户编码
|
||||||
*/
|
*/
|
||||||
@Schema(name = "appCode",defaultValue = "customer_code",type = "String",description = "客户名称,为微服务名称")
|
@Schema(defaultValue = "customer_code",type = "String",description = "客户名称,为微服务名称")
|
||||||
private String appCode;
|
private String appCode;
|
||||||
/**
|
/**
|
||||||
* 状态 - sys_yes_no
|
* 状态 - sys_yes_no
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.muyu.cloud.pay.domain.resp;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Tag(name = "客户信息相应对象",description = "负责客户信息查询的响应结果")
|
||||||
|
public class CustomerResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@Schema(description = "客户ID",defaultValue = "1",type = "Long")
|
||||||
|
private Long id ;
|
||||||
|
/**
|
||||||
|
* 服务/客户名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "客户名称",defaultValue = "商品服务",type = "String")
|
||||||
|
private String appName;
|
||||||
|
/**
|
||||||
|
* 服务/客户编码
|
||||||
|
*/
|
||||||
|
@Schema(description = "客户编码",defaultValue = "cloud_order",type = "String")
|
||||||
|
private String appCode;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
@Schema(description = "客户状态,同数据字典-系统是否",defaultValue = "Y",type = "String")
|
||||||
|
private String status;
|
||||||
|
@Schema(description = "创建人",defaultValue = "muyu",type = "String")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建时间",defaultValue = "2024-7-31 14:30:29",type = "Date")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**\
|
||||||
|
* 数据库对象构建为返回结果对象
|
||||||
|
* @param orderPayCustomer 数据对象
|
||||||
|
* @return 视图对象
|
||||||
|
*/
|
||||||
|
public static CustomerResp customerBuild(OrderPayCustomer orderPayCustomer) {
|
||||||
|
return CustomerResp.builder()
|
||||||
|
.id(orderPayCustomer.getId())
|
||||||
|
.appName(orderPayCustomer.getAppName())
|
||||||
|
.appCode(orderPayCustomer.getAppCode())
|
||||||
|
.status(orderPayCustomer.getStatus())
|
||||||
|
.createBy(orderPayCustomer.getCreateBy())
|
||||||
|
.createTime(orderPayCustomer.getCreateTime())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.muyu.cloud.pay.controller;
|
||||||
|
|
||||||
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||||
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
||||||
|
import com.muyu.cloud.pay.domain.resp.CustomerResp;
|
||||||
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -38,7 +39,7 @@ public class OrderPayCustomerController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping(path = "/list",method = RequestMethod.POST)
|
@RequestMapping(path = "/list",method = RequestMethod.POST)
|
||||||
@Operation(summary = "查看客户" , description = "根据客户的名称、编码、是否开启等可以进行客户的筛选")
|
@Operation(summary = "查看客户" , description = "根据客户的名称、编码、是否开启等可以进行客户的筛选")
|
||||||
public Result<List<OrderPayCustomer>> selectList(
|
public Result<List<CustomerResp>> selectList(
|
||||||
@Validated @RequestBody CustomerListReq customerListReq
|
@Validated @RequestBody CustomerListReq customerListReq
|
||||||
){
|
){
|
||||||
return Result.success(
|
return Result.success(
|
||||||
|
|
|
@ -4,6 +4,7 @@ package com.muyu.cloud.pay.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||||
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
||||||
|
import com.muyu.cloud.pay.domain.resp.CustomerResp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ public interface OrderPayCustomerService extends IService<OrderPayCustomer> {
|
||||||
* @param customerListReq 请求参数
|
* @param customerListReq 请求参数
|
||||||
* @return 客户集合
|
* @return 客户集合
|
||||||
*/
|
*/
|
||||||
List<OrderPayCustomer> selectList(CustomerListReq customerListReq);
|
List<CustomerResp> selectList(CustomerListReq customerListReq);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||||
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
||||||
|
import com.muyu.cloud.pay.domain.resp.CustomerResp;
|
||||||
import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
|
import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
|
||||||
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
@ -20,7 +22,7 @@ public class OrderPayCustomerServiceImpl
|
||||||
implements OrderPayCustomerService
|
implements OrderPayCustomerService
|
||||||
{
|
{
|
||||||
@Override //查询客户集合
|
@Override //查询客户集合
|
||||||
public List<OrderPayCustomer> selectList(CustomerListReq customerListReq) {
|
public List<CustomerResp> selectList(CustomerListReq customerListReq) {
|
||||||
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.like(
|
queryWrapper.like(
|
||||||
StringUtils.isNoneEmpty(customerListReq.getAppName()),
|
StringUtils.isNoneEmpty(customerListReq.getAppName()),
|
||||||
|
@ -34,6 +36,55 @@ public class OrderPayCustomerServiceImpl
|
||||||
StringUtils.isNoneEmpty(customerListReq.getStatus()),
|
StringUtils.isNoneEmpty(customerListReq.getStatus()),
|
||||||
OrderPayCustomer::getStatus,customerListReq.getStatus()
|
OrderPayCustomer::getStatus,customerListReq.getStatus()
|
||||||
);
|
);
|
||||||
return this.list(queryWrapper);
|
List<OrderPayCustomer> orderPayCustomerList = this.list(queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第一中写法
|
||||||
|
*/
|
||||||
|
// List<CustomerResp> customerRespList=new ArrayList<>();
|
||||||
|
// for (OrderPayCustomer orderPayCustomer : orderPayCustomerList) {
|
||||||
|
// CustomerResp customerResp = new CustomerResp();
|
||||||
|
// customerResp.setId(orderPayCustomer.getId());
|
||||||
|
// customerResp.setAppName(orderPayCustomer.getAppName());
|
||||||
|
// customerResp.setAppCode(orderPayCustomer.getAppCode());
|
||||||
|
// customerResp.setStatus(orderPayCustomer.getStatus());
|
||||||
|
// customerResp.setCreateBy(orderPayCustomer.getCreateBy());
|
||||||
|
// customerResp.setCreateTime(orderPayCustomer.getCreateTime());
|
||||||
|
// customerRespList.add(customerResp);
|
||||||
|
// }
|
||||||
|
/**
|
||||||
|
* 第二种 比第一种稍微高级的写法
|
||||||
|
*/
|
||||||
|
// orderPayCustomerList.stream()
|
||||||
|
// .map(orderPayCustomer -> {
|
||||||
|
// CustomerResp customerResp = new CustomerResp();
|
||||||
|
// customerResp.setId(orderPayCustomer.getId());
|
||||||
|
// customerResp.setAppName(orderPayCustomer.getAppName());
|
||||||
|
// customerResp.setAppCode(orderPayCustomer.getAppCode());
|
||||||
|
// customerResp.setStatus(orderPayCustomer.getStatus());
|
||||||
|
// customerResp.setCreateBy(orderPayCustomer.getCreateBy());
|
||||||
|
// customerResp.setCreateTime(orderPayCustomer.getCreateTime());
|
||||||
|
// return customerResp;
|
||||||
|
// }).toList();
|
||||||
|
/**
|
||||||
|
* 第三种 比上一个在高级的一种写法
|
||||||
|
*/
|
||||||
|
// customerRespList=orderPayCustomerList.stream()
|
||||||
|
// .map(orderPayCustomer ->
|
||||||
|
// CustomerResp.builder()
|
||||||
|
// .id(orderPayCustomer.getId())
|
||||||
|
// .appName(orderPayCustomer.getAppName())
|
||||||
|
// .appCode(orderPayCustomer.getAppCode())
|
||||||
|
// .status(orderPayCustomer.getStatus())
|
||||||
|
// .createBy(orderPayCustomer.getCreateBy())
|
||||||
|
// .createTime(orderPayCustomer.getCreateTime())
|
||||||
|
// .build()).toList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第四种 比上一个在高级的一种写法
|
||||||
|
*/
|
||||||
|
return orderPayCustomerList.stream()
|
||||||
|
.map(CustomerResp::customerBuild)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue