master
parent
969ac09b43
commit
48e40912c7
|
@ -22,4 +22,6 @@ public class Products {
|
|||
private Double Price;
|
||||
|
||||
private Double costPrice;
|
||||
|
||||
private String productPath;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/4/15 上午11:27
|
||||
*/
|
||||
@Data
|
||||
public class ProductsRequest {
|
||||
|
||||
private String productName;
|
||||
|
||||
private Integer pageSize=5;
|
||||
|
||||
private Integer pageNum=1;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.xxxxxx;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/4/15 上午11:58
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.bwie.xxxxxx.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bwie.common.domain.pojo.Products;
|
||||
import com.bwie.common.domain.request.ProductsRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.xxxxxx.service.ProductService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/4/15 上午11:42
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pur")
|
||||
@Log4j2
|
||||
public class ProductController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@PostMapping("/findList")
|
||||
public Result<PageResult<Products>>findList(@RequestBody ProductsRequest productsRequest){
|
||||
log.info("功能描述: xx,请求URI:{},请求方式: {},请求参数: {}",
|
||||
request.getRequestURI(),request.getMethod(),productsRequest);
|
||||
Result<PageResult<Products>>result=productService.findList(productsRequest);
|
||||
log.info("功能描述: xx,请求URI:{},请求方式: {},响应结果: {}",
|
||||
request.getRequestURI(),request.getMethod(), JSON.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.xxxxxx.mapper;
|
||||
|
||||
import com.bwie.common.domain.pojo.Products;
|
||||
import com.bwie.common.domain.request.ProductsRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/4/15 上午11:42
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductMapper {
|
||||
|
||||
List<Products> findList(ProductsRequest productsRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.xxxxxx.service;
|
||||
|
||||
import com.bwie.common.domain.pojo.Products;
|
||||
import com.bwie.common.domain.request.ProductsRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/4/15 上午11:42
|
||||
*/
|
||||
public interface ProductService {
|
||||
|
||||
Result<PageResult<Products>> findList(ProductsRequest productsRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.bwie.xxxxxx.service.impl;
|
||||
|
||||
import com.bwie.common.domain.pojo.Products;
|
||||
import com.bwie.common.domain.request.ProductsRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.xxxxxx.mapper.ProductMapper;
|
||||
import com.bwie.xxxxxx.service.ProductService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/4/15 上午11:43
|
||||
*/
|
||||
@Service
|
||||
public class ProductServiceImpl implements ProductService {
|
||||
|
||||
@Autowired
|
||||
private ProductMapper productMapper;
|
||||
@Override
|
||||
public Result<PageResult<Products>> findList(ProductsRequest productsRequest) {
|
||||
PageHelper.startPage(productsRequest.getPageNum(), productsRequest.getPageSize());
|
||||
List<Products>list=productMapper.findList(productsRequest);
|
||||
PageInfo<Products> pageInfo=new PageInfo<>(list);
|
||||
return PageResult.toResult(pageInfo.getTotal(),list);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.bwie.user.mapper.XXXMapper">
|
||||
<mapper namespace="com.bwie.xxxxxx.mapper.ProductMapper">
|
||||
|
||||
<select id="findList" resultType="com.bwie.common.domain.pojo.Products">
|
||||
SELECT
|
||||
p.product_path AS product_path,
|
||||
p.product_name AS product_name,
|
||||
p.product_id AS product_bh,
|
||||
p.cost_price AS cost_price ,
|
||||
(p.cost_price + (p.cost_price * 0.1)) AS price,
|
||||
p.product_type AS product_type ,
|
||||
o.order_status AS order_status ,
|
||||
c.coupon_id AS issue_coupon
|
||||
FROM
|
||||
orders o
|
||||
JOIN
|
||||
products p ON o.product_id = p.product_id
|
||||
LEFT JOIN
|
||||
coupons c ON o.coupon_id = c.coupon_id
|
||||
ORDER BY
|
||||
o.order_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue