From 872525cf37b5f5befd2ffc88f6d9177abd9ede1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LI-CCONG=5C=E6=9D=8E=E8=81=AA=E8=81=AA?= <1441652193@qq.com> Date: Thu, 28 Mar 2024 12:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E7=82=B9=E3=80=81=E5=88=B0=E7=AB=99?= =?UTF-8?q?=E5=9B=9E=E6=94=B6=E8=AE=A2=E5=8D=95=E4=B8=9A=E5=8A=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BDbug=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8Dv4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../java/cc/yunxi/common/genCodeMain.java | 4 +- .../controller/RecycleOrderController.java | 18 ++++++ .../cc/yunxi/controller/TestController.java | 62 ++++++++++++++++++- .../service/IRecycleOrderProductService.java | 8 ++- .../impl/RecycleOrderProductServiceImpl.java | 13 +++- .../java/cc/yunxi/NxhsApplicationTest.java | 37 ++++++----- 7 files changed, 122 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 86b0b89..f173b81 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ target/ !**/src/test/**/target/ logs upload +**/src/main/**/test/ ### STS ### .apt_generated diff --git a/nxhs-common/src/main/java/cc/yunxi/common/genCodeMain.java b/nxhs-common/src/main/java/cc/yunxi/common/genCodeMain.java index ea6dab5..deeb4b9 100644 --- a/nxhs-common/src/main/java/cc/yunxi/common/genCodeMain.java +++ b/nxhs-common/src/main/java/cc/yunxi/common/genCodeMain.java @@ -41,7 +41,7 @@ public class genCodeMain { }) //4、策略配置 .strategyConfig(builder -> { - builder.addInclude("nx_enterprise_recycle_station") // 设置需要生成的数据表名 + builder.addInclude("nx_housing_estate") // 设置需要生成的数据表名 .addTablePrefix("nx") // 设置过滤表前缀 //4.1、Mapper策略配置 .mapperBuilder() @@ -52,7 +52,7 @@ public class genCodeMain { //4.2、service 策略配置 .serviceBuilder() - .formatServiceFileName("%sService") //格式化 service 接口文件名称,%s进行匹配表名,如 UserService + .formatServiceFileName("I%sService") //格式化 service 接口文件名称,%s进行匹配表名,如 UserService .formatServiceImplFileName("%sServiceImpl") //格式化 service 实现类文件名称,%s进行匹配表名,如 UserServiceImpl //4.3、实体类策略配置 diff --git a/nxhs-service/src/main/java/cc/yunxi/controller/RecycleOrderController.java b/nxhs-service/src/main/java/cc/yunxi/controller/RecycleOrderController.java index 1f5e133..a5d07b5 100644 --- a/nxhs-service/src/main/java/cc/yunxi/controller/RecycleOrderController.java +++ b/nxhs-service/src/main/java/cc/yunxi/controller/RecycleOrderController.java @@ -132,6 +132,24 @@ public class RecycleOrderController { return CommonResult.success(CollUtils.getFirst(recycleOrderRespVO)); } + @ApiOperation("回收订单明细详情") + @GetMapping("/product-info") + public CommonResult> OrderProductList(@RequestParam("orderId") String orderId) { + List orderProducts = recycleOrderProductService.getOrderProductsByOrderId(orderId); + List detailResponseVOList = BeanUtils.copyList(orderProducts, RecycleOrderDetailResponseVO.class); + Set productIds = detailResponseVOList.stream().map(RecycleOrderDetailResponseVO::getProductId).collect(Collectors.toSet()); + List productList = priceProductService.getProductListByIds(productIds); + if (CollUtils.isNotEmpty(productList)) { + Map productMap = productList.stream().collect(Collectors.toMap(Product::getId, p -> p, (k1, k2) -> k1)); + for (RecycleOrderDetailResponseVO detailVO : detailResponseVOList) { + Product product = productMap.get(detailVO.getProductId()); + detailVO.setProduct(BeanUtils.copyBean(product, ProductSimpleVO.class)); + } + } + // 是否展示最新价格? todo + return CommonResult.success(detailResponseVOList); + } + @ApiOperation("回收订单更新") @PostMapping("/update") diff --git a/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java b/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java index 13a9dad..5111b66 100644 --- a/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java +++ b/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java @@ -3,13 +3,25 @@ package cc.yunxi.controller; import cc.yunxi.common.domain.CommonResult; import cc.yunxi.common.exception.BadRequestException; import cc.yunxi.common.exception.BizIllegalException; +import cc.yunxi.config.props.JwtProperties; import cc.yunxi.config.props.WxPayV3Properties; +import cc.yunxi.domain.dto.UserDTO; import cc.yunxi.domain.query.TestQuery; import cc.yunxi.enums.UserTypeEnum; import cc.yunxi.service.ITestService; +import cc.yunxi.test.AppConfig; +import cc.yunxi.test.dal.Animal; +import cc.yunxi.utils.JwtTool; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.lang.Console; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; +import cn.hutool.http.Header; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.hutool.log.Log; import com.ijpay.core.IJPayHttpResponse; @@ -26,14 +38,16 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Async; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; import java.security.cert.X509Certificate; import java.util.Collections; -import java.util.concurrent.ExecutionException; +import java.util.HashMap; @Api(tags = "测试接口") @RestController @@ -47,9 +61,19 @@ public class TestController { @Resource private WxPayV3Properties wxPayV3Properties; + @Resource + private JwtTool jwtTool; + + @Autowired + @Lazy + private JwtProperties jwtProperties; + @ApiOperation("测试接口成功") @GetMapping("/test01") public CommonResult success() { + Animal animal = SpringUtil.getBean("animalObj", Animal.class); + AppConfig appConfig = SpringUtil.getBean("appConfig", AppConfig.class); + log.info("animal bean: {}, appConfig bean: {}", animal, appConfig); return CommonResult.success("ok"); } @@ -70,6 +94,26 @@ public class TestController { return CommonResult.success("ok"); } + @ApiOperation("测试token生成") + @PostMapping("/test06") + public CommonResult createToken() { + UserDTO userDTO = new UserDTO(); + userDTO.setUsername("admin"); + userDTO.setId("1"); + String token = jwtTool.createToken(userDTO); + log.info("token ttl = {}", jwtProperties.getTokenTTL().toMillis()); + return CommonResult.success(token); + } + + + @ApiOperation("测试解析token") + @PostMapping("/test07") + public CommonResult parseToken(@RequestParam("authorization") String token) { + UserDTO userDTO = jwtTool.parseToken(token); + return CommonResult.success(userDTO); + } + + @ApiOperation("测试枚举转换") @PostMapping("/test04") public CommonResult enumConvert(@RequestBody TestQuery testQuery) { @@ -94,6 +138,7 @@ public class TestController { return CommonResult.success("数据处理完成"); } + @ApiOperation(value = "测试支付", hidden = true) @GetMapping("/tQ7lA2mG9f") public CommonResult wxCash(@RequestParam("openid") String openid, @RequestParam("amount") Integer amount) throws Exception { @@ -147,4 +192,17 @@ public class TestController { return serialNo; } + + @ApiOperation(value = "测试JSON接口请求") + @GetMapping("/test08") + public CommonResult test08() { + JSONObject jsonObject = new JSONObject(); + jsonObject.set("amount", "222").set("merchantId", "540429689097824901"); + String json = jsonObject.toJSONString(1); + String result = HttpRequest.post("http://localhost:8808/api/index/recharge-balance") + .header("authorization", "8bd2aa89033ead51c505e44994e42189") + .body(json) + .execute().body(); + return CommonResult.success(result); + } } diff --git a/nxhs-service/src/main/java/cc/yunxi/service/IRecycleOrderProductService.java b/nxhs-service/src/main/java/cc/yunxi/service/IRecycleOrderProductService.java index 744296b..83f4376 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/IRecycleOrderProductService.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/IRecycleOrderProductService.java @@ -26,6 +26,13 @@ public interface IRecycleOrderProductService extends IService + */ + List getOrderProductsByOrderId(String orderId); + /** * 订单下废品明细 @@ -34,7 +41,6 @@ public interface IRecycleOrderProductService extends IService getOrderProductsByOrderIds(List orderIds); - /** * 订单废品批量添加 * @param diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleOrderProductServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleOrderProductServiceImpl.java index 7a789f9..43872dc 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleOrderProductServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleOrderProductServiceImpl.java @@ -1,6 +1,7 @@ package cc.yunxi.service.impl; import cc.yunxi.common.domain.LambdaQueryWrapperX; +import cc.yunxi.common.utils.CollUtils; import cc.yunxi.domain.po.PriceProduct; import cc.yunxi.domain.po.RecycleOrderProduct; import cc.yunxi.mapper.RecycleOrderProductMapper; @@ -32,10 +33,20 @@ public class RecycleOrderProductServiceImpl extends ServiceImpl getOrderProductsByOrderId(String orderId) { + LambdaQueryWrapperX wrapper = new LambdaQueryWrapperX<>(); + wrapper.eq(RecycleOrderProduct::getRecycleOrderId, orderId); + return this.list(wrapper); + } + @Override public List getOrderProductsByOrderIds(List orderIds) { LambdaQueryWrapperX wrapper = new LambdaQueryWrapperX<>(); - wrapper.inIfPresent(RecycleOrderProduct::getRecycleOrderId, orderIds); + if (CollUtils.isEmpty(orderIds)) { + return CollUtils.emptyList(); + } + wrapper.in(RecycleOrderProduct::getRecycleOrderId, orderIds); return this.list(wrapper); } diff --git a/nxhs-service/src/test/java/cc/yunxi/NxhsApplicationTest.java b/nxhs-service/src/test/java/cc/yunxi/NxhsApplicationTest.java index f998549..d657a2f 100644 --- a/nxhs-service/src/test/java/cc/yunxi/NxhsApplicationTest.java +++ b/nxhs-service/src/test/java/cc/yunxi/NxhsApplicationTest.java @@ -1,20 +1,21 @@ package cc.yunxi; -import cc.yunxi.common.utils.LambdaUtil; -import cc.yunxi.common.domain.function.SFunction; import cc.yunxi.domain.dto.UserDTO; -import cc.yunxi.domain.po.Recycler; -import cc.yunxi.enums.UserTypeEnum; +import cc.yunxi.domain.vo.recycleorder.shorder.SHRecycleOrderRespVO; +import cc.yunxi.service.IRecyclerService; import cc.yunxi.service.ITestService; import cc.yunxi.utils.JwtTool; -import cn.hutool.core.util.StrUtil; -import cn.hutool.crypto.digest.DigestUtil; +import cn.hutool.core.lang.Filter; +import cn.hutool.core.util.ReflectUtil; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigDecimal; @SpringBootTest public class NxhsApplicationTest { @@ -22,6 +23,9 @@ public class NxhsApplicationTest { @Resource ITestService testService; + @Resource + IRecyclerService recyclerService; + @Resource JwtTool jwtTool; @@ -50,15 +54,18 @@ public class NxhsApplicationTest { @Test void test03() { - SFunction recyclerSFunction = Recycler::getGoodTotal; - String fieldName = LambdaUtil.getFieldName(recyclerSFunction); - System.out.println(fieldName); +// SFunction recyclerSFunction = Recycler::getGoodTotal; +// String fieldName = LambdaUtil.getFieldName(recyclerSFunction); +// System.out.println(fieldName); + recyclerService.totalTick("533242995646951684", 1880d, new BigDecimal("5000")); } - public static void main(String[] args) { -// System.out.println(DigestUtil.sha256Hex("123456")); -// System.out.println(DigestUtil.sha1Hex("123456")); -// System.out.println(DigestUtil.md5Hex("123456")); + public static void main(String[] args) throws NoSuchMethodException { +// Filter fieldFilter = field -> field.getName().startsWith("name") || field.getType().equals(String.class); +// Field[] fields = ReflectUtil.getFields(SHRecycleOrderRespVO.class, fieldFilter); +// System.out.println(fields.length); + BigDecimal number = new BigDecimal("123.00"); + System.out.println(number.stripTrailingZeros().scale() <= 0); } }