From 794a9323406da59b4ffd0eae687176dc6c58a08e Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 27 Sep 2021 10:06:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=AB=AF=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=86=E8=AF=8DControlle?= =?UTF-8?q?r=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98=E3=80=82=E9=99=90?= =?UTF-8?q?=E6=97=B6=E6=8A=A2=E8=B4=AD=E6=B4=BB=E5=8A=A8=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=B6=E5=A2=9E=E5=8A=A0=E6=A3=80=E6=9F=A5=E7=A7=92?= =?UTF-8?q?=E6=9D=80=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/SeckillServiceImpl.java | 2 + .../other/CustomWordsController.java | 51 ++++++++++++-- .../other/CustomWordsManagerController.java | 66 ------------------- 3 files changed, 46 insertions(+), 73 deletions(-) delete mode 100644 manager-api/src/main/java/cn/lili/controller/other/CustomWordsManagerController.java diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index 21d04846..c98962ae 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -192,6 +192,8 @@ public class SeckillServiceImpl extends ServiceImpl impl seckillVO.setEndTime(cn.hutool.core.date.DateUtil.endOfDay(seckillVO.getStartTime())); } PromotionTools.checkPromotionTime(seckillVO.getStartTime().getTime(), seckillVO.getEndTime().getTime()); + //检查秒杀活动参数 + this.checkSeckillParam(seckillVO); //更新到MYSQL中 boolean result = this.updateById(seckillVO); //保存到MONGO中 diff --git a/manager-api/src/main/java/cn/lili/controller/other/CustomWordsController.java b/manager-api/src/main/java/cn/lili/controller/other/CustomWordsController.java index 7c439a15..c65ac807 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/CustomWordsController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/CustomWordsController.java @@ -1,19 +1,27 @@ package cn.lili.controller.other; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; +import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; -import cn.lili.common.utils.StringUtils; +import cn.lili.common.vo.PageVO; +import cn.lili.common.vo.ResultMessage; import cn.lili.modules.permission.SettingKeys; +import cn.lili.modules.search.entity.dos.CustomWords; +import cn.lili.modules.search.entity.vo.CustomWordsVO; import cn.lili.modules.search.service.CustomWordsService; import cn.lili.modules.system.entity.dos.Setting; import cn.lili.modules.system.service.SettingService; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; import java.nio.charset.StandardCharsets; /** @@ -41,11 +49,11 @@ public class CustomWordsController { @GetMapping public String getCustomWords(String secretKey) { - if (StringUtils.isEmpty(secretKey)) { + if (CharSequenceUtil.isEmpty(secretKey)) { return ""; } Setting setting = settingService.get(SettingKeys.ES_SIGN.name()); - if (setting == null || StringUtils.isEmpty(setting.getSettingValue())) { + if (setting == null || CharSequenceUtil.isEmpty(setting.getSettingValue())) { return ""; } @@ -57,9 +65,38 @@ public class CustomWordsController { try { return new String(res.getBytes(), StandardCharsets.UTF_8); } catch (Exception e) { - log.error("获取分词错误",e); + log.error("获取分词错误", e); } return ""; } + @ApiOperation(value = "添加自定义分词") + @PostMapping + public ResultMessage addCustomWords(@Valid CustomWordsVO customWords) { + customWordsService.addCustomWords(customWords); + return ResultUtil.data(customWords); + } + + @ApiOperation(value = "修改自定义分词") + @PutMapping + public ResultMessage updateCustomWords(@Valid CustomWordsVO customWords) { + customWordsService.updateCustomWords(customWords); + return ResultUtil.data(customWords); + } + + @ApiOperation(value = "删除自定义分词") + @ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") + @DeleteMapping("/{id}") + public ResultMessage deleteCustomWords(@NotNull @PathVariable String id) { + customWordsService.deleteCustomWords(id); + return ResultUtil.success(); + } + + @ApiOperation(value = "分页获取自定义分词") + @ApiImplicitParam(name = "words", value = "分词", required = true, dataType = "String", paramType = "query") + @GetMapping("/page") + public ResultMessage> getCustomWords(@RequestParam String words, PageVO pageVo) { + return ResultUtil.data(customWordsService.getCustomWordsByPage(words, pageVo)); + } + } diff --git a/manager-api/src/main/java/cn/lili/controller/other/CustomWordsManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/CustomWordsManagerController.java deleted file mode 100644 index 543cbb35..00000000 --- a/manager-api/src/main/java/cn/lili/controller/other/CustomWordsManagerController.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.lili.controller.other; - -import cn.lili.common.enums.ResultUtil; -import cn.lili.common.vo.PageVO; -import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.search.entity.dos.CustomWords; -import cn.lili.modules.search.entity.vo.CustomWordsVO; -import cn.lili.modules.search.service.CustomWordsService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -/** - * 管理端,自定义分词接口 - * - * @author paulG - * @since 2020/10/16 - **/ -@RestController -@Api(tags = "管理端,自定义分词接口") -@RequestMapping("/manager/manager/custom-words") -public class CustomWordsManagerController { - - /** - * 分词 - */ - @Autowired - private CustomWordsService customWordsService; - - @ApiOperation(value = "添加自定义分词") - @PostMapping - public ResultMessage addCustomWords(@Valid CustomWordsVO customWords) { - customWordsService.addCustomWords(customWords); - return ResultUtil.data(customWords); - } - - @ApiOperation(value = "修改自定义分词") - @PutMapping - public ResultMessage updateCustomWords(@Valid CustomWordsVO customWords) { - customWordsService.updateCustomWords(customWords); - return ResultUtil.data(customWords); - } - - @ApiOperation(value = "删除自定义分词") - @ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") - @DeleteMapping("/{id}") - public ResultMessage deleteCustomWords(@NotNull @PathVariable String id) { - customWordsService.deleteCustomWords(id); - return ResultUtil.success(); - } - - @ApiOperation(value = "分页获取自定义分词") - @ApiImplicitParam(name = "words", value = "分词", required = true, dataType = "String", paramType = "query") - @GetMapping - public ResultMessage> getCustomWords(@RequestParam String words, PageVO pageVo) { - return ResultUtil.data(customWordsService.getCustomWordsByPage(words, pageVo)); - } - - -} From 0440ecea23bf17079de639b36160108f9ad03715 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 30 Sep 2021 14:48:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96logback=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/application.yml | 13 ++++-- .../src/main/resources/logback-spring.xml | 4 +- buyer-api/src/main/resources/logback.xml | 40 ------------------ common-api/src/main/resources/application.yml | 13 ++++-- .../{logback.xml => logback-spring.xml} | 4 +- config/application.yml | 13 +++--- consumer/src/main/resources/application.yml | 13 ++++-- .../src/main/resources/logback-spring.xml | 4 +- .../src/main/resources/application.yml | 13 ++++-- .../src/main/resources/logback-spring.xml | 6 +-- seller-api/src/main/resources/application.yml | 13 ++++-- .../src/main/resources/logback-spring.xml | 41 +++++++++++++++++++ 12 files changed, 103 insertions(+), 74 deletions(-) rename seller-api/src/main/resources/logback.xml => buyer-api/src/main/resources/logback-spring.xml (89%) delete mode 100644 buyer-api/src/main/resources/logback.xml rename common-api/src/main/resources/{logback.xml => logback-spring.xml} (89%) rename manager-api/src/main/resources/manager.xml => consumer/src/main/resources/logback-spring.xml (89%) rename consumer/src/main/resources/logback.xml => manager-api/src/main/resources/logback-spring.xml (86%) create mode 100644 seller-api/src/main/resources/logback-spring.xml diff --git a/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index dd62a1a8..b33e38c7 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -22,6 +22,8 @@ management: exposure: include: '*' spring: + application: + name: buyer-api # 要在其中注册的Spring Boot Admin Server的URL。 boot: admin: @@ -182,6 +184,7 @@ mybatis-plus: # 日志 logging: + config: classpath:logback-spring.xml # 输出级别 level: cn.lili: debug @@ -191,10 +194,12 @@ logging: file: # 指定路径 path: lili-logs - # 最大保存天数 - max-history: 7 - # 每个文件最大大小 - max-size: 5MB + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB #加密参数 jasypt: encryptor: diff --git a/seller-api/src/main/resources/logback.xml b/buyer-api/src/main/resources/logback-spring.xml similarity index 89% rename from seller-api/src/main/resources/logback.xml rename to buyer-api/src/main/resources/logback-spring.xml index ce08fb6f..8e2f8cac 100644 --- a/seller-api/src/main/resources/logback.xml +++ b/buyer-api/src/main/resources/logback-spring.xml @@ -4,9 +4,9 @@ - + - + ${APP_NAME} diff --git a/buyer-api/src/main/resources/logback.xml b/buyer-api/src/main/resources/logback.xml deleted file mode 100644 index 5837ff17..00000000 --- a/buyer-api/src/main/resources/logback.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - ${APP_NAME} - - - - ${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log - 30 - - - ${FILE_LOG_PATTERN} - - - - - - 127.0.0.1:4560 - - - - UTC - - - - {"appName":"${APP_NAME}"} - - - - - - - - \ No newline at end of file diff --git a/common-api/src/main/resources/application.yml b/common-api/src/main/resources/application.yml index 8f456df0..1157b9bf 100644 --- a/common-api/src/main/resources/application.yml +++ b/common-api/src/main/resources/application.yml @@ -22,6 +22,8 @@ management: exposure: include: '*' spring: + application: + name: common-api # 要在其中注册的Spring Boot Admin Server的URL。 boot: admin: @@ -181,6 +183,7 @@ mybatis-plus: # 日志 logging: + config: classpath:logback-spring.xml # 输出级别 level: cn.lili: info @@ -190,10 +193,12 @@ logging: file: # 指定路径 path: lili-logs - # 最大保存天数 - max-history: 7 - # 每个文件最大大小 - max-size: 5MB + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB #加密参数 jasypt: encryptor: diff --git a/common-api/src/main/resources/logback.xml b/common-api/src/main/resources/logback-spring.xml similarity index 89% rename from common-api/src/main/resources/logback.xml rename to common-api/src/main/resources/logback-spring.xml index 46dec7c7..8e2f8cac 100644 --- a/common-api/src/main/resources/logback.xml +++ b/common-api/src/main/resources/logback-spring.xml @@ -4,9 +4,9 @@ - + - + ${APP_NAME} diff --git a/config/application.yml b/config/application.yml index 8c576e32..e3e81029 100644 --- a/config/application.yml +++ b/config/application.yml @@ -182,6 +182,7 @@ mybatis-plus: # 日志 logging: + config: classpath:logback-spring.xml # 输出级别 level: cn.lili: info @@ -190,11 +191,13 @@ logging: # org.springframework.data.mongodb.core: debug file: # 指定路径 - path: lili-logs - # 最大保存天数 - max-history: 7 - # 每个文件最大大小 - max-size: 5MB + path: logs + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB #加密参数 jasypt: encryptor: diff --git a/consumer/src/main/resources/application.yml b/consumer/src/main/resources/application.yml index ed3853a6..1ec5a786 100644 --- a/consumer/src/main/resources/application.yml +++ b/consumer/src/main/resources/application.yml @@ -25,6 +25,8 @@ management: exposure: include: '*' spring: + application: + name: consumer # 要在其中注册的Spring Boot Admin Server的URL。 boot: admin: @@ -184,6 +186,7 @@ mybatis-plus: # 日志 logging: + config: classpath:logback-spring.xml # 输出级别 level: cn.lili: info @@ -193,10 +196,12 @@ logging: file: # 指定路径 path: lili-logs - # 最大保存天数 - max-history: 7 - # 每个文件最大大小 - max-size: 5MB + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB #加密参数 jasypt: encryptor: diff --git a/manager-api/src/main/resources/manager.xml b/consumer/src/main/resources/logback-spring.xml similarity index 89% rename from manager-api/src/main/resources/manager.xml rename to consumer/src/main/resources/logback-spring.xml index 46dec7c7..8e2f8cac 100644 --- a/manager-api/src/main/resources/manager.xml +++ b/consumer/src/main/resources/logback-spring.xml @@ -4,9 +4,9 @@ - + - + ${APP_NAME} diff --git a/manager-api/src/main/resources/application.yml b/manager-api/src/main/resources/application.yml index 6ac2b29c..8db62326 100644 --- a/manager-api/src/main/resources/application.yml +++ b/manager-api/src/main/resources/application.yml @@ -22,6 +22,8 @@ management: exposure: include: '*' spring: + application: + name: manager-api # 要在其中注册的Spring Boot Admin Server的URL。 boot: admin: @@ -166,6 +168,7 @@ mybatis-plus: # 日志 logging: + config: classpath:logback-spring.xml # 输出级别 level: cn.lili: info @@ -175,10 +178,12 @@ logging: file: # 指定路径 path: lili-logs - # 最大保存天数 - max-history: 7 - # 每个文件最大大小 - max-size: 5MB + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB #加密参数 jasypt: encryptor: diff --git a/consumer/src/main/resources/logback.xml b/manager-api/src/main/resources/logback-spring.xml similarity index 86% rename from consumer/src/main/resources/logback.xml rename to manager-api/src/main/resources/logback-spring.xml index 45ee2e13..8e2f8cac 100644 --- a/consumer/src/main/resources/logback.xml +++ b/manager-api/src/main/resources/logback-spring.xml @@ -4,9 +4,9 @@ - + - + ${APP_NAME} @@ -22,7 +22,7 @@ - 192.168.0.116:4560 + 127.0.0.1:4560 diff --git a/seller-api/src/main/resources/application.yml b/seller-api/src/main/resources/application.yml index b4980cde..2eb3eebe 100644 --- a/seller-api/src/main/resources/application.yml +++ b/seller-api/src/main/resources/application.yml @@ -22,6 +22,8 @@ management: exposure: include: '*' spring: + application: + name: seller-api # 要在其中注册的Spring Boot Admin Server的URL。 boot: admin: @@ -164,6 +166,7 @@ mybatis-plus: # 日志 logging: + config: classpath:logback-spring.xml # 输出级别 level: cn.lili: info @@ -173,10 +176,12 @@ logging: file: # 指定路径 path: lili-logs - # 最大保存天数 - max-history: 7 - # 每个文件最大大小 - max-size: 5MB + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB #加密参数 jasypt: encryptor: diff --git a/seller-api/src/main/resources/logback-spring.xml b/seller-api/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..8e2f8cac --- /dev/null +++ b/seller-api/src/main/resources/logback-spring.xml @@ -0,0 +1,41 @@ + + + + + + + + + + ${APP_NAME} + + + + ${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log + 30 + + + ${FILE_LOG_PATTERN} + + + + + + + 127.0.0.1:4560 + + + + UTC + + + + {"appName":"${APP_NAME}"} + + + + + + + + \ No newline at end of file