From 3271c30c0f0d989d4a592da3d9090c667c80c2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=AF=85=E5=A4=A7=E7=A5=9E?= <3163302184@qq.com> Date: Sat, 21 Sep 2024 11:51:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E7=94=B5=E5=AD=90=E5=9B=B4?= =?UTF-8?q?=E6=A0=8F=E5=90=8E=E5=8F=B0master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap.yml | 4 +- .../cloud-common/cloud-common-xxl/pom.xml | 37 -- .../com/muyu/common/xxl/XXLJobConfig.java | 28 -- .../com/muyu/common/xxl/XxlJobProperties.java | 63 --- .../common/xxl/demo/XxlJobDemoService.java | 38 -- ...ot.autoconfigure.AutoConfiguration.imports | 3 - cloud-server/cloud-common/pom.xml | 2 +- .../src/main/resources/bootstrap.yml | 6 +- .../cloud-modules-car/.gitignore | 38 -- .../cloud-modules/cloud-modules-car/pom.xml | 14 +- .../com/muyu/car/CloudCarApplication.java | 21 - .../muyu/car/controller/SysCarController.java | 114 ----- .../main/java/com/muyu/car/domain/SysCar.java | 91 ---- .../com/muyu/car/mapper/SysCarMapper.java | 16 - .../com/muyu/car/service/ISysCarService.java | 37 -- .../car/service/impl/SysCarServiceImpl.java | 90 ---- .../src/main/resources/banner.txt | 2 - .../src/main/resources/bootstrap.yml | 13 +- .../src/main/resources/logback/dev.xml | 74 --- .../src/main/resources/logback/prod.xml | 81 ---- .../src/main/resources/logback/test.xml | 81 ---- .../resources/mapper/car/SysCarMapper.xml | 111 ----- .../src/main/resources/bootstrap.yml | 4 +- .../com/muyu/gen/CloudGenApplication.java | 1 - .../muyu/gen/controller/GenController.java | 107 ++--- .../java/com/muyu/gen/domain/GenTable.java | 2 - .../com/muyu/gen/domain/GenTableResp.java | 43 -- .../muyu/gen/mapper/GenTableColumnMapper.java | 27 +- .../com/muyu/gen/mapper/GenTableMapper.java | 39 +- .../service/GenTableColumnServiceImpl.java | 58 +-- .../muyu/gen/service/GenTableServiceImpl.java | 250 ++++------ .../gen/service/IGenTableColumnService.java | 19 +- .../muyu/gen/service/IGenTableService.java | 50 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/logback/dev.xml | 68 +-- .../src/main/resources/logback/prod.xml | 68 +-- .../src/main/resources/logback/test.xml | 68 +-- .../mapper/generator/GenTableColumnMapper.xml | 183 ++++--- .../mapper/generator/GenTableMapper.xml | 453 +++++++++++------- .../main/resources/vm/java/controller.java.vm | 43 +- .../src/main/resources/vm/java/domain.java.vm | 40 +- .../src/main/resources/vm/java/mapper.java.vm | 81 +++- .../main/resources/vm/java/service.java.vm | 40 +- .../resources/vm/java/serviceImpl.java.vm | 176 ++++--- .../main/resources/vm/java/sub-domain.java.vm | 3 +- .../src/main/resources/vm/vue/index.vue.vm | 8 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- 48 files changed, 980 insertions(+), 1827 deletions(-) delete mode 100644 cloud-server/cloud-common/cloud-common-xxl/pom.xml delete mode 100644 cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java delete mode 100644 cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XxlJobProperties.java delete mode 100644 cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java delete mode 100644 cloud-server/cloud-common/cloud-common-xxl/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/.gitignore delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/CloudCarApplication.java delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/controller/SysCarController.java delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/domain/SysCar.java delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/mapper/SysCarMapper.java delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/ISysCarService.java delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/impl/SysCarServiceImpl.java delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/resources/banner.txt delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/dev.xml delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/prod.xml delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/test.xml delete mode 100644 cloud-server/cloud-modules/cloud-modules-car/src/main/resources/mapper/car/SysCarMapper.xml delete mode 100644 cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTableResp.java diff --git a/cloud-server/cloud-auth/src/main/resources/bootstrap.yml b/cloud-server/cloud-auth/src/main/resources/bootstrap.yml index 5737044..9f39c17 100644 --- a/cloud-server/cloud-auth/src/main/resources/bootstrap.yml +++ b/cloud-server/cloud-auth/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: # nacos线上地址 nacos: - addr: 47.116.173.119:8848 + addr: 110.42.213.184:8848 user-name: nacos password: nacos - namespace: one + namespace: public # Spring spring: application: diff --git a/cloud-server/cloud-common/cloud-common-xxl/pom.xml b/cloud-server/cloud-common/cloud-common-xxl/pom.xml deleted file mode 100644 index 4af9214..0000000 --- a/cloud-server/cloud-common/cloud-common-xxl/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - - com.muyu - cloud-common - 3.6.3 - - - cloud-common-xxl - - XllJob定时任务 - - - 17 - 17 - UTF-8 - - - - - - - com.muyu - cloud-common-core - - - - - com.xuxueli - xxl-job-core - - - - \ No newline at end of file diff --git a/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java b/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java deleted file mode 100644 index 0bf4362..0000000 --- a/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.muyu.common.xxl; - -import com.muyu.common.core.utils.StringUtils; -import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; -import lombok.extern.log4j.Log4j2; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -@Log4j2 -@Component -public class XXLJobConfig { - @Bean - public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) { - if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){ - throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项,xxl-job共享配置[application-xxl-config]"); - } - XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); - xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses()); - xxlJobSpringExecutor.setAppname(xxlJobProperties.getAppName()); - xxlJobSpringExecutor.setIp(xxlJobProperties.getIp()); - xxlJobSpringExecutor.setPort(xxlJobProperties.getPort()); - xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken()); - xxlJobSpringExecutor.setLogPath(xxlJobProperties.getLogPath()); - xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getLogRetentionDays()); - log.info(">>>>>>>>>>> xxl-job config init success."); - return xxlJobSpringExecutor; - } -} diff --git a/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XxlJobProperties.java b/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XxlJobProperties.java deleted file mode 100644 index c1428f7..0000000 --- a/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XxlJobProperties.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.muyu.common.xxl; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Data -@Configuration -@ConfigurationProperties(prefix = "xxl-job") -public class XxlJobProperties { - - /** - * 调度中心部署根地址 [选填]: - * 如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调"; - * 为空则关闭自动注册; - */ - private String adminAddresses; - - /** - * 执行器通讯TOKEN [选填]: - * 非空时启用; - */ - private String accessToken; - - /** - * 执行器AppName [选填]: - * 执行器心跳注册分组依据;为空则关闭自动注册 - */ - private String appName; - - /** - * 执行器注册 [选填]: - * 优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。 - * 从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。 - */ - private String address; - - /** - * 执行器IP [选填]: - * 默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用; - * 地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; - */ - private String ip; - - /** - * 执行器端口号 [选填]: - * 小于等于0则自动获取;默认端口为9999, - * 单机部署多个执行器时,注意要配置不同执行器端口; - */ - private int port; - - /** - * 执行器运行日志文件存储磁盘路径 [选填]: - * 需要对该路径拥有读写权限;为空则使用默认路径; - */ - private String logPath; - - /** - * 执行器日志文件保存天数 [选填]: - * 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; - */ - private int logRetentionDays; -} diff --git a/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java b/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java deleted file mode 100644 index 51cd2a4..0000000 --- a/cloud-server/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.muyu.common.xxl.demo; - -import com.xxl.job.core.context.XxlJobHelper; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.log4j.Log4j2; -import org.springframework.stereotype.Component; - -@Log4j2 -@Component -public class XxlJobDemoService { - - /** - * 无参测试 - */ - @XxlJob("xxl-job-demo-no-param") - public void xxlJobDemoNoParam(){ - log.info("调度名称:[{}] - 无参", "xxl-job-demo-no-param"); - } - - /** - * 有参测试 - */ - @XxlJob("xxl-job-demo-one-param") - public void xxlJobDemoOneParam(){ - String param = XxlJobHelper.getJobParam(); - log.info("调度名称:[{}] - 参数:[{}]", "xxl-job-demo-one-param", param); - } - /** - * 分片测试 - */ - @XxlJob("xxl-job-slice-demo") - public void xxlJobSliceDemo(){ - int shardTotal = XxlJobHelper.getShardTotal(); - int shardIndex = XxlJobHelper.getShardIndex(); - String param = XxlJobHelper.getJobParam(); - log.info("调度名称:[{}-[{}/{}(分片位置/分片总数)]] - 参数:[{}]", "xxl-job-slice-demo",shardIndex, shardTotal, param); - } -} diff --git a/cloud-server/cloud-common/cloud-common-xxl/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cloud-server/cloud-common/cloud-common-xxl/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 1404a51..0000000 --- a/cloud-server/cloud-common/cloud-common-xxl/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,3 +0,0 @@ -com.muyu.common.xxl.XXLJobConfig -com.muyu.common.xxl.XxlJobProperties -com.muyu.common.xxl.demo.XxlJobDemoService \ No newline at end of file diff --git a/cloud-server/cloud-common/pom.xml b/cloud-server/cloud-common/pom.xml index d00dfc6..782ac1e 100644 --- a/cloud-server/cloud-common/pom.xml +++ b/cloud-server/cloud-common/pom.xml @@ -18,7 +18,7 @@ cloud-common-datascope cloud-common-datasource cloud-common-system - cloud-common-xxl + cloud-common-rabbit diff --git a/cloud-server/cloud-gateway/src/main/resources/bootstrap.yml b/cloud-server/cloud-gateway/src/main/resources/bootstrap.yml index 4936f23..e737bce 100644 --- a/cloud-server/cloud-gateway/src/main/resources/bootstrap.yml +++ b/cloud-server/cloud-gateway/src/main/resources/bootstrap.yml @@ -1,13 +1,13 @@ # Tomcat server: - port: 8080 + port: 8084 # nacos线上地址 nacos: - addr: 47.116.173.119:8848 + addr: 110.42.213.184:8848 user-name: nacos password: nacos - namespace: one + namespace: public # Spring spring: diff --git a/cloud-server/cloud-modules/cloud-modules-car/.gitignore b/cloud-server/cloud-modules/cloud-modules-car/.gitignore deleted file mode 100644 index 5ff6309..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/cloud-server/cloud-modules/cloud-modules-car/pom.xml b/cloud-server/cloud-modules/cloud-modules-car/pom.xml index 625b4c6..c7daf6d 100644 --- a/cloud-server/cloud-modules/cloud-modules-car/pom.xml +++ b/cloud-server/cloud-modules/cloud-modules-car/pom.xml @@ -61,28 +61,17 @@ cloud-common-datascope - com.muyu - cloud-common-log + cloud-common-core - com.muyu cloud-common-api-doc - - - com.muyu - cloud-common-xxl - - - com.muyu - cloud-common-rabbit - @@ -102,4 +91,5 @@ + diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/CloudCarApplication.java b/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/CloudCarApplication.java deleted file mode 100644 index 662105f..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/CloudCarApplication.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.muyu.car; - -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 CloudCarApplication { - public static void main (String[] args) { - SpringApplication.run(CloudCarApplication.class, args); - } -} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/controller/SysCarController.java b/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/controller/SysCarController.java deleted file mode 100644 index 778fa77..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/controller/SysCarController.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.muyu.car.controller; - -import java.util.Arrays; -import java.util.List; -import jakarta.servlet.http.HttpServletResponse; -import javax.annotation.Resource; - -import org.springframework.beans.factory.annotation.Autowired; -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.car.domain.SysCar; -import com.muyu.car.service.ISysCarService; -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-17 - */ -@RestController -@RequestMapping("/car") -public class SysCarController extends BaseController -{ - @Autowired - private ISysCarService sysCarService; - - /** - * 查询车辆基础信息列表 - */ - @RequiresPermissions("car:car:list") - @GetMapping("/list") - public Result> list(SysCar sysCar) - { - startPage(); - List list = sysCarService.selectSysCarList(sysCar); - return getDataTable(list); - } - - /** - * 导出车辆基础信息列表 - */ - @RequiresPermissions("car:car:export") - @PostMapping("/export") - public void export(HttpServletResponse response, SysCar sysCar) - { - List list = sysCarService.selectSysCarList(sysCar); - ExcelUtil util = new ExcelUtil(SysCar.class); - util.exportExcel(response, list, "车辆基础信息数据"); - } - - /** - * 获取车辆基础信息详细信息 - */ - @RequiresPermissions("car:car:query") - @GetMapping(value = "/{id}") - public Result> getInfo(@PathVariable("id") Long id) - { - return success(sysCarService.selectSysCarById(id)); - } - - /** - * 新增车辆基础信息 - */ - @RequiresPermissions("car:car:add") - @PostMapping - public Result add( - @Validated @RequestBody SysCar sysCar) - { - if (sysCarService.checkIdUnique(sysCar)) { - return error("新增 车辆基础信息 '" + sysCar + "'失败,车辆基础信息已存在"); - } - sysCar.setCreateBy(SecurityUtils.getUsername()); - return toAjax(sysCarService.save(sysCar)); - } - - /** - * 修改车辆基础信息 - */ - @RequiresPermissions("car:car:edit") - @PutMapping - public Result edit( - @Validated @RequestBody SysCar sysCar) - { - if (!sysCarService.checkIdUnique(sysCar)) { - return error("修改 车辆基础信息 '" + sysCar + "'失败,车辆基础信息不存在"); - } - sysCar.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(sysCarService.updateById(sysCar)); - } - - /** - * 删除车辆基础信息 - */ - @RequiresPermissions("car:car:remove") - @DeleteMapping("/{ids}") - public Result remove(@PathVariable("ids") Long[] ids) - { - sysCarService.removeBatchByIds(Arrays.asList(ids)); - return success(); - } -} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/domain/SysCar.java b/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/domain/SysCar.java deleted file mode 100644 index 22c2ea1..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/domain/SysCar.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.muyu.car.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; - -/** - * 车辆基础信息对象 sys_car - * - * @author muyu - * @date 2024-09-17 - */ - -@Data -@Setter -@Getter -@SuperBuilder -@NoArgsConstructor -@AllArgsConstructor -@TableName("sys_car") -public class SysCar extends BaseEntity{ - private static final long serialVersionUID = 1L; - - /** 自增主键 */ - @TableId( type = IdType.AUTO) - private Long id; - - /** 车辆VIN码 */ - @Excel(name = "车辆VIN码") - private String carVin; - - /** 车辆车牌号 */ - @Excel(name = "车辆车牌号") - private String carPlate; - - /** 车辆品牌 */ - @Excel(name = "车辆品牌") - private String carBrand; - - /** 车辆型号 */ - @Excel(name = "车辆型号") - private String carModel; - - /** 车辆车型(如客车,卡车,公交车等) */ - @Excel(name = "车辆车型(如客车,卡车,公交车等)") - private String carType; - - /** 最后一次连线时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "最后一次连线时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date carLastJoinTime; - - /** 最后一次离线时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "最后一次离线时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date carLastOfflineTime; - - /** 启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中 */ - @Excel(name = "启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中") - private String state; - - - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("carVin", getCarVin()) - .append("carPlate", getCarPlate()) - .append("carBrand", getCarBrand()) - .append("carModel", getCarModel()) - .append("carType", getCarType()) - .append("carLastJoinTime", getCarLastJoinTime()) - .append("carLastOfflineTime", getCarLastOfflineTime()) - .append("state", getState()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/mapper/SysCarMapper.java b/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/mapper/SysCarMapper.java deleted file mode 100644 index 1711c48..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/mapper/SysCarMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.muyu.car.mapper; - -import java.util.List; -import com.muyu.car.domain.SysCar; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * 车辆基础信息Mapper接口 - * - * @author muyu - * @date 2024-09-17 - */ -public interface SysCarMapper extends BaseMapper{ - -} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/ISysCarService.java b/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/ISysCarService.java deleted file mode 100644 index 3b010ff..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/ISysCarService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.muyu.car.service; - -import java.util.List; -import com.muyu.car.domain.SysCar; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - * 车辆基础信息Service接口 - * - * @author muyu - * @date 2024-09-17 - */ -public interface ISysCarService extends IService { - /** - * 精确查询车辆基础信息 - * - * @param id 车辆基础信息主键 - * @return 车辆基础信息 - */ - public SysCar selectSysCarById(Long id); - - /** - * 查询车辆基础信息列表 - * - * @param sysCar 车辆基础信息 - * @return 车辆基础信息集合 - */ - public List selectSysCarList(SysCar sysCar); - - /** - * 判断 车辆基础信息 id是否唯一 - * @param sysCar 车辆基础信息 - * @return 结果 - */ - Boolean checkIdUnique(SysCar sysCar); - -} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/impl/SysCarServiceImpl.java b/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/impl/SysCarServiceImpl.java deleted file mode 100644 index 309faaf..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/java/com/muyu/car/service/impl/SysCarServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.muyu.car.service.impl; - -import java.util.List; -import com.muyu.common.core.utils.DateUtils; -import org.springframework.stereotype.Service; -import com.muyu.car.mapper.SysCarMapper; -import com.muyu.car.domain.SysCar; -import com.muyu.car.service.ISysCarService; -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-17 - */ -@Service -public class SysCarServiceImpl - extends ServiceImpl - implements ISysCarService { - - /** - * 精确查询车辆基础信息 - * - * @param id 车辆基础信息主键 - * @return 车辆基础信息 - */ - @Override - public SysCar selectSysCarById(Long id) - { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - Assert.notNull(id, "id不可为空"); - queryWrapper.eq(SysCar::getId, id); - return this.getOne(queryWrapper); - } - - - /** - * 查询车辆基础信息列表 - * - * @param sysCar 车辆基础信息 - * @return 车辆基础信息 - */ - @Override - public List selectSysCarList(SysCar sysCar) - { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - if (StringUtils.isNotEmpty(sysCar.getCarVin())){ - queryWrapper.eq(SysCar::getCarVin, sysCar.getCarVin()); - } - if (StringUtils.isNotEmpty(sysCar.getCarPlate())){ - queryWrapper.eq(SysCar::getCarPlate, sysCar.getCarPlate()); - } - if (StringUtils.isNotEmpty(sysCar.getCarBrand())){ - queryWrapper.eq(SysCar::getCarBrand, sysCar.getCarBrand()); - } - if (StringUtils.isNotEmpty(sysCar.getCarModel())){ - queryWrapper.eq(SysCar::getCarModel, sysCar.getCarModel()); - } - if (StringUtils.isNotEmpty(sysCar.getCarType())){ - queryWrapper.eq(SysCar::getCarType, sysCar.getCarType()); - } - if (sysCar.getCarLastJoinTime()!= null){ - queryWrapper.eq(SysCar::getCarLastJoinTime, sysCar.getCarLastJoinTime()); - } - if (sysCar.getCarLastOfflineTime()!= null){ - queryWrapper.eq(SysCar::getCarLastOfflineTime, sysCar.getCarLastOfflineTime()); - } - if (StringUtils.isNotEmpty(sysCar.getState())){ - queryWrapper.eq(SysCar::getState, sysCar.getState()); - } - return this.list(queryWrapper); - } - - /** - * 唯一 判断 - * @param sysCar 车辆基础信息 - * @return 车辆基础信息 - */ - @Override - public Boolean checkIdUnique(SysCar sysCar) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(SysCar::getId, sysCar.getId()); - return this.count(queryWrapper) > 0; - } - -} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/banner.txt b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/banner.txt deleted file mode 100644 index 0dd5eee..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/banner.txt +++ /dev/null @@ -1,2 +0,0 @@ -Spring Boot Version: ${spring-boot.version} -Spring Application Name: ${spring.application.name} diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml index 9d2c73c..d1b64a8 100644 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml +++ b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml @@ -1,13 +1,13 @@ # Tomcat server: - port: 10010 + port: 10011 # nacos线上地址 nacos: - addr: 47.116.173.119:8848 + addr: 110.42.213.184:8848 user-name: nacos password: nacos - namespace: one + namespace: public # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # Spring spring: @@ -51,11 +51,8 @@ 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 + com.muyu.carrail.mapper: DEBUG diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/dev.xml b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/dev.xml deleted file mode 100644 index d1b5629..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/dev.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - ${log.pattern} - - - - - - ${log.path}/info.log - - - - ${log.path}/info.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - INFO - - ACCEPT - - DENY - - - - - ${log.path}/error.log - - - - ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - ERROR - - ACCEPT - - DENY - - - - - - - - - - - - - - - - - - diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/prod.xml b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/prod.xml deleted file mode 100644 index 76a0d8f..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/prod.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - ${log.sky.pattern} - - - - - - ${log.path}/info.log - - - - ${log.path}/info.%d{yyyy-MM-dd}.log - - 60 - - - - - INFO - - ACCEPT - - DENY - - - - - ${log.path}/error.log - - - - ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 - - - - - ERROR - - ACCEPT - - DENY - - - - - - - - ${log.sky.pattern} - - - - - - - - - - - - - - - - - - - - diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/test.xml b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/test.xml deleted file mode 100644 index 2cd69e4..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/logback/test.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - ${log.sky.pattern} - - - - - - ${log.path}/info.log - - - - ${log.path}/info.%d{yyyy-MM-dd}.log - - 60 - - - - - INFO - - ACCEPT - - DENY - - - - - ${log.path}/error.log - - - - ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 - - - - - ERROR - - ACCEPT - - DENY - - - - - - - - ${log.sky.pattern} - - - - - - - - - - - - - - - - - - - - diff --git a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/mapper/car/SysCarMapper.xml b/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/mapper/car/SysCarMapper.xml deleted file mode 100644 index 5113cd6..0000000 --- a/cloud-server/cloud-modules/cloud-modules-car/src/main/resources/mapper/car/SysCarMapper.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - select id, car_vin, car_plate, car_brand, car_model, car_type, car_last_join_time, car_last_offline_time, state, create_by, create_time, update_by, update_time, remark from sys_car - - - - - - - - insert into sys_car - - car_vin, - car_plate, - car_brand, - car_model, - car_type, - car_last_join_time, - car_last_offline_time, - state, - create_by, - create_time, - update_by, - update_time, - remark, - - - #{carVin}, - #{carPlate}, - #{carBrand}, - #{carModel}, - #{carType}, - #{carLastJoinTime}, - #{carLastOfflineTime}, - #{state}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - #{remark}, - - - - - update sys_car - - car_vin = #{carVin}, - car_plate = #{carPlate}, - car_brand = #{carBrand}, - car_model = #{carModel}, - car_type = #{carType}, - car_last_join_time = #{carLastJoinTime}, - car_last_offline_time = #{carLastOfflineTime}, - state = #{state}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - remark = #{remark}, - - where id = #{id} - - - - delete from sys_car where id = #{id} - - - - delete from sys_car where id in - - #{id} - - - diff --git a/cloud-server/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml b/cloud-server/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml index c01a9c3..8bf570c 100644 --- a/cloud-server/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml +++ b/cloud-server/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: # nacos线上地址 nacos: - addr: 47.116.173.119:8848 + addr: 110.42.213.184:8848 user-name: nacos password: nacos - namespace: one + namespace: public # Spring spring: diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java index 3cb1f39..da3eb43 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java @@ -16,6 +16,5 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; public class CloudGenApplication { public static void main (String[] args) { SpringApplication.run(CloudGenApplication.class, args); - System.out.println("CloudGen 模块启动成功!"); } } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java index 100a2c4..1dfe039 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java @@ -1,24 +1,22 @@ package com.muyu.gen.controller; -import com.muyu.common.core.domain.Result; import com.muyu.common.core.text.Convert; import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.log.annotation.Log; import com.muyu.common.log.enums.BusinessType; import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.gen.domain.GenTable; import com.muyu.gen.domain.GenTableColumn; -import com.muyu.gen.domain.GenTableResp; import com.muyu.gen.service.IGenTableColumnService; import com.muyu.gen.service.IGenTableService; -import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; - +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.HashMap; import java.util.List; @@ -27,19 +25,15 @@ import java.util.Map; /** * 代码生成 操作处理 * - * @author ruoyi + * @author muyu */ @RequestMapping("/gen") @RestController -public class GenController extends BaseController -{ - @Resource +public class GenController extends BaseController { + @Autowired private IGenTableService genTableService; - @Resource - private HttpServletResponse response; - - @Resource + @Autowired private IGenTableColumnService genTableColumnService; /** @@ -47,8 +41,7 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:list") @GetMapping("/list") - public Result genList(GenTable genTable) - { + public Result> genList (GenTable genTable) { startPage(); List list = genTableService.selectGenTableList(genTable); return getDataTable(list); @@ -59,8 +52,7 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:query") @GetMapping(value = "/{tableId}") - public Result getInfo(@PathVariable("tableId") Long tableId) - { + public Result getInfo (@PathVariable("tableId") Long tableId) { GenTable table = genTableService.selectGenTableById(tableId); List tables = genTableService.selectGenTableAll(); List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); @@ -71,14 +63,12 @@ public class GenController extends BaseController return success(map); } - /** * 查询数据库列表 */ @RequiresPermissions("tool:gen:list") @GetMapping("/db/list") - public Result dataList(GenTable genTable) - { + public Result> dataList (GenTable genTable) { startPage(); List list = genTableService.selectDbTableList(genTable); return getDataTable(list); @@ -88,26 +78,26 @@ public class GenController extends BaseController * 查询数据表字段列表 */ @GetMapping(value = "/column/{tableId}") - public Result columnList(@PathVariable("tableId") Long tableId) - { - TableDataInfo dataInfo = new TableDataInfo(); + public Result> columnList (Long tableId) { List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); - dataInfo.setRows(list); - dataInfo.setTotal(list.size()); - return success(dataInfo); + return Result.success( + TableDataInfo.builder() + .total(list.size()) + .rows(list) + .build() + ); } /** * 导入表结构(保存) */ -// @RequiresPermissions("tool:gen:import") + @RequiresPermissions("tool:gen:import") @Log(title = "代码生成", businessType = BusinessType.IMPORT) @PostMapping("/importTable") - public Result importTableSave(@RequestParam("tables") String tables, @RequestParam("dbName") String dbName) - { + public Result importTableSave (String tables) { String[] tableNames = Convert.toStrArray(tables); // 查询表信息 - List tableList = genTableService.selectDbTableListByNames(tableNames,dbName); + List tableList = genTableService.selectDbTableListByNames(tableNames); genTableService.importGenTable(tableList); return success(); } @@ -118,8 +108,7 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:edit") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PutMapping - public Result editSave(@Validated @RequestBody GenTable genTable) - { + public Result editSave (@Validated @RequestBody GenTable genTable) { genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); return success(); @@ -131,8 +120,7 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:remove") @Log(title = "代码生成", businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") - public Result remove(@PathVariable("tableIds") Long[] tableIds) - { + public Result remove (@PathVariable("tableIds") Long[] tableIds) { genTableService.deleteGenTableByIds(tableIds); return success(); } @@ -142,8 +130,7 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:preview") @GetMapping("/preview/{tableId}") - public Result preview(@PathVariable("tableId") Long tableId) throws IOException - { + public Result preview (@PathVariable("tableId") Long tableId) throws IOException { Map dataMap = genTableService.previewCode(tableId); return success(dataMap); } @@ -154,8 +141,7 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/download/{tableName}") - public void download(@PathVariable("tableName") String tableName) throws IOException - { + public void download (HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { byte[] data = genTableService.downloadCode(tableName); genCode(response, data); } @@ -166,8 +152,7 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/genCode/{tableName}") - public Result genCode(@PathVariable("tableName") String tableName) - { + public Result genCode (@PathVariable("tableName") String tableName) { genTableService.generatorCode(tableName); return success(); } @@ -177,10 +162,9 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:edit") @Log(title = "代码生成", businessType = BusinessType.UPDATE) - @GetMapping("/synchDb/{tableName}/{dbName}") - public Result synchDb(@PathVariable("tableName") String tableName,@PathVariable("dbName") String dbName) - { - genTableService.synchDb(tableName,dbName); + @GetMapping("/synchDb/{tableName}") + public Result synchDb (@PathVariable("tableName") String tableName) { + genTableService.synchDb(tableName); return success(); } @@ -190,8 +174,7 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/batchGenCode") - public void batchGenCode(@RequestParam("tables") String tables) throws IOException - { + public void batchGenCode (HttpServletResponse response, String tables) throws IOException { String[] tableNames = Convert.toStrArray(tables); byte[] data = genTableService.downloadCode(tableNames); genCode(response, data); @@ -200,37 +183,11 @@ public class GenController extends BaseController /** * 生成zip文件 */ - private void genCode(HttpServletResponse response, byte[] data) throws IOException - { + private void genCode (HttpServletResponse response, byte[] data) throws IOException { response.reset(); - response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); - response.addHeader("Content-Length", "" + data.length); + response.setHeader("Content-Disposition", "attachment; filename=\"muyu.zip\""); + response.addHeader("Content-Length", String.valueOf(data.length)); response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } - - /** - * 查询所有数据库名称 - */ - @GetMapping("/selDbNameAll") - public Result> selDbNameAll(){ - return Result.success(genTableService.selDbNameAll()); - } - - /** - * 查询所有表,不分数据库 - */ - @GetMapping("/db/listAll") - public Result> genListAll() { - return success(genTableService.selectDbTableListAll()); - } - - /** - * 根据数据库名称与表名称查询表字段 - */ - @GetMapping("/selectDbTableColumnsByName") - public Result> selTableAll(@RequestParam("dbName") String dbName,@RequestParam("table") String table){ - List genTableColumns = genTableColumnService.selectDbTableColumnsByName(table, dbName); - return Result.success(genTableColumns); - } } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java index c906725..edb6510 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java @@ -35,8 +35,6 @@ public class GenTable extends BaseEntity { */ private Long tableId; - private String dbName; - /** * 表名称 */ diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTableResp.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTableResp.java deleted file mode 100644 index 70b30dc..0000000 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTableResp.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.muyu.gen.domain; - -import com.muyu.common.core.constant.GenConstants; -import com.muyu.common.core.utils.StringUtils; -import com.muyu.common.core.web.domain.BaseEntity; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; -import org.apache.commons.lang3.ArrayUtils; - -import java.util.List; - - -/** - * 业务表 gen_table - * - * @author muyu - */ -@Data -@SuperBuilder -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = true) -public class GenTableResp extends BaseEntity { - - private String dbName; - - /** - * 表名称 - */ - private String tableName; - - /** - * 表描述 - */ - private String tableComment; - - -} diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java index 76f5909..5825d59 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java @@ -1,64 +1,67 @@ package com.muyu.gen.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.gen.domain.GenTableColumn; -import org.apache.ibatis.annotations.Param; import java.util.List; - /** * 业务字段 数据层 * - * @author ruoyi + * @author muyu */ -public interface GenTableColumnMapper -{ +public interface GenTableColumnMapper extends BaseMapper { /** * 根据表名称查询列信息 * * @param tableName 表名称 - * @param dbName + * * @return 列信息 */ - public List selectDbTableColumnsByName(@Param("tableName") String tableName, @Param("dbName") String dbName); + List selectDbTableColumnsByName (String tableName); /** * 查询业务字段列表 * * @param tableId 业务字段编号 + * * @return 业务字段集合 */ - public List selectGenTableColumnListByTableId(@Param("tableId") Long tableId); + List selectGenTableColumnListByTableId (Long tableId); /** * 新增业务字段 * * @param genTableColumn 业务字段信息 + * * @return 结果 */ - public int insertGenTableColumn(GenTableColumn genTableColumn); + int insertGenTableColumn (GenTableColumn genTableColumn); /** * 修改业务字段 * * @param genTableColumn 业务字段信息 + * * @return 结果 */ - public int updateGenTableColumn(GenTableColumn genTableColumn); + int updateGenTableColumn (GenTableColumn genTableColumn); /** * 删除业务字段 * * @param genTableColumns 列数据 + * * @return 结果 */ - public int deleteGenTableColumns(@Param("genTableColumns") List genTableColumns); + int deleteGenTableColumns (List genTableColumns); /** * 批量删除业务字段 * * @param ids 需要删除的数据ID + * * @return 结果 */ - public int deleteGenTableColumnByIds(@Param("ids") Long[] ids); + int deleteGenTableColumnByIds (Long[] ids); } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java index aa49b3f..66858cb 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java @@ -1,91 +1,92 @@ package com.muyu.gen.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.gen.domain.GenTable; -import com.muyu.gen.domain.GenTableResp; -import org.apache.ibatis.annotations.Param; import java.util.List; /** * 业务 数据层 * - * @author ruoyi + * @author muyu */ -public interface GenTableMapper -{ +public interface GenTableMapper extends BaseMapper { /** * 查询业务列表 * * @param genTable 业务信息 + * * @return 业务集合 */ - public List selectGenTableList(GenTable genTable); + List selectGenTableList (GenTable genTable); /** * 查询据库列表 * * @param genTable 业务信息 + * * @return 数据库表集合 */ - public List selectDbTableList(GenTable genTable); + List selectDbTableList (GenTable genTable); /** * 查询据库列表 * * @param tableNames 表名称组 - * @param dbName + * * @return 数据库表集合 */ - public List selectDbTableListByNames(@Param("tableNames") String[] tableNames, @Param("dbName") String dbName); + List selectDbTableListByNames (String[] tableNames); /** * 查询所有表信息 * * @return 表信息集合 */ - public List selectGenTableAll(); + List selectGenTableAll (); /** * 查询表ID业务信息 * * @param id 业务ID + * * @return 业务信息 */ - public GenTable selectGenTableById(@Param("id") Long id); + GenTable selectGenTableById (Long id); /** * 查询表名称业务信息 * * @param tableName 表名称 + * * @return 业务信息 */ - public GenTable selectGenTableByName(@Param("tableName") String tableName); + GenTable selectGenTableByName (String tableName); /** * 新增业务 * * @param genTable 业务信息 + * * @return 结果 */ - public int insertGenTable(GenTable genTable); + int insertGenTable (GenTable genTable); /** * 修改业务 * * @param genTable 业务信息 + * * @return 结果 */ - public int updateGenTable(GenTable genTable); + int updateGenTable (GenTable genTable); /** * 批量删除业务 * * @param ids 需要删除的数据ID + * * @return 结果 */ - public int deleteGenTableByIds(@Param("ids") Long[] ids); - - List selDbNameAll(); - - List selectDbTableListAll(); + int deleteGenTableByIds (Long[] ids); } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java index 043c83b..895b1ed 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java @@ -3,7 +3,7 @@ package com.muyu.gen.service; import com.muyu.common.core.text.Convert; import com.muyu.gen.domain.GenTableColumn; import com.muyu.gen.mapper.GenTableColumnMapper; - import javax.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -11,64 +11,58 @@ import java.util.List; /** * 业务字段 服务层实现 * - * @author ruoyi + * @author muyu */ @Service -public class GenTableColumnServiceImpl implements IGenTableColumnService -{ - @Resource - private GenTableColumnMapper genTableColumnMapper; +public class GenTableColumnServiceImpl implements IGenTableColumnService { + @Autowired + private GenTableColumnMapper genTableColumnMapper; - /** + /** * 查询业务字段列表 * * @param tableId 业务字段编号 + * * @return 业务字段集合 */ - @Override - public List selectGenTableColumnListByTableId(Long tableId) - { - return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); - } + @Override + public List selectGenTableColumnListByTableId (Long tableId) { + return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); + } /** * 新增业务字段 * * @param genTableColumn 业务字段信息 + * * @return 结果 */ - @Override - public int insertGenTableColumn(GenTableColumn genTableColumn) - { - return genTableColumnMapper.insertGenTableColumn(genTableColumn); - } + @Override + public int insertGenTableColumn (GenTableColumn genTableColumn) { + return genTableColumnMapper.insertGenTableColumn(genTableColumn); + } - /** + /** * 修改业务字段 * * @param genTableColumn 业务字段信息 + * * @return 结果 */ - @Override - public int updateGenTableColumn(GenTableColumn genTableColumn) - { - return genTableColumnMapper.updateGenTableColumn(genTableColumn); - } + @Override + public int updateGenTableColumn (GenTableColumn genTableColumn) { + return genTableColumnMapper.updateGenTableColumn(genTableColumn); + } - /** + /** * 删除业务字段对象 * * @param ids 需要删除的数据ID + * * @return 结果 */ - @Override - public int deleteGenTableColumnByIds(String ids) - { - return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); - } - @Override - public List selectDbTableColumnsByName(String table, String dbName) { - return genTableColumnMapper.selectDbTableColumnsByName(table,dbName); + public int deleteGenTableColumnByIds (String ids) { + return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); } } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java index 8cdefc5..6273779 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java @@ -10,7 +10,6 @@ import com.muyu.common.core.utils.StringUtils; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.gen.domain.GenTable; import com.muyu.gen.domain.GenTableColumn; -import com.muyu.gen.domain.GenTableResp; import com.muyu.gen.mapper.GenTableColumnMapper; import com.muyu.gen.mapper.GenTableMapper; import com.muyu.gen.util.GenUtils; @@ -23,7 +22,7 @@ import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import javax.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,28 +41,43 @@ import java.util.zip.ZipOutputStream; /** * 业务 服务层实现 * - * @author ruoyi + * @author muyu */ @Service -public class GenTableServiceImpl implements IGenTableService -{ +public class GenTableServiceImpl implements IGenTableService { private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class); - @Resource + @Autowired private GenTableMapper genTableMapper; - @Resource + @Autowired private GenTableColumnMapper genTableColumnMapper; + /** + * 获取代码生成地址 + * + * @param table 业务表信息 + * @param template 模板文件路径 + * + * @return 生成地址 + */ + public static String getGenPath (GenTable table, String template) { + String genPath = table.getGenPath(); + if (StringUtils.equals(genPath, "/")) { + return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); + } + return genPath + File.separator + VelocityUtils.getFileName(template, table); + } + /** * 查询业务信息 * * @param id 业务ID + * * @return 业务信息 */ @Override - public GenTable selectGenTableById(Long id) - { + public GenTable selectGenTableById (Long id) { GenTable genTable = genTableMapper.selectGenTableById(id); setTableFromOptions(genTable); return genTable; @@ -73,11 +87,11 @@ public class GenTableServiceImpl implements IGenTableService * 查询业务列表 * * @param genTable 业务信息 + * * @return 业务集合 */ @Override - public List selectGenTableList(GenTable genTable) - { + public List selectGenTableList (GenTable genTable) { return genTableMapper.selectGenTableList(genTable); } @@ -85,11 +99,11 @@ public class GenTableServiceImpl implements IGenTableService * 查询据库列表 * * @param genTable 业务信息 + * * @return 数据库表集合 */ @Override - public List selectDbTableList(GenTable genTable) - { + public List selectDbTableList (GenTable genTable) { return genTableMapper.selectDbTableList(genTable); } @@ -97,13 +111,12 @@ public class GenTableServiceImpl implements IGenTableService * 查询据库列表 * * @param tableNames 表名称组 - * @param dbName + * * @return 数据库表集合 */ @Override - public List selectDbTableListByNames(String[] tableNames, String dbName) - { - return genTableMapper.selectDbTableListByNames(tableNames,dbName); + public List selectDbTableListByNames (String[] tableNames) { + return genTableMapper.selectDbTableListByNames(tableNames); } /** @@ -112,8 +125,7 @@ public class GenTableServiceImpl implements IGenTableService * @return 表信息集合 */ @Override - public List selectGenTableAll() - { + public List selectGenTableAll () { return genTableMapper.selectGenTableAll(); } @@ -121,19 +133,17 @@ public class GenTableServiceImpl implements IGenTableService * 修改业务 * * @param genTable 业务信息 + * * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public void updateGenTable(GenTable genTable) - { + public void updateGenTable (GenTable genTable) { String options = JSON.toJSONString(genTable.getParams()); genTable.setOptions(options); int row = genTableMapper.updateGenTable(genTable); - if (row > 0) - { - for (GenTableColumn cenTableColumn : genTable.getColumns()) - { + if (row > 0) { + for (GenTableColumn cenTableColumn : genTable.getColumns()) { genTableColumnMapper.updateGenTableColumn(cenTableColumn); } } @@ -143,12 +153,12 @@ public class GenTableServiceImpl implements IGenTableService * 删除业务对象 * * @param tableIds 需要删除的数据ID + * * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public void deleteGenTableByIds(Long[] tableIds) - { + public void deleteGenTableByIds (Long[] tableIds) { genTableMapper.deleteGenTableByIds(tableIds); genTableColumnMapper.deleteGenTableColumnByIds(tableIds); } @@ -160,31 +170,23 @@ public class GenTableServiceImpl implements IGenTableService */ @Override @Transactional(rollbackFor = Exception.class) - public void importGenTable(List tableList) - { + public void importGenTable (List tableList) { String operName = SecurityUtils.getUsername(); - try - { - for (GenTable table : tableList) - { - String dbName = table.getDbName(); + try { + for (GenTable table : tableList) { String tableName = table.getTableName(); GenUtils.initTable(table, operName); int row = genTableMapper.insertGenTable(table); - if (row > 0) - { + if (row > 0) { // 保存列信息 - List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName); - for (GenTableColumn column : genTableColumns) - { + List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + for (GenTableColumn column : genTableColumns) { GenUtils.initColumnField(column, table); genTableColumnMapper.insertGenTableColumn(column); } } } - } - catch (Exception e) - { + } catch (Exception e) { throw new ServiceException("导入失败:" + e.getMessage()); } } @@ -193,11 +195,11 @@ public class GenTableServiceImpl implements IGenTableService * 预览代码 * * @param tableId 表编号 + * * @return 预览数据列表 */ @Override - public Map previewCode(Long tableId) - { + public Map previewCode (Long tableId) { Map dataMap = new LinkedHashMap<>(); // 查询表信息 GenTable table = genTableMapper.selectGenTableById(tableId); @@ -211,8 +213,7 @@ public class GenTableServiceImpl implements IGenTableService // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); - for (String template : templates) - { + for (String template : templates) { // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); @@ -226,11 +227,11 @@ public class GenTableServiceImpl implements IGenTableService * 生成代码(下载方式) * * @param tableName 表名称 + * * @return 数据 */ @Override - public byte[] downloadCode(String tableName) - { + public byte[] downloadCode (String tableName) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); generatorCode(tableName, zip); @@ -244,8 +245,7 @@ public class GenTableServiceImpl implements IGenTableService * @param tableName 表名称 */ @Override - public void generatorCode(String tableName) - { + public void generatorCode (String tableName) { // 查询表信息 GenTable table = genTableMapper.selectGenTableByName(tableName); // 设置主子表信息 @@ -259,21 +259,16 @@ public class GenTableServiceImpl implements IGenTableService // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); - for (String template : templates) - { - if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) - { + for (String template : templates) { + if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); tpl.merge(context, sw); - try - { + try { String path = getGenPath(table, template); FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); - } - catch (IOException e) - { + } catch (IOException e) { throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); } } @@ -284,54 +279,45 @@ public class GenTableServiceImpl implements IGenTableService * 同步数据库 * * @param tableName 表名称 - * @param dbName */ @Override @Transactional(rollbackFor = Exception.class) - public void synchDb(String tableName, String dbName) - { + public void synchDb (String tableName) { GenTable table = genTableMapper.selectGenTableByName(tableName); List tableColumns = table.getColumns(); Map tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity())); - List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName); - if (StringUtils.isEmpty(dbTableColumns)) - { + List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + if (StringUtils.isEmpty(dbTableColumns)) { throw new ServiceException("同步数据失败,原表结构不存在"); } List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); dbTableColumns.forEach(column -> { GenUtils.initColumnField(column, table); - if (tableColumnMap.containsKey(column.getColumnName())) - { + if (tableColumnMap.containsKey(column.getColumnName())) { GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); column.setColumnId(prevColumn.getColumnId()); - if (column.isList()) - { + if (column.isList()) { // 如果是列表,继续保留查询方式/字典类型选项 column.setDictType(prevColumn.getDictType()); column.setQueryType(prevColumn.getQueryType()); } if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk() && (column.isInsert() || column.isEdit()) - && ((column.isUsableColumn()) || (!column.isSuperColumn()))) - { + && ((column.isUsableColumn()) || (!column.isSuperColumn()))) { // 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项 column.setIsRequired(prevColumn.getIsRequired()); column.setHtmlType(prevColumn.getHtmlType()); } genTableColumnMapper.updateGenTableColumn(column); - } - else - { + } else { genTableColumnMapper.insertGenTableColumn(column); } }); List delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); - if (StringUtils.isNotEmpty(delColumns)) - { + if (StringUtils.isNotEmpty(delColumns)) { genTableColumnMapper.deleteGenTableColumns(delColumns); } } @@ -340,15 +326,14 @@ public class GenTableServiceImpl implements IGenTableService * 批量生成代码(下载方式) * * @param tableNames 表数组 + * * @return 数据 */ @Override - public byte[] downloadCode(String[] tableNames) - { + public byte[] downloadCode (String[] tableNames) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); - for (String tableName : tableNames) - { + for (String tableName : tableNames) { generatorCode(tableName, zip); } IOUtils.closeQuietly(zip); @@ -358,8 +343,7 @@ public class GenTableServiceImpl implements IGenTableService /** * 查询表信息并生成代码 */ - private void generatorCode(String tableName, ZipOutputStream zip) - { + private void generatorCode (String tableName, ZipOutputStream zip) { // 查询表信息 GenTable table = genTableMapper.selectGenTableByName(tableName); // 设置主子表信息 @@ -373,23 +357,19 @@ public class GenTableServiceImpl implements IGenTableService // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); - for (String template : templates) - { + for (String template : templates) { // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); tpl.merge(context, sw); - try - { + try { // 添加到zip zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); IOUtils.write(sw.toString(), zip, Constants.UTF8); IOUtils.closeQuietly(sw); zip.flush(); zip.closeEntry(); - } - catch (IOException e) - { + } catch (IOException e) { log.error("渲染模板失败,表名:" + table.getTableName(), e); } } @@ -401,80 +381,49 @@ public class GenTableServiceImpl implements IGenTableService * @param genTable 业务信息 */ @Override - public void validateEdit(GenTable genTable) - { - if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) - { + public void validateEdit (GenTable genTable) { + if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { String options = JSON.toJSONString(genTable.getParams()); JSONObject paramsObj = JSON.parseObject(options); - if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) - { + if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) { throw new ServiceException("树编码字段不能为空"); - } - else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) - { + } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) { throw new ServiceException("树父编码字段不能为空"); - } - else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) - { + } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) { throw new ServiceException("树名称字段不能为空"); - } - else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) - { - if (StringUtils.isEmpty(genTable.getSubTableName())) - { + } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) { + if (StringUtils.isEmpty(genTable.getSubTableName())) { throw new ServiceException("关联子表的表名不能为空"); - } - else if (StringUtils.isEmpty(genTable.getSubTableFkName())) - { + } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { throw new ServiceException("子表关联的外键名不能为空"); } } } } - @Override - public List selDbNameAll() { - return genTableMapper.selDbNameAll(); - } - - @Override - public List selectDbTableListAll() { - return genTableMapper.selectDbTableListAll(); - } - - /** * 设置主键列信息 * * @param table 业务表信息 */ - public void setPkColumn(GenTable table) - { - for (GenTableColumn column : table.getColumns()) - { - if (column.isPk()) - { + public void setPkColumn (GenTable table) { + for (GenTableColumn column : table.getColumns()) { + if (column.isPk()) { table.setPkColumn(column); break; } } - if (StringUtils.isNull(table.getPkColumn())) - { + if (StringUtils.isNull(table.getPkColumn())) { table.setPkColumn(table.getColumns().get(0)); } - if (GenConstants.TPL_SUB.equals(table.getTplCategory())) - { - for (GenTableColumn column : table.getSubTable().getColumns()) - { - if (column.isPk()) - { + if (GenConstants.TPL_SUB.equals(table.getTplCategory())) { + for (GenTableColumn column : table.getSubTable().getColumns()) { + if (column.isPk()) { table.getSubTable().setPkColumn(column); break; } } - if (StringUtils.isNull(table.getSubTable().getPkColumn())) - { + if (StringUtils.isNull(table.getSubTable().getPkColumn())) { table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); } } @@ -485,11 +434,9 @@ public class GenTableServiceImpl implements IGenTableService * * @param table 业务表信息 */ - public void setSubTable(GenTable table) - { + public void setSubTable (GenTable table) { String subTableName = table.getSubTableName(); - if (StringUtils.isNotEmpty(subTableName)) - { + if (StringUtils.isNotEmpty(subTableName)) { table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); } } @@ -499,11 +446,9 @@ public class GenTableServiceImpl implements IGenTableService * * @param genTable 设置后的生成对象 */ - public void setTableFromOptions(GenTable genTable) - { + public void setTableFromOptions (GenTable genTable) { JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); - if (StringUtils.isNotNull(paramsObj)) - { + if (StringUtils.isNotNull(paramsObj)) { String treeCode = paramsObj.getString(GenConstants.TREE_CODE); String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); String treeName = paramsObj.getString(GenConstants.TREE_NAME); @@ -517,21 +462,4 @@ public class GenTableServiceImpl implements IGenTableService genTable.setParentMenuName(parentMenuName); } } - - /** - * 获取代码生成地址 - * - * @param table 业务表信息 - * @param template 模板文件路径 - * @return 生成地址 - */ - public static String getGenPath(GenTable table, String template) - { - String genPath = table.getGenPath(); - if (StringUtils.equals(genPath, "/")) - { - return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); - } - return genPath + File.separator + VelocityUtils.getFileName(template, table); - } } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java index e6d4d55..b60ea57 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java @@ -7,41 +7,42 @@ import java.util.List; /** * 业务字段 服务层 * - * @author ruoyi + * @author muyu */ -public interface IGenTableColumnService -{ +public interface IGenTableColumnService { /** * 查询业务字段列表 * * @param tableId 业务字段编号 + * * @return 业务字段集合 */ - public List selectGenTableColumnListByTableId(Long tableId); + List selectGenTableColumnListByTableId (Long tableId); /** * 新增业务字段 * * @param genTableColumn 业务字段信息 + * * @return 结果 */ - public int insertGenTableColumn(GenTableColumn genTableColumn); + int insertGenTableColumn (GenTableColumn genTableColumn); /** * 修改业务字段 * * @param genTableColumn 业务字段信息 + * * @return 结果 */ - public int updateGenTableColumn(GenTableColumn genTableColumn); + int updateGenTableColumn (GenTableColumn genTableColumn); /** * 删除业务字段信息 * * @param ids 需要删除的数据ID + * * @return 结果 */ - public int deleteGenTableColumnByIds(String ids); - - List selectDbTableColumnsByName(String table, String dbName); + int deleteGenTableColumnByIds (String ids); } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java index f79d5e8..f34dc37 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java @@ -1,7 +1,6 @@ package com.muyu.gen.service; import com.muyu.gen.domain.GenTable; -import com.muyu.gen.domain.GenTableResp; import java.util.List; import java.util.Map; @@ -9,121 +8,124 @@ import java.util.Map; /** * 业务 服务层 * - * @author ruoyi + * @author muyu */ -public interface IGenTableService -{ +public interface IGenTableService { /** * 查询业务列表 * * @param genTable 业务信息 + * * @return 业务集合 */ - public List selectGenTableList(GenTable genTable); + List selectGenTableList (GenTable genTable); /** * 查询据库列表 * * @param genTable 业务信息 + * * @return 数据库表集合 */ - public List selectDbTableList(GenTable genTable); + List selectDbTableList (GenTable genTable); /** * 查询据库列表 * * @param tableNames 表名称组 - * @param dbName + * * @return 数据库表集合 */ - public List selectDbTableListByNames(String[] tableNames, String dbName); + List selectDbTableListByNames (String[] tableNames); /** * 查询所有表信息 * * @return 表信息集合 */ - public List selectGenTableAll(); + List selectGenTableAll (); /** * 查询业务信息 * * @param id 业务ID + * * @return 业务信息 */ - public GenTable selectGenTableById(Long id); + GenTable selectGenTableById (Long id); /** * 修改业务 * * @param genTable 业务信息 + * * @return 结果 */ - public void updateGenTable(GenTable genTable); + void updateGenTable (GenTable genTable); /** * 删除业务信息 * * @param tableIds 需要删除的表数据ID + * * @return 结果 */ - public void deleteGenTableByIds(Long[] tableIds); + void deleteGenTableByIds (Long[] tableIds); /** * 导入表结构 * * @param tableList 导入表列表 */ - public void importGenTable(List tableList); + void importGenTable (List tableList); /** * 预览代码 * * @param tableId 表编号 + * * @return 预览数据列表 */ - public Map previewCode(Long tableId); + Map previewCode (Long tableId); /** * 生成代码(下载方式) * * @param tableName 表名称 + * * @return 数据 */ - public byte[] downloadCode(String tableName); + byte[] downloadCode (String tableName); /** * 生成代码(自定义路径) * * @param tableName 表名称 + * * @return 数据 */ - public void generatorCode(String tableName); + void generatorCode (String tableName); /** * 同步数据库 * * @param tableName 表名称 - * @param dbName */ - public void synchDb(String tableName, String dbName); + void synchDb (String tableName); /** * 批量生成代码(下载方式) * * @param tableNames 表数组 + * * @return 数据 */ - public byte[] downloadCode(String[] tableNames); + byte[] downloadCode (String[] tableNames); /** * 修改保存参数校验 * * @param genTable 业务信息 */ - public void validateEdit(GenTable genTable); - - List selDbNameAll(); - - List selectDbTableListAll(); + void validateEdit (GenTable genTable); } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml index 7220679..bd41e64 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: # nacos线上地址 nacos: - addr: 47.116.173.119:8848 + addr: 110.42.213.184:8848 user-name: nacos password: nacos - namespace: one + namespace: public # Spring spring: diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/dev.xml b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/dev.xml index 30606f7..0b3964c 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/dev.xml +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/dev.xml @@ -1,31 +1,31 @@ - - - + + + - - - ${log.pattern} - - + + + ${log.pattern} + + - - ${log.path}/info.log + + ${log.path}/info.log - + - ${log.path}/info.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + INFO @@ -33,16 +33,16 @@ DENY - + - ${log.path}/error.log + ${log.path}/error.log ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 + + 60 ${log.pattern} @@ -50,25 +50,25 @@ ERROR - + ACCEPT - + DENY - - - + + + - - - + + + - + - - + + diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/prod.xml b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/prod.xml index 151a3cb..4a9d602 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/prod.xml +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/prod.xml @@ -1,32 +1,32 @@ - - - + + + - - - ${log.pattern} - - + + + ${log.pattern} + + - - ${log.path}/info.log + + ${log.path}/info.log - + - ${log.path}/info.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + INFO @@ -34,16 +34,16 @@ DENY - + - ${log.path}/error.log + ${log.path}/error.log ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 + + 60 ${log.pattern} @@ -51,9 +51,9 @@ ERROR - + ACCEPT - + DENY @@ -72,17 +72,17 @@ - - - + + + - - - + + + - + - - + + diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/test.xml b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/test.xml index 151a3cb..4a9d602 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/test.xml +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/logback/test.xml @@ -1,32 +1,32 @@ - - - + + + - - - ${log.pattern} - - + + + ${log.pattern} + + - - ${log.path}/info.log + + ${log.path}/info.log - + - ${log.path}/info.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + INFO @@ -34,16 +34,16 @@ DENY - + - ${log.path}/error.log + ${log.path}/error.log ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 + + 60 ${log.pattern} @@ -51,9 +51,9 @@ ERROR - + ACCEPT - + DENY @@ -72,17 +72,17 @@ - - - + + + - - - + + + - + - - + + diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml index ea0616b..fb9800e 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -1,36 +1,58 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column + + select column_id, + table_id, + column_name, + column_comment, + column_type, + java_type, + java_field, + is_pk, + is_increment, + is_required, + is_insert, + is_edit, + is_list, + is_query, + query_type, + html_type, + dict_type, + sort, + create_by, + create_time, + update_by, + update_time + from gen_table_column + select column_name, + (case when (is_nullable = 'no' column_key != 'PRI') then '1' else null end) as is_required, + (case when column_key = 'PRI' then '1' else '0' end) as is_pk, + ordinal_position as sort, + column_comment, + (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, + column_type + from information_schema.columns + where table_schema = (select database()) + and table_name = (#{tableName}) + order by ordinal_position + insert into gen_table_column ( - table_id, - column_name, - column_comment, - column_type, - java_type, - java_field, - is_pk, - is_increment, - is_required, - is_insert, - is_edit, - is_list, - is_query, - query_type, - html_type, - dict_type, - sort, - create_by, - create_time - )values( - #{tableId}, - #{columnName}, - #{columnComment}, - #{columnType}, - #{javaType}, - #{javaField}, - #{isPk}, - #{isIncrement}, - #{isRequired}, - #{isInsert}, - #{isEdit}, - #{isList}, - #{isQuery}, - #{queryType}, - #{htmlType}, - #{dictType}, - #{sort}, - #{createBy}, - sysdate() - ) + table_id, + column_name, + column_comment, + column_type, + java_type, + java_field, + is_pk, + is_increment, + is_required, + is_insert, + is_edit, + is_list, + is_query, + query_type, + html_type, + dict_type, + sort, + create_by, + create_time + )values( + #{tableId}, + #{columnName}, + #{columnComment}, + #{columnType}, + #{javaType}, + #{javaField}, + #{isPk}, + #{isIncrement}, + #{isRequired}, + #{isInsert}, + #{isEdit}, + #{isList}, + #{isQuery}, + #{queryType}, + #{htmlType}, + #{dictType}, + #{sort}, + #{createBy}, + sysdate() + ) @@ -113,20 +141,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from gen_table_column where table_id in ( - + delete from gen_table_column where table_id in + #{tableId} - ) - - delete from gen_table_column where column_id in ( - + delete from gen_table_column where column_id in + #{item.columnId} - ) diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml index ba9b0cf..42ab2cf 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml @@ -1,208 +1,291 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - select table_id, db_name, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table + + + + + + + + + + + + + + + + + + + + + + + + + + + select table_id, + table_name, + table_comment, + sub_table_name, + sub_table_fk_name, + class_name, + tpl_category, + package_name, + module_name, + business_name, + function_name, + function_author, + gen_type, + gen_path, + options, + create_by, + create_time, + update_by, + update_time, + remark + from gen_table - - - - table_schema in (#{dbName}) - - - table_schema = (select database()) - - - - + + + + AND lower(table_name) like lower(concat('%', #{tableName}, '%')) + + + AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) + + + AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') + + + AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') + + + - + select table_name, table_comment, create_time, update_time from information_schema.tables + where table_schema = (select database()) + AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' + AND table_name NOT IN (select table_name from gen_table) + + AND lower(table_name) like lower(concat('%', #{tableName}, '%')) + + + AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) + + + AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') + + + AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') + order by create_time desc - + - + select table_name, table_comment, create_time, update_time from information_schema.tables + where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) + and table_name in + + #{name} - + - + - + - + - - - + SELECT t.table_id, + t.table_name, + t.table_comment, + t.sub_table_name, + t.sub_table_fk_name, + t.class_name, + t.tpl_category, + t.package_name, + t.module_name, + t.business_name, + t.function_name, + t.function_author, + t.options, + t.remark, + c.column_id, + c.column_name, + c.column_comment, + c.column_type, + c.java_type, + c.java_field, + c.is_pk, + c.is_increment, + c.is_required, + c.is_insert, + c.is_edit, + c.is_list, + c.is_query, + c.query_type, + c.html_type, + c.dict_type, + c.sort + FROM gen_table t + LEFT JOIN gen_table_column c ON t.table_id = c.table_id + order by c.sort + - - - - + insert into gen_table ( - db_name, - table_name, - table_comment, - class_name, - tpl_category, - package_name, - module_name, - business_name, - function_name, - function_author, - gen_type, - gen_path, - remark, - create_by, - create_time - )values( - #{dbName}, - #{tableName}, - #{tableComment}, - #{className}, - #{tplCategory}, - #{packageName}, - #{moduleName}, - #{businessName}, - #{functionName}, - #{functionAuthor}, - #{genType}, - #{genPath}, - #{remark}, - #{createBy}, - sysdate() - ) + table_name, + table_comment, + class_name, + tpl_category, + package_name, + module_name, + business_name, + function_name, + function_author, + gen_type, + gen_path, + remark, + create_by, + create_time + )values( + #{tableName}, + #{tableComment}, + #{className}, + #{tplCategory}, + #{packageName}, + #{moduleName}, + #{businessName}, + #{functionName}, + #{functionAuthor}, + #{genType}, + #{genPath}, + #{remark}, + #{createBy}, + sysdate() + ) update gen_table - db_name = #{dbName}, table_name = #{tableName}, table_comment = #{tableComment}, sub_table_name = #{subTableName}, @@ -211,7 +294,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" function_author = #{functionAuthor}, gen_type = #{genType}, gen_path = #{genPath}, - tpl_category = #{tplCategory}, package_name = #{packageName}, + tpl_category = #{tplCategory}, + package_name = #{packageName}, module_name = #{moduleName}, business_name = #{businessName}, function_name = #{functionName}, @@ -224,11 +308,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from gen_table where table_id in ( - + delete from gen_table where table_id in + #{tableId} - ) diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm index c62cc8b..1df5be0 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm @@ -1,9 +1,9 @@ package ${packageName}.controller; -import java.util.Arrays; import java.util.List; +import java.io.IOException; import jakarta.servlet.http.HttpServletResponse; -import javax.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -12,14 +12,14 @@ 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.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; import com.muyu.common.security.annotation.RequiresPermissions; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; 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; #if($table.crud || $table.sub) import com.muyu.common.core.web.page.TableDataInfo; #elseif($table.tree) @@ -35,7 +35,7 @@ import com.muyu.common.core.web.page.TableDataInfo; @RequestMapping("/${businessName}") public class ${ClassName}Controller extends BaseController { - @Resource + @Autowired private I${ClassName}Service ${className}Service; /** @@ -44,14 +44,14 @@ public class ${ClassName}Controller extends BaseController @RequiresPermissions("${permissionPrefix}:list") @GetMapping("/list") #if($table.crud || $table.sub) - public Result> list(${ClassName} ${className}) + public Result list(${ClassName} ${className}) { startPage(); List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return getDataTable(list); } #elseif($table.tree) - public Result<${ClassName}> list(${ClassName} ${className}) + public Result list(${ClassName} ${className}) { List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return success(list); @@ -62,6 +62,7 @@ public class ${ClassName}Controller extends BaseController * 导出${functionName}列表 */ @RequiresPermissions("${permissionPrefix}:export") + @Log(title = "${functionName}", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ${ClassName} ${className}) { @@ -75,7 +76,7 @@ public class ${ClassName}Controller extends BaseController */ @RequiresPermissions("${permissionPrefix}:query") @GetMapping(value = "/{${pkColumn.javaField}}") - public Result> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) + public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); } @@ -84,40 +85,32 @@ public class ${ClassName}Controller extends BaseController * 新增${functionName} */ @RequiresPermissions("${permissionPrefix}:add") + @Log(title = "${functionName}", businessType = BusinessType.INSERT) @PostMapping - public Result add( - @Validated @RequestBody ${ClassName} ${className}) + public Result add(@RequestBody ${ClassName} ${className}) { - if (${className}Service.checkIdUnique(${className})) { - return error("新增 ${functionName} '" + ${className} + "'失败,${functionName}已存在"); - } - ${className}.setCreateBy(SecurityUtils.getUsername()); - return toAjax(${className}Service.save(${className})); + return toAjax(${className}Service.insert${ClassName}(${className})); } /** * 修改${functionName} */ @RequiresPermissions("${permissionPrefix}:edit") + @Log(title = "${functionName}", businessType = BusinessType.UPDATE) @PutMapping - public Result edit( - @Validated @RequestBody ${ClassName} ${className}) + public Result edit(@RequestBody ${ClassName} ${className}) { - if (!${className}Service.checkIdUnique(${className})) { - return error("修改 ${functionName} '" + ${className} + "'失败,${functionName}不存在"); - } - ${className}.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(${className}Service.updateById(${className})); + return toAjax(${className}Service.update${ClassName}(${className})); } /** * 删除${functionName} */ @RequiresPermissions("${permissionPrefix}:remove") + @Log(title = "${functionName}", businessType = BusinessType.DELETE) @DeleteMapping("/{${pkColumn.javaField}s}") - public Result remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s) + public Result remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s) { - ${className}Service.removeBatchByIds(Arrays.asList(${pkColumn.javaField}s)); - return success(); + return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); } } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm index 4c89918..1292991 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm @@ -9,13 +9,6 @@ import com.muyu.common.core.web.domain.BaseEntity; #elseif($table.tree) import com.muyu.common.core.web.domain.TreeEntity; #end -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; /** * ${functionName}对象 ${tableName} @@ -23,20 +16,13 @@ import com.baomidou.mybatisplus.annotation.IdType; * @author ${author} * @date ${datetime} */ - #if($table.crud || $table.sub) #set($Entity="BaseEntity") #elseif($table.tree) #set($Entity="TreeEntity") #end -@Data -@Setter -@Getter -@SuperBuilder -@NoArgsConstructor -@AllArgsConstructor -@TableName("${tableName}") -public class ${ClassName} extends ${Entity}{ +public class ${ClassName} extends ${Entity} +{ private static final long serialVersionUID = 1L; #foreach ($column in $columns) @@ -58,19 +44,33 @@ public class ${ClassName} extends ${Entity}{ @Excel(name = "${comment}") #end #end - #if($column.javaField == $pkColumn.javaField) - @TableId( type = IdType.AUTO) - #end private $column.javaType $column.javaField; #end #end - #if($table.sub) /** $table.subTable.functionName信息 */ private List<${subClassName}> ${subclassName}List; #end +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + public void set${AttrName}($column.javaType $column.javaField) + { + this.$column.javaField = $column.javaField; + } + + public $column.javaType get${AttrName}() + { + return $column.javaField; + } +#end +#end #if($table.sub) public List<${subClassName}> get${subClassName}List() diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm index e6f420b..7e7d7c2 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm @@ -5,16 +5,87 @@ import ${packageName}.domain.${ClassName}; #if($table.sub) import ${packageName}.domain.${subClassName}; #end -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; /** * ${functionName}Mapper接口 - * + * * @author ${author} * @date ${datetime} */ -@Mapper -public interface ${ClassName}Mapper extends BaseMapper<${ClassName}>{ +public interface ${ClassName}Mapper +{ + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 删除${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的数据主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); +#if($table.sub) + + /** + * 批量删除${subTable.functionName} + * + * @param ${pkColumn.javaField}s 需要删除的数据主键集合 + * @return 结果 + */ + public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + + /** + * 批量新增${subTable.functionName} + * + * @param ${subclassName}List ${subTable.functionName}列表 + * @return 结果 + */ + public int batch${subClassName}(List<${subClassName}> ${subclassName}List); + + + /** + * 通过${functionName}主键删除${subTable.functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}ID + * @return 结果 + */ + public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField}); +#end } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm index 1a01fae..264882b 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm @@ -2,18 +2,18 @@ package ${packageName}.service; import java.util.List; import ${packageName}.domain.${ClassName}; -import com.baomidou.mybatisplus.extension.service.IService; /** * ${functionName}Service接口 - * + * * @author ${author} * @date ${datetime} */ -public interface I${ClassName}Service extends IService<${ClassName}> { +public interface I${ClassName}Service +{ /** - * 精确查询${functionName} - * + * 查询${functionName} + * * @param ${pkColumn.javaField} ${functionName}主键 * @return ${functionName} */ @@ -21,17 +21,41 @@ public interface I${ClassName}Service extends IService<${ClassName}> { /** * 查询${functionName}列表 - * + * * @param ${className} ${functionName} * @return ${functionName}集合 */ public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); /** - * 判断 ${functionName} id是否唯一 + * 新增${functionName} + * * @param ${className} ${functionName} * @return 结果 */ - Boolean checkIdUnique(${ClassName} ${className}); + public int insert${ClassName}(${ClassName} ${className}); + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm index 38f1eca..3904af5 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm @@ -7,6 +7,7 @@ import com.muyu.common.core.utils.DateUtils; #break #end #end +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; #if($table.sub) import java.util.ArrayList; @@ -17,10 +18,6 @@ import ${packageName}.domain.${subClassName}; import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; -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; /** * ${functionName}Service业务层处理 @@ -29,12 +26,13 @@ import org.springframework.util.Assert; * @date ${datetime} */ @Service -public class ${ClassName}ServiceImpl - extends ServiceImpl<${ClassName}Mapper, ${ClassName}> - implements I${ClassName}Service { +public class ${ClassName}ServiceImpl implements I${ClassName}Service +{ + @Autowired + private ${ClassName}Mapper ${className}Mapper; /** - * 精确查询${functionName} + * 查询${functionName} * * @param ${pkColumn.javaField} ${functionName}主键 * @return ${functionName} @@ -42,13 +40,9 @@ public class ${ClassName}ServiceImpl @Override public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) { - LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>(); - Assert.notNull(${pkColumn.javaField}, "${pkColumn.javaField}不可为空"); - queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField}); - return this.getOne(queryWrapper); + return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); } - /** * 查询${functionName}列表 * @@ -58,58 +52,118 @@ public class ${ClassName}ServiceImpl @Override public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) { - LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>(); -#foreach($column in $columns) - #set($queryType=$column.queryType) - #set($javaField=$column.javaField) - #set($javaType=$column.javaType) - #set($columnName=$column.columnName) - #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - #if($column.query) - #if($column.queryType == "EQ") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.eq(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #elseif($queryType == "NE") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.ne(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #elseif($queryType == "GT") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.gt(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #elseif($queryType == "GTE") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.ge(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #elseif($queryType == "LT") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.lt(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #elseif($queryType == "LTE") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.le(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #elseif($queryType == "LIKE") - if (StringUtils.isNotEmpty(${className}.get${AttrName}())){ - queryWrapper.like(${ClassName}::get${AttrName}, ${className}.get${AttrName}()); - } - #end - #end -#end - return this.list(queryWrapper); + return ${className}Mapper.select${ClassName}List(${className}); } /** - * 唯一 判断 - * @param ${className} ${functionName} - * @return ${functionName} - */ + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ +#if($table.sub) + @Transactional +#end @Override - public Boolean checkIdUnique(${ClassName} ${className}) { - LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${className}.get${pkColumn.capJavaField}()); - return this.count(queryWrapper) > 0; + public int insert${ClassName}(${ClassName} ${className}) + { +#foreach ($column in $columns) +#if($column.javaField == 'createTime') + ${className}.setCreateTime(DateUtils.getNowDate()); +#end +#end +#if($table.sub) + int rows = ${className}Mapper.insert${ClassName}(${className}); + insert${subClassName}(${className}); + return rows; +#else + return ${className}Mapper.insert${ClassName}(${className}); +#end } + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int update${ClassName}(${ClassName} ${className}) + { +#foreach ($column in $columns) +#if($column.javaField == 'updateTime') + ${className}.setUpdateTime(DateUtils.getNowDate()); +#end +#end +#if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); + insert${subClassName}(${className}); +#end + return ${className}Mapper.update${ClassName}(${className}); + } + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) + { +#if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); +#end + return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s); + } + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) + { +#if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); +#end + return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + } +#if($table.sub) + + /** + * 新增${subTable.functionName}信息 + * + * @param ${className} ${functionName}对象 + */ + public void insert${subClassName}(${ClassName} ${className}) + { + List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); + ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); + if (StringUtils.isNotNull(${subclassName}List)) + { + List<${subClassName}> list = new ArrayList<${subClassName}>(); + for (${subClassName} ${subclassName} : ${subclassName}List) + { + ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); + list.add(${subclassName}); + } + if (list.size() > 0) + { + ${className}Mapper.batch${subClassName}(list); + } + } + } +#end } diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm index 61c6273..a5c170c 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm @@ -17,7 +17,8 @@ import com.muyu.common.core.web.domain.BaseEntity; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) -public class ${subClassName} extends BaseEntity { +public class ${subClassName} extends BaseEntity +{ private static final long serialVersionUID = 1L; #foreach ($column in $subTable.columns) diff --git a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm index cf9b3b0..6296014 100644 --- a/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm +++ b/cloud-server/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm @@ -170,7 +170,7 @@ - +