From 6a55491e450eb53e6d1c07d208c8fef06cff1025 Mon Sep 17 00:00:00 2001 From: liuyibo <14460729+liuyibo12345@user.noreply.gitee.com> Date: Sat, 21 Sep 2024 11:59:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat():=E8=BD=A6=E8=BE=86=E8=AD=A6=E5=91=8A?= =?UTF-8?q?CRUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloud-auth/src/main/resources/bootstrap.yml | 2 +- .../src/main/resources/bootstrap.yml | 2 +- .../src/main/resources/bootstrap.yml | 2 +- .../src/main/resources/bootstrap.yml | 2 +- .../src/main/resources/bootstrap.yml | 12 +- .../src/main/resources/bootstrap.yml | 2 +- cloud-warn/pom.xml | 96 +++++++++ .../com/muyu/warn/CloudWarnApplication.java | 21 ++ .../warn/controller/WarnLogsController.java | 110 ++++++++++ .../warn/controller/WarnRuleController.java | 110 ++++++++++ .../controller/WarnStrategyController.java | 110 ++++++++++ .../java/com/muyu/warn/domain/WarnLogs.java | 91 +++++++++ .../java/com/muyu/warn/domain/WarnRule.java | 77 +++++++ .../com/muyu/warn/domain/WarnStrategy.java | 57 ++++++ .../com/muyu/warn/mapper/WarnLogsMapper.java | 16 ++ .../com/muyu/warn/mapper/WarnRuleMapper.java | 16 ++ .../muyu/warn/mapper/WarnStrategyMapper.java | 16 ++ .../muyu/warn/service/IWarnLogsService.java | 37 ++++ .../muyu/warn/service/IWarnRuleService.java | 37 ++++ .../warn/service/IWarnStrategyService.java | 37 ++++ .../service/impl/WarnLogsServiceImpl.java | 92 +++++++++ .../service/impl/WarnRuleServiceImpl.java | 86 ++++++++ .../service/impl/WarnStrategyServiceImpl.java | 74 +++++++ cloud-warn/src/main/resources/banner.txt | 0 cloud-warn/src/main/resources/bootstrap.yml | 49 +++++ cloud-weixin-mp/pom.xml | 76 +++++++ .../src/main/java/com/muyu/SpringBoot.java | 17 ++ .../main/java/com/muyu/message/Article.java | 27 +++ .../java/com/muyu/message/NewMessage.java | 34 ++++ .../java/com/muyu/message/TextMessage.java | 51 +++++ .../main/java/com/muyu/token/AccessToken.java | 30 +++ .../main/java/com/muyu/util/OkHttpUtils.java | 36 ++++ .../main/java/com/muyu/util/TokenUtil.java | 41 ++++ .../main/java/com/muyu/util/WechatUtil.java | 39 ++++ .../com/muyu/wxController/WxController.java | 190 ++++++++++++++++++ .../src/main/resources/bootstrap.yml | 12 ++ pom.xml | 2 + 37 files changed, 1693 insertions(+), 16 deletions(-) create mode 100644 cloud-warn/pom.xml create mode 100644 cloud-warn/src/main/java/com/muyu/warn/CloudWarnApplication.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/controller/WarnLogsController.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/controller/WarnRuleController.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/controller/WarnStrategyController.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/WarnLogs.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/WarnRule.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/WarnStrategy.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/mapper/WarnLogsMapper.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/mapper/WarnRuleMapper.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/mapper/WarnStrategyMapper.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/IWarnLogsService.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/IWarnRuleService.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/IWarnStrategyService.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnLogsServiceImpl.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnRuleServiceImpl.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnStrategyServiceImpl.java create mode 100644 cloud-warn/src/main/resources/banner.txt create mode 100644 cloud-warn/src/main/resources/bootstrap.yml create mode 100644 cloud-weixin-mp/pom.xml create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/SpringBoot.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/message/Article.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/message/NewMessage.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/message/TextMessage.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/token/AccessToken.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/util/OkHttpUtils.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/util/TokenUtil.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/util/WechatUtil.java create mode 100644 cloud-weixin-mp/src/main/java/com/muyu/wxController/WxController.java create mode 100644 cloud-weixin-mp/src/main/resources/bootstrap.yml diff --git a/cloud-auth/src/main/resources/bootstrap.yml b/cloud-auth/src/main/resources/bootstrap.yml index 1eaec3e..f8ff18b 100644 --- a/cloud-auth/src/main/resources/bootstrap.yml +++ b/cloud-auth/src/main/resources/bootstrap.yml @@ -7,7 +7,7 @@ nacos: addr: 106.15.136.7:8848 user-name: nacos password: nacos - namespace: crj + namespace: lyb # Spring spring: application: diff --git a/cloud-gateway/src/main/resources/bootstrap.yml b/cloud-gateway/src/main/resources/bootstrap.yml index 5c23eb1..cf53ffc 100644 --- a/cloud-gateway/src/main/resources/bootstrap.yml +++ b/cloud-gateway/src/main/resources/bootstrap.yml @@ -7,7 +7,7 @@ nacos: addr: 106.15.136.7:8848 user-name: nacos password: nacos - namespace: crj + namespace: lyb # Spring spring: diff --git a/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml index ed3a86f..21cfa55 100644 --- a/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml @@ -7,7 +7,7 @@ nacos: addr: 106.15.136.7:8848 user-name: nacos password: nacos - namespace: crj + namespace: lyb # Spring spring: diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml index c2cac97..b2b68de 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml @@ -7,7 +7,7 @@ nacos: addr: 106.15.136.7:8848 user-name: nacos password: nacos - namespace: crj + namespace: lyb # Spring spring: diff --git a/cloud-modules/cloud-modules-system/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-system/src/main/resources/bootstrap.yml index 369161d..9ba95a5 100644 --- a/cloud-modules/cloud-modules-system/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-system/src/main/resources/bootstrap.yml @@ -7,15 +7,9 @@ nacos: addr: 106.15.136.7:8848 user-name: nacos password: nacos - namespace: crj + namespace: lyb spring: - amqp: - deserialization: - trust: - all: true - main: - allow-bean-definition-overriding: true application: # 应用名称 name: cloud-system @@ -50,10 +44,6 @@ spring: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} # 系统环境Config共享配置 - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - # xxl-job 配置文件 - - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - # rabbit 配置文件 - - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} logging: level: com.muyu.system.mapper: DEBUG diff --git a/cloud-visual/cloud-visual-monitor/src/main/resources/bootstrap.yml b/cloud-visual/cloud-visual-monitor/src/main/resources/bootstrap.yml index 6a9083d..a61db2e 100644 --- a/cloud-visual/cloud-visual-monitor/src/main/resources/bootstrap.yml +++ b/cloud-visual/cloud-visual-monitor/src/main/resources/bootstrap.yml @@ -7,7 +7,7 @@ nacos: addr: 106.15.136.7:8848 user-name: nacos password: nacos - namespace: crj + namespace: lyb # Spring spring: diff --git a/cloud-warn/pom.xml b/cloud-warn/pom.xml new file mode 100644 index 0000000..4b6edda --- /dev/null +++ b/cloud-warn/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + com.muyu + cloud-server + 3.6.3 + + + cloud-warn + + + 17 + 17 + UTF-8 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + com.mysql + mysql-connector-j + + + + + com.muyu + cloud-common-datasource + + + + + com.muyu + cloud-common-datascope + + + + + com.muyu + cloud-common-log + + + + + com.muyu + cloud-common-api-doc + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + diff --git a/cloud-warn/src/main/java/com/muyu/warn/CloudWarnApplication.java b/cloud-warn/src/main/java/com/muyu/warn/CloudWarnApplication.java new file mode 100644 index 0000000..c9a6d4c --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/CloudWarnApplication.java @@ -0,0 +1,21 @@ +package com.muyu.warn; + +import com.muyu.common.security.annotation.EnableCustomConfig; +import com.muyu.common.security.annotation.EnableMyFeignClients; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 系统模块 + * + * @author muyu + */ +@EnableCustomConfig +//@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class CloudWarnApplication { + public static void main (String[] args) { + SpringApplication.run(CloudWarnApplication.class, args); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/controller/WarnLogsController.java b/cloud-warn/src/main/java/com/muyu/warn/controller/WarnLogsController.java new file mode 100644 index 0000000..bf68ab5 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/controller/WarnLogsController.java @@ -0,0 +1,110 @@ +package com.muyu.warn.controller; + +import java.util.Arrays; +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.warn.domain.WarnLogs; +import com.muyu.warn.service.IWarnLogsService; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.security.utils.SecurityUtils; +import org.springframework.validation.annotation.Validated; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 预警日志Controller + * + * @author muyu + * @date 2024-09-20 + */ +@RestController +@RequestMapping("/logs") +public class WarnLogsController extends BaseController +{ + @Resource + private IWarnLogsService warnLogsService; + + /** + * 查询预警日志列表 + */ + @RequiresPermissions("warn:logs:list") + @GetMapping("/list") + public Result> list(WarnLogs warnLogs) + { + startPage(); + List list = warnLogsService.selectWarnLogsList(warnLogs); + return getDataTable(list); + } + + /** + * 导出预警日志列表 + */ + @RequiresPermissions("warn:logs:export") + @PostMapping("/export") + public void export(HttpServletResponse response, WarnLogs warnLogs) + { + List list = warnLogsService.selectWarnLogsList(warnLogs); + ExcelUtil util = new ExcelUtil(WarnLogs.class); + util.exportExcel(response, list, "预警日志数据"); + } + + /** + * 获取预警日志详细信息 + */ + @RequiresPermissions("warn:logs:query") + @GetMapping(value = "/{id}") + public Result> getInfo(@PathVariable("id") Long id) + { + return success(warnLogsService.selectWarnLogsById(id)); + } + + /** + * 新增预警日志 + */ + @RequiresPermissions("warn:logs:add") + @PostMapping + public Result add( + @Validated @RequestBody WarnLogs warnLogs) + { + if (warnLogsService.checkIdUnique(warnLogs)) { + return error("新增 预警日志 '" + warnLogs + "'失败,预警日志已存在"); + } + return toAjax(warnLogsService.save(warnLogs)); + } + + /** + * 修改预警日志 + */ + @RequiresPermissions("warn:logs:edit") + @PutMapping + public Result edit( + @Validated @RequestBody WarnLogs warnLogs) + { + if (!warnLogsService.checkIdUnique(warnLogs)) { + return error("修改 预警日志 '" + warnLogs + "'失败,预警日志不存在"); + } + return toAjax(warnLogsService.updateById(warnLogs)); + } + + /** + * 删除预警日志 + */ + @RequiresPermissions("warn:logs:remove") + @DeleteMapping("/{ids}") + public Result remove(@PathVariable("ids") Long[] ids) + { + warnLogsService.removeBatchByIds(Arrays.asList(ids)); + return success(); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/controller/WarnRuleController.java b/cloud-warn/src/main/java/com/muyu/warn/controller/WarnRuleController.java new file mode 100644 index 0000000..a88ac08 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/controller/WarnRuleController.java @@ -0,0 +1,110 @@ +package com.muyu.warn.controller; + +import java.util.Arrays; +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.warn.domain.WarnRule; +import com.muyu.warn.service.IWarnRuleService; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.security.utils.SecurityUtils; +import org.springframework.validation.annotation.Validated; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 预警规则Controller + * + * @author muyu + * @date 2024-09-20 + */ +@RestController +@RequestMapping("/rule") +public class WarnRuleController extends BaseController +{ + @Resource + private IWarnRuleService warnRuleService; + + /** + * 查询预警规则列表 + */ + @RequiresPermissions("warn:rule:list") + @GetMapping("/list") + public Result> list(WarnRule warnRule) + { + startPage(); + List list = warnRuleService.selectWarnRuleList(warnRule); + return getDataTable(list); + } + + /** + * 导出预警规则列表 + */ + @RequiresPermissions("warn:rule:export") + @PostMapping("/export") + public void export(HttpServletResponse response, WarnRule warnRule) + { + List list = warnRuleService.selectWarnRuleList(warnRule); + ExcelUtil util = new ExcelUtil(WarnRule.class); + util.exportExcel(response, list, "预警规则数据"); + } + + /** + * 获取预警规则详细信息 + */ + @RequiresPermissions("warn:rule:query") + @GetMapping(value = "/{id}") + public Result> getInfo(@PathVariable("id") Long id) + { + return success(warnRuleService.selectWarnRuleById(id)); + } + + /** + * 新增预警规则 + */ + @RequiresPermissions("warn:rule:add") + @PostMapping + public Result add( + @Validated @RequestBody WarnRule warnRule) + { + if (warnRuleService.checkIdUnique(warnRule)) { + return error("新增 预警规则 '" + warnRule + "'失败,预警规则已存在"); + } + return toAjax(warnRuleService.save(warnRule)); + } + + /** + * 修改预警规则 + */ + @RequiresPermissions("warn:rule:edit") + @PutMapping + public Result edit( + @Validated @RequestBody WarnRule warnRule) + { + if (!warnRuleService.checkIdUnique(warnRule)) { + return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在"); + } + return toAjax(warnRuleService.updateById(warnRule)); + } + + /** + * 删除预警规则 + */ + @RequiresPermissions("warn:rule:remove") + @DeleteMapping("/{ids}") + public Result remove(@PathVariable("ids") Long[] ids) + { + warnRuleService.removeBatchByIds(Arrays.asList(ids)); + return success(); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/controller/WarnStrategyController.java b/cloud-warn/src/main/java/com/muyu/warn/controller/WarnStrategyController.java new file mode 100644 index 0000000..fdc8542 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/controller/WarnStrategyController.java @@ -0,0 +1,110 @@ +package com.muyu.warn.controller; + +import java.util.Arrays; +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.warn.domain.WarnStrategy; +import com.muyu.warn.service.IWarnStrategyService; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.security.utils.SecurityUtils; +import org.springframework.validation.annotation.Validated; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 预警策略Controller + * + * @author muyu + * @date 2024-09-20 + */ +@RestController +@RequestMapping("/strategy") +public class WarnStrategyController extends BaseController +{ + @Resource + private IWarnStrategyService warnStrategyService; + + /** + * 查询预警策略列表 + */ + @RequiresPermissions("warn:strategy:list") + @GetMapping("/list") + public Result> list(WarnStrategy warnStrategy) + { + startPage(); + List list = warnStrategyService.selectWarnStrategyList(warnStrategy); + return getDataTable(list); + } + + /** + * 导出预警策略列表 + */ + @RequiresPermissions("warn:strategy:export") + @PostMapping("/export") + public void export(HttpServletResponse response, WarnStrategy warnStrategy) + { + List list = warnStrategyService.selectWarnStrategyList(warnStrategy); + ExcelUtil util = new ExcelUtil(WarnStrategy.class); + util.exportExcel(response, list, "预警策略数据"); + } + + /** + * 获取预警策略详细信息 + */ + @RequiresPermissions("warn:strategy:query") + @GetMapping(value = "/{id}") + public Result> getInfo(@PathVariable("id") Long id) + { + return success(warnStrategyService.selectWarnStrategyById(id)); + } + + /** + * 新增预警策略 + */ + @RequiresPermissions("warn:strategy:add") + @PostMapping + public Result add( + @Validated @RequestBody WarnStrategy warnStrategy) + { + if (warnStrategyService.checkIdUnique(warnStrategy)) { + return error("新增 预警策略 '" + warnStrategy + "'失败,预警策略已存在"); + } + return toAjax(warnStrategyService.save(warnStrategy)); + } + + /** + * 修改预警策略 + */ + @RequiresPermissions("warn:strategy:edit") + @PutMapping + public Result edit( + @Validated @RequestBody WarnStrategy warnStrategy) + { + if (!warnStrategyService.checkIdUnique(warnStrategy)) { + return error("修改 预警策略 '" + warnStrategy + "'失败,预警策略不存在"); + } + return toAjax(warnStrategyService.updateById(warnStrategy)); + } + + /** + * 删除预警策略 + */ + @RequiresPermissions("warn:strategy:remove") + @DeleteMapping("/{ids}") + public Result remove(@PathVariable("ids") Long[] ids) + { + warnStrategyService.removeBatchByIds(Arrays.asList(ids)); + return success(); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/domain/WarnLogs.java b/cloud-warn/src/main/java/com/muyu/warn/domain/WarnLogs.java new file mode 100644 index 0000000..768a980 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/domain/WarnLogs.java @@ -0,0 +1,91 @@ +package com.muyu.warn.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + * 预警日志对象 warn_logs + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@Setter +@Getter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@TableName("warn_logs") +public class WarnLogs{ + private static final long serialVersionUID = 1L; + + /** 预警日志id */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 车辆vin码 */ + @Excel(name = "车辆vin码") + private String vin; + + /** 规则id */ + @Excel(name = "规则id") + private Long warnRuleId; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 最大值 */ + @Excel(name = "最大值") + private Long maxValue; + + /** 最小值 */ + @Excel(name = "最小值") + private Long minValue; + + /** 平均值 */ + @Excel(name = "平均值") + private Long avgValue; + + /** 中位数 */ + @Excel(name = "中位数") + private Long medianValue; + + /** 是否发送预警 */ + @Excel(name = "是否发送预警") + private Long status; + + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("vin", getVin()) + .append("warnRuleId", getWarnRuleId()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("maxValue", getMaxValue()) + .append("minValue", getMinValue()) + .append("avgValue", getAvgValue()) + .append("medianValue", getMedianValue()) + .append("status", getStatus()) + .toString(); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/domain/WarnRule.java b/cloud-warn/src/main/java/com/muyu/warn/domain/WarnRule.java new file mode 100644 index 0000000..7a02610 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/domain/WarnRule.java @@ -0,0 +1,77 @@ +package com.muyu.warn.domain; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + * 预警规则对象 warn_rule + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@Setter +@Getter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@TableName("warn_rule") +public class WarnRule{ + private static final long serialVersionUID = 1L; + + /** 规则id */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 规则名称 */ + @Excel(name = "规则名称") + private String ruleName; + + /** 策略id */ + @Excel(name = "策略id") + private Long strategyId; + + /** 报文数据类型id */ + @Excel(name = "报文数据类型id") + private Long msgTypeId; + + /** 滑窗时间 */ + @Excel(name = "滑窗时间") + private Long slideTime; + + /** 滑窗频率 */ + @Excel(name = "滑窗频率") + private Long slideFrequency; + + /** 最大值 */ + @Excel(name = "最大值") + private Long maxValue; + + /** 最小值 */ + @Excel(name = "最小值") + private Long minValue; + + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("ruleName", getRuleName()) + .append("strategyId", getStrategyId()) + .append("msgTypeId", getMsgTypeId()) + .append("slideTime", getSlideTime()) + .append("slideFrequency", getSlideFrequency()) + .append("maxValue", getMaxValue()) + .append("minValue", getMinValue()) + .toString(); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/domain/WarnStrategy.java b/cloud-warn/src/main/java/com/muyu/warn/domain/WarnStrategy.java new file mode 100644 index 0000000..8fe5d6c --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/domain/WarnStrategy.java @@ -0,0 +1,57 @@ +package com.muyu.warn.domain; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + * 预警策略对象 warn_strategy + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@Setter +@Getter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@TableName("warn_strategy") +public class WarnStrategy{ + private static final long serialVersionUID = 1L; + + /** 策略id */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 车辆类型id */ + @Excel(name = "车辆类型id") + private Long carTypeId; + + /** 策略名称 */ + @Excel(name = "策略名称") + private String strategyName; + + /** 报文模版id */ + @Excel(name = "报文模版id") + private Long msgId; + + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("carTypeId", getCarTypeId()) + .append("strategyName", getStrategyName()) + .append("msgId", getMsgId()) + .toString(); + } +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnLogsMapper.java b/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnLogsMapper.java new file mode 100644 index 0000000..1046cea --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnLogsMapper.java @@ -0,0 +1,16 @@ +package com.muyu.warn.mapper; + +import com.muyu.warn.domain.WarnLogs; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 预警日志Mapper接口 + * + * @author muyu + * @date 2024-09-20 + */ +@Mapper +public interface WarnLogsMapper extends BaseMapper{ + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnRuleMapper.java b/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnRuleMapper.java new file mode 100644 index 0000000..127e420 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnRuleMapper.java @@ -0,0 +1,16 @@ +package com.muyu.warn.mapper; + +import com.muyu.warn.domain.WarnRule; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 预警规则Mapper接口 + * + * @author muyu + * @date 2024-09-20 + */ +@Mapper +public interface WarnRuleMapper extends BaseMapper{ + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnStrategyMapper.java b/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnStrategyMapper.java new file mode 100644 index 0000000..37acc07 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/mapper/WarnStrategyMapper.java @@ -0,0 +1,16 @@ +package com.muyu.warn.mapper; + +import com.muyu.warn.domain.WarnStrategy; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 预警策略Mapper接口 + * + * @author muyu + * @date 2024-09-20 + */ +@Mapper +public interface WarnStrategyMapper extends BaseMapper{ + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/service/IWarnLogsService.java b/cloud-warn/src/main/java/com/muyu/warn/service/IWarnLogsService.java new file mode 100644 index 0000000..d642e13 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/service/IWarnLogsService.java @@ -0,0 +1,37 @@ +package com.muyu.warn.service; + +import java.util.List; +import com.muyu.warn.domain.WarnLogs; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 预警日志Service接口 + * + * @author muyu + * @date 2024-09-20 + */ +public interface IWarnLogsService extends IService { + /** + * 精确查询预警日志 + * + * @param id 预警日志主键 + * @return 预警日志 + */ + public WarnLogs selectWarnLogsById(Long id); + + /** + * 查询预警日志列表 + * + * @param warnLogs 预警日志 + * @return 预警日志集合 + */ + public List selectWarnLogsList(WarnLogs warnLogs); + + /** + * 判断 预警日志 id是否唯一 + * @param warnLogs 预警日志 + * @return 结果 + */ + Boolean checkIdUnique(WarnLogs warnLogs); + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/service/IWarnRuleService.java b/cloud-warn/src/main/java/com/muyu/warn/service/IWarnRuleService.java new file mode 100644 index 0000000..38a502b --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/service/IWarnRuleService.java @@ -0,0 +1,37 @@ +package com.muyu.warn.service; + +import java.util.List; +import com.muyu.warn.domain.WarnRule; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 预警规则Service接口 + * + * @author muyu + * @date 2024-09-20 + */ +public interface IWarnRuleService extends IService { + /** + * 精确查询预警规则 + * + * @param id 预警规则主键 + * @return 预警规则 + */ + public WarnRule selectWarnRuleById(Long id); + + /** + * 查询预警规则列表 + * + * @param warnRule 预警规则 + * @return 预警规则集合 + */ + public List selectWarnRuleList(WarnRule warnRule); + + /** + * 判断 预警规则 id是否唯一 + * @param warnRule 预警规则 + * @return 结果 + */ + Boolean checkIdUnique(WarnRule warnRule); + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/service/IWarnStrategyService.java b/cloud-warn/src/main/java/com/muyu/warn/service/IWarnStrategyService.java new file mode 100644 index 0000000..cb395ed --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/service/IWarnStrategyService.java @@ -0,0 +1,37 @@ +package com.muyu.warn.service; + +import java.util.List; +import com.muyu.warn.domain.WarnStrategy; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 预警策略Service接口 + * + * @author muyu + * @date 2024-09-20 + */ +public interface IWarnStrategyService extends IService { + /** + * 精确查询预警策略 + * + * @param id 预警策略主键 + * @return 预警策略 + */ + public WarnStrategy selectWarnStrategyById(Long id); + + /** + * 查询预警策略列表 + * + * @param warnStrategy 预警策略 + * @return 预警策略集合 + */ + public List selectWarnStrategyList(WarnStrategy warnStrategy); + + /** + * 判断 预警策略 id是否唯一 + * @param warnStrategy 预警策略 + * @return 结果 + */ + Boolean checkIdUnique(WarnStrategy warnStrategy); + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnLogsServiceImpl.java b/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnLogsServiceImpl.java new file mode 100644 index 0000000..2780bc4 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnLogsServiceImpl.java @@ -0,0 +1,92 @@ +package com.muyu.warn.service.impl; + +import java.util.List; +import org.springframework.stereotype.Service; +import com.muyu.warn.mapper.WarnLogsMapper; +import com.muyu.warn.domain.WarnLogs; +import com.muyu.warn.service.IWarnLogsService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.utils.StringUtils; +import org.springframework.util.Assert; + +/** + * 预警日志Service业务层处理 + * + * @author muyu + * @date 2024-09-20 + */ +@Service +public class WarnLogsServiceImpl + extends ServiceImpl + implements IWarnLogsService { + + /** + * 精确查询预警日志 + * + * @param id 预警日志主键 + * @return 预警日志 + */ + @Override + public WarnLogs selectWarnLogsById(Long id) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Assert.notNull(id, "id不可为空"); + queryWrapper.eq(WarnLogs::getId, id); + return this.getOne(queryWrapper); + } + + + /** + * 查询预警日志列表 + * + * @param warnLogs 预警日志 + * @return 预警日志 + */ + @Override + public List selectWarnLogsList(WarnLogs warnLogs) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotEmpty(warnLogs.getVin())){ + queryWrapper.eq(WarnLogs::getVin, warnLogs.getVin()); + } + if (StringUtils.isNotNull(warnLogs.getWarnRuleId())){ + queryWrapper.eq(WarnLogs::getWarnRuleId, warnLogs.getWarnRuleId()); + } + if (StringUtils.isNotNull(warnLogs.getStartTime())){ + queryWrapper.eq(WarnLogs::getStartTime, warnLogs.getStartTime()); + } + if (StringUtils.isNotNull(warnLogs.getEndTime())){ + queryWrapper.eq(WarnLogs::getEndTime, warnLogs.getEndTime()); + } + if (StringUtils.isNotNull(warnLogs.getMaxValue())){ + queryWrapper.eq(WarnLogs::getMaxValue, warnLogs.getMaxValue()); + } + if (StringUtils.isNotNull(warnLogs.getMinValue())){ + queryWrapper.eq(WarnLogs::getMinValue, warnLogs.getMinValue()); + } + if (StringUtils.isNotNull(warnLogs.getAvgValue())){ + queryWrapper.eq(WarnLogs::getAvgValue, warnLogs.getAvgValue()); + } + if (StringUtils.isNotNull(warnLogs.getMedianValue())){ + queryWrapper.eq(WarnLogs::getMedianValue, warnLogs.getMedianValue()); + } + if (StringUtils.isNotNull(warnLogs.getStatus())){ + queryWrapper.eq(WarnLogs::getStatus, warnLogs.getStatus()); + } + return this.list(queryWrapper); + } + + /** + * 唯一 判断 + * @param warnLogs 预警日志 + * @return 预警日志 + */ + @Override + public Boolean checkIdUnique(WarnLogs warnLogs) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WarnLogs::getId, warnLogs.getId()); + return this.count(queryWrapper) > 0; + } + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnRuleServiceImpl.java b/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnRuleServiceImpl.java new file mode 100644 index 0000000..fed3c6f --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnRuleServiceImpl.java @@ -0,0 +1,86 @@ +package com.muyu.warn.service.impl; + +import java.util.List; +import org.springframework.stereotype.Service; +import com.muyu.warn.mapper.WarnRuleMapper; +import com.muyu.warn.domain.WarnRule; +import com.muyu.warn.service.IWarnRuleService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.utils.StringUtils; +import org.springframework.util.Assert; + +/** + * 预警规则Service业务层处理 + * + * @author muyu + * @date 2024-09-20 + */ +@Service +public class WarnRuleServiceImpl + extends ServiceImpl + implements IWarnRuleService { + + /** + * 精确查询预警规则 + * + * @param id 预警规则主键 + * @return 预警规则 + */ + @Override + public WarnRule selectWarnRuleById(Long id) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Assert.notNull(id, "id不可为空"); + queryWrapper.eq(WarnRule::getId, id); + return this.getOne(queryWrapper); + } + + + /** + * 查询预警规则列表 + * + * @param warnRule 预警规则 + * @return 预警规则 + */ + @Override + public List selectWarnRuleList(WarnRule warnRule) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotNull(warnRule.getRuleName())){ + queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName()); + } + if (StringUtils.isNotNull(warnRule.getStrategyId())){ + queryWrapper.eq(WarnRule::getStrategyId, warnRule.getStrategyId()); + } + if (StringUtils.isNotNull(warnRule.getMsgTypeId())){ + queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId()); + } + if (StringUtils.isNotNull(warnRule.getSlideTime())){ + queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime()); + } + if (StringUtils.isNotNull(warnRule.getSlideFrequency())){ + queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency()); + } + if (StringUtils.isNotNull(warnRule.getMaxValue())){ + queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue()); + } + if (StringUtils.isNotNull(warnRule.getMinValue())){ + queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue()); + } + return this.list(queryWrapper); + } + + /** + * 唯一 判断 + * @param warnRule 预警规则 + * @return 预警规则 + */ + @Override + public Boolean checkIdUnique(WarnRule warnRule) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WarnRule::getId, warnRule.getId()); + return this.count(queryWrapper) > 0; + } + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnStrategyServiceImpl.java b/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnStrategyServiceImpl.java new file mode 100644 index 0000000..343b4e5 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/service/impl/WarnStrategyServiceImpl.java @@ -0,0 +1,74 @@ +package com.muyu.warn.service.impl; + +import java.util.List; +import org.springframework.stereotype.Service; +import com.muyu.warn.mapper.WarnStrategyMapper; +import com.muyu.warn.domain.WarnStrategy; +import com.muyu.warn.service.IWarnStrategyService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.utils.StringUtils; +import org.springframework.util.Assert; + +/** + * 预警策略Service业务层处理 + * + * @author muyu + * @date 2024-09-20 + */ +@Service +public class WarnStrategyServiceImpl + extends ServiceImpl + implements IWarnStrategyService { + + /** + * 精确查询预警策略 + * + * @param id 预警策略主键 + * @return 预警策略 + */ + @Override + public WarnStrategy selectWarnStrategyById(Long id) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Assert.notNull(id, "id不可为空"); + queryWrapper.eq(WarnStrategy::getId, id); + return this.getOne(queryWrapper); + } + + + /** + * 查询预警策略列表 + * + * @param warnStrategy 预警策略 + * @return 预警策略 + */ + @Override + public List selectWarnStrategyList(WarnStrategy warnStrategy) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotNull(warnStrategy.getCarTypeId())){ + queryWrapper.eq(WarnStrategy::getCarTypeId, warnStrategy.getCarTypeId()); + } + if (StringUtils.isNotNull(warnStrategy.getStrategyName())){ + queryWrapper.like(WarnStrategy::getStrategyName, warnStrategy.getStrategyName()); + } + if (StringUtils.isNotNull(warnStrategy.getMsgId())){ + queryWrapper.eq(WarnStrategy::getMsgId, warnStrategy.getMsgId()); + } + return this.list(queryWrapper); + } + + /** + * 唯一 判断 + * @param warnStrategy 预警策略 + * @return 预警策略 + */ + @Override + public Boolean checkIdUnique(WarnStrategy warnStrategy) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WarnStrategy::getId, warnStrategy.getId()); + return this.count(queryWrapper) > 0; + } + +} diff --git a/cloud-warn/src/main/resources/banner.txt b/cloud-warn/src/main/resources/banner.txt new file mode 100644 index 0000000..e69de29 diff --git a/cloud-warn/src/main/resources/bootstrap.yml b/cloud-warn/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..a6a79fb --- /dev/null +++ b/cloud-warn/src/main/resources/bootstrap.yml @@ -0,0 +1,49 @@ +# Tomcat +server: + port: 9710 + +# nacos线上地址 +nacos: + addr: 106.15.136.7:8848 + user-name: nacos + password: nacos + namespace: lyb + +spring: + application: + # 应用名称 + name: cloud-warn + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名89 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + config: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + # 系统共享配置 + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # 系统环境Config共享配置 + - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.muyu.system.mapper: DEBUG diff --git a/cloud-weixin-mp/pom.xml b/cloud-weixin-mp/pom.xml new file mode 100644 index 0000000..b8479a9 --- /dev/null +++ b/cloud-weixin-mp/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + com.muyu + cloud-server-parent + 3.6.4 + + + + + cloud-weixin-mp + 3.6.3 + + + 17 + 17 + UTF-8 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.dom4j + dom4j + 2.1.3 + + + + org.projectlombok + lombok + + + + com.thoughtworks.xstream + xstream + 1.4.20 + + + + com.squareup.okhttp3 + okhttp + + + + com.alibaba.fastjson2 + fastjson2 + 2.0.43 + + + + com.muyu + cloud-common-core + 3.6.3 + + + + + + + diff --git a/cloud-weixin-mp/src/main/java/com/muyu/SpringBoot.java b/cloud-weixin-mp/src/main/java/com/muyu/SpringBoot.java new file mode 100644 index 0000000..9b0fe2f --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/SpringBoot.java @@ -0,0 +1,17 @@ +package com.muyu; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + *@ClassName SpringBoot + *@Description 描述 + *@Author YiBo.Liu + *@Date 2024/9/17 17:01 + */ +@SpringBootApplication +public class SpringBoot { + public static void main(String[] args) { + SpringApplication.run(SpringBoot.class, args); + } +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/message/Article.java b/cloud-weixin-mp/src/main/java/com/muyu/message/Article.java new file mode 100644 index 0000000..8c9c88c --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/message/Article.java @@ -0,0 +1,27 @@ +package com.muyu.message; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +/** + * @ClassName TextMessage + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/17 21:06 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@XStreamAlias("item") +public class Article { + @XStreamAlias("Title") + private String title; + @XStreamAlias("Description") + private String description; + @XStreamAlias("PicUrl") + private String picUrl; + @XStreamAlias("Url") + private String url; + +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/message/NewMessage.java b/cloud-weixin-mp/src/main/java/com/muyu/message/NewMessage.java new file mode 100644 index 0000000..69571b6 --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/message/NewMessage.java @@ -0,0 +1,34 @@ +package com.muyu.message; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @ClassName TextMessage + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/17 21:06 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@XStreamAlias("xml") +public class NewMessage { + @XStreamAlias("ToUserName") + private String toUserName; + @XStreamAlias("FromUserName") + private String fromUserName; + @XStreamAlias("CreateTime") + private long createTime; + @XStreamAlias("MsgType") + private String msgType; + @XStreamAlias("ArticleCount") + private int articleCount; + @XStreamAlias("Articles") + private List
articles; + +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/message/TextMessage.java b/cloud-weixin-mp/src/main/java/com/muyu/message/TextMessage.java new file mode 100644 index 0000000..5a339e3 --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/message/TextMessage.java @@ -0,0 +1,51 @@ +package com.muyu.message; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName TextMessage + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/17 21:06 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@XStreamAlias("xml") +public class TextMessage { + + /** + * 接收方账号 + */ + @XStreamAlias("ToUserName") + private String toUserName; + + /** + * 开发者微信号 + */ + @XStreamAlias("FromUserName") + private String fromUserName; + + /** + * 创建时间 + */ + @XStreamAlias("CreateTime") + private long createTime; + + /** + * 消息类型 + */ + @XStreamAlias("MsgType") + private String msgType; + + /** + * 消息内容 + */ + @XStreamAlias("Content") + private String content; + + +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/token/AccessToken.java b/cloud-weixin-mp/src/main/java/com/muyu/token/AccessToken.java new file mode 100644 index 0000000..bf0951a --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/token/AccessToken.java @@ -0,0 +1,30 @@ +package com.muyu.token; + +import lombok.Data; + +/** + * @ClassName AccessToken + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/18 15:48 + */ +@Data +public class AccessToken { + + private String access_token; + + private long expires_in; + + public void setExpiresTime(long expiresIn) { + this.expires_in = System.currentTimeMillis()+expiresIn*1000; + } + + /** + * 判断是否超时 + * @return + */ + public boolean isExpired() { + return System.currentTimeMillis()>this.expires_in; + } + +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/util/OkHttpUtils.java b/cloud-weixin-mp/src/main/java/com/muyu/util/OkHttpUtils.java new file mode 100644 index 0000000..cf32b41 --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/util/OkHttpUtils.java @@ -0,0 +1,36 @@ +package com.muyu.util; + +import okhttp3.*; + +import java.io.IOException; + +public class OkHttpUtils { + + private static final OkHttpClient client = new OkHttpClient(); + + public static String sendGetRequest(String urlString) { + Request request = new Request.Builder() + .url(urlString) + .build(); + try (Response response = client.newCall(request).execute()) { + return response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + public static String sendPostRequest(String urlString, String params) { + RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), params); + Request request = new Request.Builder() + .url(urlString) + .post(requestBody) + .build(); + try (Response response = client.newCall(request).execute()) { + return response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/util/TokenUtil.java b/cloud-weixin-mp/src/main/java/com/muyu/util/TokenUtil.java new file mode 100644 index 0000000..11e8dd3 --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/util/TokenUtil.java @@ -0,0 +1,41 @@ +package com.muyu.util; + +import com.alibaba.fastjson2.JSON; +import com.muyu.token.AccessToken; +import org.springframework.stereotype.Component; + +/** + * @ClassName AccessToken + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/18 15:48 + */ +@Component +public class TokenUtil { + private final static String APP_ID = "wx74741af76decd078"; + + private final static String APP_SECRET ="540af183133e701051b726f936ebbfe9"; + + private static AccessToken accessToken = new AccessToken(); + + + public static void getToken(){ + String url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s",APP_ID,APP_SECRET); + String request = OkHttpUtils.sendGetRequest(url); + AccessToken wechatToken = JSON.parseObject(request, AccessToken.class); + if (wechatToken != null) { + accessToken.setExpiresTime(wechatToken.getExpires_in()); + accessToken.setAccess_token(wechatToken.getAccess_token()); + } + } + + /** + * 获取AccessToken + * @return + */ + public static String getAccessToken(){ + getToken(); + return accessToken.getAccess_token(); + } + +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/util/WechatUtil.java b/cloud-weixin-mp/src/main/java/com/muyu/util/WechatUtil.java new file mode 100644 index 0000000..328cccd --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/util/WechatUtil.java @@ -0,0 +1,39 @@ +package com.muyu.util; + + + +import okhttp3.*; + +import java.io.IOException; + +public class WechatUtil { + + public static void send(String toUser,String content) { + String accessToken = TokenUtil.getAccessToken(); + if (!accessToken.equals("")) { + String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + accessToken; + String jsonStr = "{\"touser\":\"" + toUser + "\",\"msgtype\":\"text\",\"text\":{\"content\":\"" + content + "\"}}"; + OkHttpClient client = new OkHttpClient(); + + // 构建请求 + RequestBody requestBody = RequestBody.create(jsonStr, MediaType.get("application/json; charset=utf-8")); + Request request = new Request.Builder() + .url(url) + .post(requestBody) + .addHeader("Content-Type", "application/json; charset=utf-8") + .build(); + + // 发送请求 + try (Response response = client.newCall(request).execute()) { + if (!response.isSuccessful()) { + throw new IOException("Unexpected code " + response); + } + // 输出响应 + System.out.println(response.body().string()); + }catch (IOException e) { + e.printStackTrace(); + } + } + } + +} diff --git a/cloud-weixin-mp/src/main/java/com/muyu/wxController/WxController.java b/cloud-weixin-mp/src/main/java/com/muyu/wxController/WxController.java new file mode 100644 index 0000000..8e7c1d8 --- /dev/null +++ b/cloud-weixin-mp/src/main/java/com/muyu/wxController/WxController.java @@ -0,0 +1,190 @@ +package com.muyu.wxController; + +import com.muyu.message.Article; +import com.muyu.message.NewMessage; +import com.muyu.message.TextMessage; +import com.muyu.util.TokenUtil; +import com.muyu.util.WechatUtil; +import com.thoughtworks.xstream.XStream; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.http.HttpServletRequest; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; + +/** + * @ClassName WxController + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/17 16:59 + */ +@RestController("/wx") +public class WxController { + + @GetMapping("/wxTest") + public String test() { + return "Hello wechat"; + } + + /** + * 完成微信消息验证 判断是否是微信消息 + * @param signature + * @param timestamp + * @param nonce + * @param echostr + * @return + */ + @GetMapping("/") + public String check(String signature, String timestamp, String nonce, String echostr) { + //1)将token、timestamp、nonce三个参数进行字典序排序 + String token = "lybjava"; + List list = Arrays.asList(token, timestamp, nonce); + //排序 + Collections.sort(list); + //2)将三个参数字符串拼接成一个字符串进行sha1加密 + StringBuilder stringBuilder = new StringBuilder(); + for (String string : list) { + stringBuilder.append(string); + } + //加密 + try { + MessageDigest instance = MessageDigest.getInstance("sha1"); + //使用sha1进行加密获得byte数组 + byte[] digest = instance.digest(stringBuilder.toString().getBytes()); + StringBuilder sum = new StringBuilder(); + for (byte b : digest) { + sum.append(Integer.toHexString((b>>4)&15)); + sum.append(Integer.toHexString(b&15)); + } + System.out.println("signature:"+signature); + System.out.println("sum:"+sum); + + //3)开发者获得加密后的字符串可与signature对比,标识该请求来源于微信 + if(!StringUtils.isEmpty(signature) && signature.equals(sum.toString())) { + return echostr; + } + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + return null; + } + + + /** + * 用户发送消息,回复消息 + * @param request + * @return + * @throws IOException + */ + @PostMapping("/") + public String receiveMessage(HttpServletRequest request) throws IOException { + + ServletInputStream inputStream = request.getInputStream(); + Map map = new HashMap<>(); + + try { + SAXReader reader = new SAXReader(); + //读取request的输入流,获得Document对象 + Document document = reader.read(inputStream); + //获得root节点 + Element root = document.getRootElement(); + //获得root的子节点 + List elements = root.elements(); + for (Element element : elements) { + map.put(element.getName(), element.getStringValue()); + } + }catch (DocumentException e) { + throw new RuntimeException(e); + } + System.out.println("接收到用户的消息:"+map); + //回复消息 + String message =""; + if ("图文".equals(map.get("Content"))) { + message = getReplyNewsMessage(map); + }else { + message = getReplyMessage(map); + + } + System.out.println("回复给用户的消息:"+message); + return message; + } + + /** + * 获得回复的消息内容 + * @param map + * @return xml格式的字符串 + */ + private String getReplyMessage(Map map) { + TextMessage textMessage = new TextMessage(); + textMessage.setToUserName(map.get("FromUserName")); + textMessage.setFromUserName(map.get("ToUserName")); + textMessage.setMsgType("text"); + textMessage.setContent("你好宝贝,欢迎关注本公众号~"); + textMessage.setCreateTime(System.currentTimeMillis()/1000); + + //xstream 将java对象转换成xml字符串 + XStream xStream = new XStream(); + xStream.processAnnotations(TextMessage.class); + String xml = xStream.toXML(textMessage); + return xml; + } + + /** + * 获取Access_token + * @return + */ + @GetMapping("/getToken") + public String getToken() { + String accessToken = TokenUtil.getAccessToken(); + return accessToken; + } + + /** + * 回复图文消息 + * @param map + * @return + */ + private String getReplyNewsMessage(Map map) { + NewMessage newsMessage = new NewMessage(); + newsMessage.setToUserName(map.get("FromUserName")); + newsMessage.setFromUserName(map.get("ToUserName")); + newsMessage.setMsgType("news"); + newsMessage.setCreateTime(System.currentTimeMillis() / 1000); + newsMessage.setArticleCount(1); + List
articles = new ArrayList<>(); + Article article = new Article(); + article.setTitle("一个图文消息"); + article.setDescription("详细描述--------------信息"); + article.setUrl("https://www.baidu.com"); + article.setPicUrl("http://mmbiz.qpic.cn/mmbiz_jpg/RiaWwmABEMmkFKQMeQZLLYaxknlzE9CxSozVSH42iaXiaQcia5hPPUicuNYbS8dG99zsMZ1ic266ialM42Mbn8SkN54kA/0"); + articles.add(article); + newsMessage.setArticles(articles); + //XStream将java对象转换为xml字符串 + XStream xStream = new XStream(); + xStream.processAnnotations(NewMessage.class); + String xml = xStream.toXML(newsMessage); + return xml; + } + + + @GetMapping("/send") + public void send(@RequestParam("openId") String openId,@RequestParam("content")String content) { + WechatUtil.send(openId,content); + } + + + + + +} diff --git a/cloud-weixin-mp/src/main/resources/bootstrap.yml b/cloud-weixin-mp/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..66fc877 --- /dev/null +++ b/cloud-weixin-mp/src/main/resources/bootstrap.yml @@ -0,0 +1,12 @@ +# Tomcat +server: + port: 8666 +##用户授权的重定向域名 +#redirect: +# domain:123 +##公众号appId和secret +#wx: +# appId:123 +# secret:123 + + diff --git a/pom.xml b/pom.xml index 4558953..1dcf2df 100644 --- a/pom.xml +++ b/pom.xml @@ -282,6 +282,8 @@ cloud-visual cloud-modules cloud-common + cloud-weixin-mp + cloud-warn pom From 17c891ff02463be57fb4c4e7756328fe88a5b8e9 Mon Sep 17 00:00:00 2001 From: liuyibo <14460729+liuyibo12345@user.noreply.gitee.com> Date: Mon, 23 Sep 2024 10:15:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat():=E8=BD=A6=E8=BE=86=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E5=88=97=E8=A1=A8=EF=BC=8C=E8=A7=84=E5=88=99?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E9=80=9A=E8=BF=87=E7=AD=96=E7=95=A5?= =?UTF-8?q?id=E6=9F=A5=E8=AF=A2=E8=A7=84=E5=88=99=EF=BC=8C=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E7=AD=96=E7=95=A5=E8=A1=A8=E7=9A=84=E6=8A=A5=E6=96=87?= =?UTF-8?q?id=E6=9F=A5=E8=AF=A2=E6=8A=A5=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap.yml | 60 ++++++++++++++++ .../warn/controller/CarMessageController.java | 39 +++++++++++ .../warn/controller/CarTypeController.java | 47 +++++++++++++ .../warn/controller/TemplateController.java | 37 ++++++++++ .../warn/controller/WarnRuleController.java | 26 ++++--- .../controller/WarnStrategyController.java | 13 ++++ .../java/com/muyu/warn/domain/CarMessage.java | 50 +++++++++++++ .../java/com/muyu/warn/domain/CarType.java | 42 +++++++++++ .../warn/domain/Resp/StrategyRuleList.java | 60 ++++++++++++++++ .../warn/domain/Resp/WarnStrategyList.java | 70 +++++++++++++++++++ .../java/com/muyu/warn/domain/Template.java | 40 +++++++++++ .../com/muyu/warn/domain/WarnStrategy.java | 4 +- .../muyu/warn/mapper/CarMessageMapper.java | 9 +++ .../com/muyu/warn/mapper/CarTypeMapper.java | 12 ++++ .../com/muyu/warn/mapper/TemplateMapper.java | 9 +++ .../muyu/warn/mapper/WarnStrategyMapper.java | 4 ++ .../muyu/warn/service/CarMessageService.java | 7 ++ .../com/muyu/warn/service/CarTypeService.java | 9 +++ .../muyu/warn/service/IWarnRuleService.java | 2 + .../warn/service/IWarnStrategyService.java | 5 ++ .../muyu/warn/service/TemplateService.java | 7 ++ .../service/impl/CarMessageServiceImpl.java | 24 +++++++ .../service/impl/CarTypeTypeServiceImpl.java | 29 ++++++++ .../service/impl/TemplateServiceImpl.java | 24 +++++++ .../service/impl/WarnRuleServiceImpl.java | 2 + .../service/impl/WarnStrategyServiceImpl.java | 18 ++++- .../main/resources/mapper/CarTypeMapper.xml | 9 +++ .../resources/mapper/WarnStrategyMapper.xml | 26 +++++++ 28 files changed, 672 insertions(+), 12 deletions(-) create mode 100644 cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml create mode 100644 cloud-warn/src/main/java/com/muyu/warn/controller/CarMessageController.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/controller/CarTypeController.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/controller/TemplateController.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/CarMessage.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/CarType.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/Resp/StrategyRuleList.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/Resp/WarnStrategyList.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/domain/Template.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/mapper/CarMessageMapper.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/mapper/CarTypeMapper.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/mapper/TemplateMapper.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/CarMessageService.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/CarTypeService.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/TemplateService.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/impl/CarMessageServiceImpl.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/impl/CarTypeTypeServiceImpl.java create mode 100644 cloud-warn/src/main/java/com/muyu/warn/service/impl/TemplateServiceImpl.java create mode 100644 cloud-warn/src/main/resources/mapper/CarTypeMapper.xml create mode 100644 cloud-warn/src/main/resources/mapper/WarnStrategyMapper.xml diff --git a/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..f95ea7d --- /dev/null +++ b/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml @@ -0,0 +1,60 @@ +# Tomcat +server: + port: 10066 + +# nacos线上地址 +nacos: + addr: 106.15.136.7:8848 + user-name: nacos + password: nacos + namespace: zmw +# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all +# Spring +spring: + amqp: + deserialization: + trust: + all: true + main: + allow-bean-definition-overriding: true + application: + # 应用名称 + name: cloud-car + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + config: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + # 系统共享配置 + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # 系统环境Config共享配置 + - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # xxl-job 配置文件 + - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # rabbit 配置文件 + - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.muyu.system.mapper: DEBUG diff --git a/cloud-warn/src/main/java/com/muyu/warn/controller/CarMessageController.java b/cloud-warn/src/main/java/com/muyu/warn/controller/CarMessageController.java new file mode 100644 index 0000000..f65b305 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/controller/CarMessageController.java @@ -0,0 +1,39 @@ +package com.muyu.warn.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.muyu.common.core.domain.Result; +import com.muyu.warn.domain.CarMessage; +import com.muyu.warn.service.CarMessageService; +import com.muyu.warn.service.CarTypeService; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @ClassName CarMessageController + * @Description 描述 + * @Author YiBo.Liu + * @Date 2024/9/22 22:28 + */ +@RestController +@RequestMapping("/carMessage") +public class CarMessageController { + @Autowired + private CarMessageService carMessageService; + + /** + * 根据报文模板id查询报文 + * @param templateId + * @return + */ + @GetMapping("/selectByTemplateId") + private Result> selectByTemplateId(@RequestParam("templateId") Integer templateId) { + return Result.success(carMessageService.list + (new LambdaQueryWrapper().eq(CarMessage::getTemplateId, templateId))); + } + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/controller/CarTypeController.java b/cloud-warn/src/main/java/com/muyu/warn/controller/CarTypeController.java new file mode 100644 index 0000000..a3b82f9 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/controller/CarTypeController.java @@ -0,0 +1,47 @@ +package com.muyu.warn.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.muyu.common.core.domain.Result; +import com.muyu.warn.domain.CarType; +import com.muyu.warn.service.CarTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @ClassName CarController + * @Description 车辆类型Controller层 + * @Author YiBo.Liu + * @Date 2024/9/22 16:52 + */ +@RestController +@RequestMapping("/carType") +public class CarTypeController { + + @Autowired + private CarTypeService carTypeService; + + /** + * 查询所有规则 + * @return carTypeList + */ + @GetMapping("/carTypeList") + private Result> carTypeList() { + List carTypeList = carTypeService.list(); + return Result.success(carTypeList); + } + + /** + * 通过id查询类型对象 + * @param catTypeId + * @return + */ + @PostMapping("/catTypeId") + private Result catTypeId(@RequestParam("catTypeId") Integer catTypeId) { + CarType carType = carTypeService.findById(catTypeId); + return Result.success(carType); + } + + +} diff --git a/cloud-warn/src/main/java/com/muyu/warn/controller/TemplateController.java b/cloud-warn/src/main/java/com/muyu/warn/controller/TemplateController.java new file mode 100644 index 0000000..74966f7 --- /dev/null +++ b/cloud-warn/src/main/java/com/muyu/warn/controller/TemplateController.java @@ -0,0 +1,37 @@ +package com.muyu.warn.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.muyu.common.core.domain.Result; +import com.muyu.warn.domain.Template; +import com.muyu.warn.service.TemplateService; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @ClassName Template + * @Description 报文模板 + * @Author YiBo.Liu + * @Date 2024/9/22 18:37 + */ +@RestController +@RequestMapping("/template") +public class TemplateController { + + @Autowired + private TemplateService templateService; + + /** + * 通过报文id查询 + * @param templateId + * @return + */ + @GetMapping("/findByTemplateId") + private Result findByTemplateId(@RequestParam("templateId") Integer templateId) { + return Result.success(templateService.getOne( + new LambdaQueryWrapper