feat():新增商品列表查询接口
parent
75907ced24
commit
ad39c86702
|
@ -1,12 +1,17 @@
|
|||
package com.muyu.cloud.market.domin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.domin
|
||||
|
@ -24,7 +29,7 @@ public class Product extends BaseEntity {
|
|||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String productId;
|
||||
private Integer productId;
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
|
@ -32,7 +37,7 @@ public class Product extends BaseEntity {
|
|||
/**
|
||||
*产品价格
|
||||
*/
|
||||
private String productPrice;
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
*产品介绍
|
||||
*/
|
||||
|
@ -40,7 +45,7 @@ public class Product extends BaseEntity {
|
|||
/**
|
||||
*产品上架状态(是否上架 0未上架 1已上架)
|
||||
*/
|
||||
private String productState;
|
||||
private Integer productState;
|
||||
/**
|
||||
*产品规格(按次购买/按日期购买)购买多少次
|
||||
*/
|
||||
|
@ -48,15 +53,21 @@ public class Product extends BaseEntity {
|
|||
/**
|
||||
*产品库存
|
||||
*/
|
||||
private String productInventory;
|
||||
private Integer productInventory;
|
||||
/**
|
||||
*产品销量
|
||||
*/
|
||||
private String product_sales;
|
||||
private Integer productSales;
|
||||
/**
|
||||
* 产品类型
|
||||
*/
|
||||
private String productType;
|
||||
/**
|
||||
*产品上架日期
|
||||
*/
|
||||
private String product_shelvesdate;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "产品上架日期",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
||||
private Date productShelvesdate;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.cloud.market.domin.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -20,6 +22,8 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@Tag(name = "添加客户信息请求对象",description = "根据入参进行客户信息的添加")
|
||||
public class CustomerAddReq {
|
||||
|
||||
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.muyu.cloud.market.domin.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.domin.req
|
||||
* @Project:cloud-market
|
||||
* @name:CustomerUpdReq
|
||||
* @Date:2024/8/21 14:13
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "修改客户信息请求对象",description = "根据入参进行客户信息的修改")
|
||||
public class CustomerUpdReq {
|
||||
|
||||
/**
|
||||
* 客户Id
|
||||
*/
|
||||
@NotEmpty(message = "客户id不可为空")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 客户性别
|
||||
*/
|
||||
private String gender;
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private String idCard;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String tel;
|
||||
/**
|
||||
* 客户地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 征信状态
|
||||
*/
|
||||
private String credit;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.muyu.cloud.market.domin.req;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.domin.req
|
||||
* @Project:cloud-market
|
||||
* @name:ProductListReq
|
||||
* @Date:2024/8/21 15:15
|
||||
*/
|
||||
|
||||
@Tag(name = "接口产品列表请求对象")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ProductListReq {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description = "产品ID",defaultValue = "1",type = "Integer")
|
||||
private Integer id;
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
@Schema(description = "产品名称",defaultValue = "根据身份证查询",type = "String")
|
||||
private String productName;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@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-07-31 14:30:29",type = "Date")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.muyu.cloud.market.domin.resp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
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.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.domin.resp
|
||||
* @Project:cloud-market
|
||||
* @name:ProductListResp
|
||||
* @Date:2024/8/21 15:06
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Tag(name="接口产品信息响应对象",description = "接口产品查询的响应结果")
|
||||
public class ProductListResp {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer productId;
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
*产品价格
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
*产品介绍
|
||||
*/
|
||||
private String productContent;
|
||||
/**
|
||||
*产品上架状态(是否上架 0未上架 1已上架)
|
||||
*/
|
||||
private Integer productState;
|
||||
|
||||
@Schema(description = "创建人",defaultValue = "muyu",type = "String")
|
||||
private String createBy;
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@Schema(description = "创建时间",defaultValue = "2024-07-31 14:30:29",type = "Date")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
/**
|
||||
* 数据库对象构建为返回结果对象
|
||||
* @param product
|
||||
* @return
|
||||
*/
|
||||
public static ProductListResp productListRespbuild(Product product){
|
||||
return ProductListResp.builder()
|
||||
.productId(product.getProductId())
|
||||
.productName(product.getProductName())
|
||||
.productPrice(product.getProductPrice())
|
||||
.productContent(product.getProductContent())
|
||||
.productState(product.getProductState())
|
||||
.createBy(product.getCreateBy())
|
||||
.createTime(product.getCreateTime())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.muyu.cloud.market.controller;
|
||||
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
import com.muyu.cloud.market.domin.req.CustomerUpdReq;
|
||||
import com.muyu.cloud.market.service.InsideCustomerMessageService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.controller
|
||||
* @Project:cloud-market
|
||||
* @name:InsideUseInterfaceController
|
||||
* @Date:2024/8/20 20:42
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("InsideCostomerMessage")
|
||||
@Tag(name = "内部使用控制层",description = "进行公司内部用户信息使用管理、增删改等相关操作")
|
||||
public class InsideCustomerMessageController {
|
||||
|
||||
/**
|
||||
* 内部使用业务层
|
||||
*/
|
||||
@Autowired
|
||||
private InsideCustomerMessageService insideCustomerMessageService;
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "新增客户信息",description = "客户信息的添加操作")
|
||||
public Result addCustomerMessage(@Validated @RequestBody CustomerAddReq customerAddReq){
|
||||
insideCustomerMessageService.add(customerAddReq);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改客户信息
|
||||
* @param id
|
||||
* @param customerUpdReq
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "客户信息修改", description = "通过ID修改客户信息")
|
||||
public Result<String> update(
|
||||
@Schema(title = "客户ID", type = "Integer", defaultValue = "1", description = "修改客户信息需要依据的唯一条件")
|
||||
@PathVariable("id") Integer id,
|
||||
@RequestBody @Validated CustomerUpdReq customerUpdReq) {
|
||||
insideCustomerMessageService.updateBy(customerUpdReq);
|
||||
return Result.success(null, "操作成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.muyu.cloud.market.controller;
|
||||
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
import com.muyu.cloud.market.service.FindCustomerMeaasgeService;
|
||||
import com.muyu.cloud.market.service.InsideUseInterfaceService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.controller
|
||||
* @Project:cloud-market
|
||||
* @name:InsideUseInterfaceController
|
||||
* @Date:2024/8/20 20:42
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("InsideUse")
|
||||
@Tag(name = "内部使用控制层",description = "进行公司内部接口使用管理、增删改等相关操作")
|
||||
public class InsideUseInterfaceController {
|
||||
|
||||
/**
|
||||
* 内部使用业务层
|
||||
*/
|
||||
@Autowired
|
||||
private InsideUseInterfaceService insideUseInterfaceService;
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "新增客户信息",description = "客户信息的添加操作")
|
||||
public Result addCustomerMessage(@Validated @RequestBody CustomerAddReq customerAddReq){
|
||||
insideUseInterfaceService.add(customerAddReq);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,22 @@
|
|||
package com.muyu.cloud.market.controller;
|
||||
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.req.ProductListReq;
|
||||
import com.muyu.cloud.market.domin.resp.ProductListResp;
|
||||
import com.muyu.cloud.market.service.ProductApiService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.controller
|
||||
|
@ -18,6 +30,21 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@Tag(name = "产品接口控制层",description = "进行产品接口管理、查看等相关操作")
|
||||
public class ProductApiController {
|
||||
|
||||
@Autowired
|
||||
private ProductApiService productApiService;
|
||||
|
||||
/**
|
||||
* 查询全部商品接口
|
||||
* @param productListReq
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(path ="/list",method = RequestMethod.POST)
|
||||
@Operation(summary = "产品列表",description = "查询全部产品信息")
|
||||
public Result<List<ProductListResp>> selectList(@Validated @RequestBody ProductListReq productListReq){
|
||||
return Result.success(productApiService.selectList(productListReq));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.muyu.cloud.market.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.cloud.market.domin.Customer;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
|
@ -13,7 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
* @Date:2024/8/20 20:51
|
||||
*/
|
||||
@Mapper
|
||||
public interface InsideUseInterfaceMapper extends BaseMapper<Customer> {
|
||||
public interface InsideCustomerMessageMapper extends BaseMapper<Customer> {
|
||||
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.cloud.market.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.cloud.market.domin.Customer;
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
import com.muyu.cloud.market.domin.req.CustomerUpdReq;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
|
@ -11,11 +12,17 @@ import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
|||
* @name:InsideUseInterfaceService
|
||||
* @Date:2024/8/20 20:45
|
||||
*/
|
||||
public interface InsideUseInterfaceService extends IService<Customer> {
|
||||
public interface InsideCustomerMessageService extends IService<Customer> {
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
*
|
||||
*/
|
||||
void add(CustomerAddReq customerAddReq);
|
||||
|
||||
/**
|
||||
* 修改客户信息
|
||||
* @param customerUpdReq
|
||||
*/
|
||||
void updateBy(CustomerUpdReq customerUpdReq);
|
||||
}
|
|
@ -2,6 +2,10 @@ package com.muyu.cloud.market.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.req.ProductListReq;
|
||||
import com.muyu.cloud.market.domin.resp.ProductListResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
|
@ -11,4 +15,11 @@ import com.muyu.cloud.market.domin.Product;
|
|||
* @Date:2024/8/20 15:01
|
||||
*/
|
||||
public interface ProductApiService extends IService<Product> {
|
||||
|
||||
/**
|
||||
* 查询全部商品接口
|
||||
* @param productListReq
|
||||
* @return
|
||||
*/
|
||||
List<ProductListResp> selectList(ProductListReq productListReq);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@ package com.muyu.cloud.market.service.impl;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.market.domin.Customer;
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
import com.muyu.cloud.market.mapper.InsideUseInterfaceMapper;
|
||||
import com.muyu.cloud.market.service.InsideUseInterfaceService;
|
||||
import com.muyu.cloud.market.domin.req.CustomerUpdReq;
|
||||
import com.muyu.cloud.market.mapper.InsideCustomerMessageMapper;
|
||||
import com.muyu.cloud.market.service.InsideCustomerMessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -20,13 +21,13 @@ import java.util.Date;
|
|||
* @Date:2024/8/20 20:45
|
||||
*/
|
||||
@Service
|
||||
public class InsideUseInterfaceServiceImpl extends ServiceImpl<InsideUseInterfaceMapper, Customer> implements InsideUseInterfaceService {
|
||||
public class InsideCustomerMessageServiceImpl extends ServiceImpl<InsideCustomerMessageMapper, Customer> implements InsideCustomerMessageService {
|
||||
|
||||
/**
|
||||
* 内部使用持久层
|
||||
*/
|
||||
@Autowired
|
||||
private InsideUseInterfaceMapper insideUseInterfaceMapper;
|
||||
private InsideCustomerMessageMapper insideCustomerMessageMapper;
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
|
@ -56,6 +57,39 @@ public class InsideUseInterfaceServiceImpl extends ServiceImpl<InsideUseInterfac
|
|||
customer.setAddress(customerAddReq.getAddress());
|
||||
customer.setCredit(customer.getCredit());
|
||||
customer.setEmail(customer.getEmail());
|
||||
insideUseInterfaceMapper.insert(customer);
|
||||
insideCustomerMessageMapper.insert(customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客户信息
|
||||
* @param customerUpdReq
|
||||
*/
|
||||
@Override
|
||||
public void updateBy(CustomerUpdReq customerUpdReq) {
|
||||
Customer customer = new Customer();
|
||||
//从身份证中截取出出生日期
|
||||
if (customerUpdReq.getIdCard().length()!=18){
|
||||
throw new RuntimeException();
|
||||
}
|
||||
String birthday = customerUpdReq.getIdCard().substring(6, 14);
|
||||
String birthday1=birthday.substring(0, 4) + '-' + birthday.substring(4, 6) + '-' + birthday.substring(6);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
//如果转化过程中出现异常,需要捕捉ParseException并进行处理
|
||||
try {
|
||||
Date birthday2 = simpleDateFormat.parse(birthday1);
|
||||
customer.setBirthday(birthday2);
|
||||
}catch (ParseException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
customer.setId(customerUpdReq.getId());
|
||||
customer.setName(customerUpdReq.getName());
|
||||
customer.setGender(customerUpdReq.getGender());
|
||||
customer.setIdCard(customerUpdReq.getIdCard());
|
||||
customer.setTel(customerUpdReq.getTel());
|
||||
customer.setAddress(customerUpdReq.getAddress());
|
||||
customer.setCredit(customerUpdReq.getCredit());
|
||||
customer.setEmail(customerUpdReq.getEmail());
|
||||
insideCustomerMessageMapper.updateById(customer);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,11 +1,17 @@
|
|||
package com.muyu.cloud.market.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.req.ProductListReq;
|
||||
import com.muyu.cloud.market.domin.resp.ProductListResp;
|
||||
import com.muyu.cloud.market.mapper.ProductApiMapper;
|
||||
import com.muyu.cloud.market.service.ProductApiService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.service.impl
|
||||
|
@ -15,4 +21,23 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class ProductApiServiceImpl extends ServiceImpl<ProductApiMapper, Product> implements ProductApiService {
|
||||
|
||||
/**
|
||||
* 查询全部商品接口
|
||||
* @param productListReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ProductListResp> selectList(ProductListReq productListReq) {
|
||||
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotEmpty(productListReq.getProductName()),
|
||||
Product::getProductName,productListReq.getProductName());
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(productListReq.getStatus()),
|
||||
Product::getProductState,productListReq.getStatus());
|
||||
List<Product> productList = this.list(queryWrapper);
|
||||
return productList.stream()
|
||||
.map(product -> ProductListResp.productListRespbuild(product))
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue