Przeglądaj źródła

【移除】 基础服务合并的原modules

linfutong 3 lat temu
rodzic
commit
a148f87ba2
100 zmienionych plików z 0 dodań i 8386 usunięć
  1. 0 1
      zd-common/pom.xml
  2. 0 4
      zd-modules/pom.xml
  3. 0 10
      zd-modules/zd-message/Dockerfile
  4. 0 155
      zd-modules/zd-message/pom.xml
  5. 0 28
      zd-modules/zd-message/src/main/java/com/zd/message/ZdMessageApplication.java
  6. 0 31
      zd-modules/zd-message/src/main/java/com/zd/message/base/FridConsumer.java
  7. 0 130
      zd-modules/zd-message/src/main/java/com/zd/message/controller/UserOpenIdController.java
  8. 0 33
      zd-modules/zd-message/src/main/java/com/zd/message/controller/WXTokenController.java
  9. 0 138
      zd-modules/zd-message/src/main/java/com/zd/message/controller/WechatMsgController.java
  10. 0 30
      zd-modules/zd-message/src/main/java/com/zd/message/domain/UserOpenId.java
  11. 0 77
      zd-modules/zd-message/src/main/java/com/zd/message/mapper/UserOpenIdMapper.java
  12. 0 108
      zd-modules/zd-message/src/main/java/com/zd/message/properties/WeChatProperties.java
  13. 0 17
      zd-modules/zd-message/src/main/java/com/zd/message/service/ISendService.java
  14. 0 84
      zd-modules/zd-message/src/main/java/com/zd/message/service/IUserOpenIdService.java
  15. 0 65
      zd-modules/zd-message/src/main/java/com/zd/message/service/IWechatMsgSendService.java
  16. 0 21
      zd-modules/zd-message/src/main/java/com/zd/message/service/impl/SendServiceImpl.java
  17. 0 143
      zd-modules/zd-message/src/main/java/com/zd/message/service/impl/UserOpenIdServiceImpl.java
  18. 0 283
      zd-modules/zd-message/src/main/java/com/zd/message/service/impl/WechatMsgSendServiceImpl.java
  19. 0 49
      zd-modules/zd-message/src/main/java/com/zd/message/utils/SHA1.java
  20. 0 26
      zd-modules/zd-message/src/main/java/com/zd/message/utils/WXPublicUtils.java
  21. 0 10
      zd-modules/zd-message/src/main/resources/banner.txt
  22. 0 29
      zd-modules/zd-message/src/main/resources/bootstrap.yml
  23. BIN
      zd-modules/zd-message/src/main/resources/libs/connect-lib.jar
  24. BIN
      zd-modules/zd-message/src/main/resources/libs/reader-lib.jar
  25. 0 74
      zd-modules/zd-message/src/main/resources/logback.xml
  26. 0 78
      zd-modules/zd-message/src/main/resources/mapper/message/UserOpenIdMapper.xml
  27. 0 182
      zd-modules/zd-message/wait-for-it.sh
  28. 0 10
      zd-modules/zd-modules-file/Dockerfile
  29. 0 117
      zd-modules/zd-modules-file/pom.xml
  30. 0 20
      zd-modules/zd-modules-file/src/main/java/com/zd/ZdFileApplication.java
  31. 0 43
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/config/RedisConfig.java
  32. 0 71
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/controller/UploadController.java
  33. 0 124
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/dto/FileChunkDTO.java
  34. 0 46
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/dto/FileChunkResultDTO.java
  35. 0 75
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/RestApiResponse.java
  36. 0 29
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/error/BaseErrorCode.java
  37. 0 42
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/error/BusinessErrorCode.java
  38. 0 34
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/error/BusinessException.java
  39. 0 45
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/service/IUploadService.java
  40. 0 306
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/service/impl/UploadServiceImpl.java
  41. 0 64
      zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/utils/FileUtils.java
  42. 0 74
      zd-modules/zd-modules-file/src/main/java/com/zd/file/config/MinioConfig.java
  43. 0 51
      zd-modules/zd-modules-file/src/main/java/com/zd/file/config/ResourcesConfig.java
  44. 0 43
      zd-modules/zd-modules-file/src/main/java/com/zd/file/controller/SysFileController.java
  45. 0 40
      zd-modules/zd-modules-file/src/main/java/com/zd/file/service/FastDfsSysFileServiceImpl.java
  46. 0 19
      zd-modules/zd-modules-file/src/main/java/com/zd/file/service/ISysFileService.java
  47. 0 55
      zd-modules/zd-modules-file/src/main/java/com/zd/file/service/LocalSysFileServiceImpl.java
  48. 0 43
      zd-modules/zd-modules-file/src/main/java/com/zd/file/service/MinioSysFileServiceImpl.java
  49. 0 201
      zd-modules/zd-modules-file/src/main/java/com/zd/file/utils/FileUploadUtils.java
  50. 0 124
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/ActionEnter.java
  51. 0 160
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/ConfigManager.java
  52. 0 18
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/Encoder.java
  53. 0 131
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/PathFormat.java
  54. 0 23
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/SpringUtil.java
  55. 0 56
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/contorller/UeditorController.java
  56. 0 34
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/ActionMap.java
  57. 0 8
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/ActionState.java
  58. 0 52
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/AppInfo.java
  59. 0 90
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/BaseState.java
  60. 0 24
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/FileType.java
  61. 0 23
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/MIMEType.java
  62. 0 88
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/MultiState.java
  63. 0 11
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/State.java
  64. 0 102
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/hunter/FileManager.java
  65. 0 111
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/hunter/ImageHunter.java
  66. 0 38
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/Base64Uploader.java
  67. 0 65
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/BinaryUploader.java
  68. 0 120
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/StorageManager.java
  69. 0 60
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/UploadUtils.java
  70. 0 29
      zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/Uploader.java
  71. 0 10
      zd-modules/zd-modules-file/src/main/resources/banner.txt
  72. 0 26
      zd-modules/zd-modules-file/src/main/resources/bootstrap.yml
  73. 0 68
      zd-modules/zd-modules-file/src/main/resources/config.json
  74. 0 74
      zd-modules/zd-modules-file/src/main/resources/logback.xml
  75. 0 182
      zd-modules/zd-modules-file/wait-for-it.sh
  76. 0 10
      zd-modules/zd-modules-gen/Dockerfile
  77. 0 105
      zd-modules/zd-modules-gen/pom.xml
  78. 0 24
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/ZdGenApplication.java
  79. 0 65
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/config/GenConfig.java
  80. 0 195
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/controller/GenController.java
  81. 0 363
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/domain/GenTable.java
  82. 0 362
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/domain/GenTableColumn.java
  83. 0 60
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/mapper/GenTableColumnMapper.java
  84. 0 83
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/mapper/GenTableMapper.java
  85. 0 64
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/GenTableColumnServiceImpl.java
  86. 0 438
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/GenTableServiceImpl.java
  87. 0 44
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/IGenTableColumnService.java
  88. 0 121
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/IGenTableService.java
  89. 0 223
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/util/GenUtils.java
  90. 0 31
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/util/VelocityInitializer.java
  91. 0 328
      zd-modules/zd-modules-gen/src/main/java/com/zd/gen/util/VelocityUtils.java
  92. 0 10
      zd-modules/zd-modules-gen/src/main/resources/banner.txt
  93. 0 25
      zd-modules/zd-modules-gen/src/main/resources/bootstrap.yml
  94. 0 74
      zd-modules/zd-modules-gen/src/main/resources/logback.xml
  95. 0 133
      zd-modules/zd-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml
  96. 0 202
      zd-modules/zd-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml
  97. 0 127
      zd-modules/zd-modules-gen/src/main/resources/vm/java/controller.java.vm
  98. 0 115
      zd-modules/zd-modules-gen/src/main/resources/vm/java/domain.java.vm
  99. 0 99
      zd-modules/zd-modules-gen/src/main/resources/vm/java/mapper.java.vm
  100. 0 0
      zd-modules/zd-modules-gen/src/main/resources/vm/java/service.java.vm

+ 0 - 1
zd-common/pom.xml

@@ -19,7 +19,6 @@
         <module>zd-common-security</module>
 		<module>zd-common-datasource</module>
         <module>zd-common-mqtt</module>
-        <module>zd-common-datascope</module>
     </modules>
 
 </project>

+ 0 - 4
zd-modules/pom.xml

@@ -13,9 +13,6 @@
 
     <modules>
         <module>zd-modules-system</module>
-        <module>zd-modules-gen</module>
-        <module>zd-modules-job</module>
-        <module>zd-modules-file</module>
         <module>zd-exam</module>
         <module>zd-modules-laboratory</module>
         <module>zd-modules-app</module>
@@ -26,7 +23,6 @@
         <module>zd-airbottle</module>
         <module>zd-chemical</module>
         <module>zd-speaker</module>
-        <module>zd-message</module>
         <module>zd-netty</module>
         <module>zd-smartlock</module>
         <module>zd-bottle-parent</module>

Plik diff jest za duży
+ 0 - 10
zd-modules/zd-message/Dockerfile


+ 0 - 155
zd-modules/zd-message/pom.xml

@@ -1,155 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>zd-modules</artifactId>
-        <groupId>com.zd</groupId>
-        <version>3.1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>zd-message</artifactId>
-    <packaging>jar</packaging>
-    <description>消息服务</description>
-
-    <properties>
-        <maven.compiler.source>8</maven.compiler.source>
-        <maven.compiler.target>8</maven.compiler.target>
-    </properties>
-    <dependencies>
-        <!-- SpringCloud Alibaba Nacos -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Nacos Config -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Nacos Config -->
-
-        <dependency>
-            <groupId>com.alibaba.nacos</groupId>
-            <artifactId>nacos-spring-context</artifactId>
-            <version>0.2.3-RC1</version>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
-        </dependency>
-
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
-
-        <!-- Swagger UI -->
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>${swagger.fox.version}</version>
-        </dependency>
-
-        <!-- Mysql Connector -->
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-
-        <!-- zd Common DataSource -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-datasource</artifactId>
-        </dependency>
-
-        <!-- zd Common DataScope -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-datascope</artifactId>
-        </dependency>
-
-        <!-- zd Common Log -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-log</artifactId>
-        </dependency>
-
-        <!-- zd Common Swagger -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-swagger</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.junit.vintage</groupId>
-                    <artifactId>junit-vintage-engine</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-resultdata</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.projectlombok</groupId>
-            <artifactId>lombok</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>connect</groupId>
-            <artifactId>connect-lib</artifactId>
-            <version>1.0.0</version>
-            <scope>system</scope>
-            <systemPath>${project.basedir}/src/main/resources/libs/connect-lib.jar</systemPath>
-        </dependency>
-        <dependency>
-            <groupId>reader</groupId>
-            <artifactId>reader-lib</artifactId>
-            <version>1.0.0</version>
-            <scope>system</scope>
-            <systemPath>${project.basedir}/src/main/resources/libs/reader-lib.jar</systemPath>
-        </dependency>
-    </dependencies>
-    <build>
-        <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <includeSystemScope>true</includeSystemScope>
-                    <fork>true</fork>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 28
zd-modules/zd-message/src/main/java/com/zd/message/ZdMessageApplication.java

@@ -1,28 +0,0 @@
-package com.zd.message;
-
-import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
-import com.zd.common.security.annotation.EnableCustomConfig;
-import com.zd.common.security.annotation.EnableRyFeignClients;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-/**
- * Controller
- *
- * @author cyl
- * @date 2022/5/9
- */
-@EnableCustomConfig
-@EnableRyFeignClients
-@SpringBootApplication
-@EnableScheduling
-@NacosPropertySource(dataId = "zd-message", autoRefreshed = true)
-@Slf4j
-public class ZdMessageApplication {
-    public static void main(String[] args) {
-        SpringApplication.run(ZdMessageApplication.class, args);
-        log.info("(♥◠‿◠)ノ゙  消息模块启动成功   ლ(´ڡ`ლ)゙");
-    }
-}

+ 0 - 31
zd-modules/zd-message/src/main/java/com/zd/message/base/FridConsumer.java

@@ -1,31 +0,0 @@
-package com.zd.message.base;
-
-import com.payne.reader.base.Consumer;
-import com.payne.reader.bean.receive.InventoryTag;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.message.service.ISendService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Slf4j
-@Component
-public class FridConsumer implements Consumer<InventoryTag> {
-
-    @Autowired
-    private ISendService sendService;
-
-    @Override
-    public void accept(InventoryTag tag) {
-        try {
-            tag.setEpc(tag.getEpc().replace(" ", ""));
-            com.zd.system.api.domain.InventoryTag  inventoryTag = new com.zd.system.api.domain.InventoryTag ();
-            BeanUtils.copyProperties(tag,inventoryTag);
-            sendService.send(inventoryTag);
-        } catch (BeansException e) {
-            throw new ServiceException(e.getMessage());
-        }
-    }
-}

+ 0 - 130
zd-modules/zd-message/src/main/java/com/zd/message/controller/UserOpenIdController.java

@@ -1,130 +0,0 @@
-package com.zd.message.controller;
-
-import java.util.List;
-import java.io.IOException;
-import javax.servlet.http.HttpServletResponse;
-
-import com.zd.common.core.domain.R;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.message.domain.UserOpenId;
-import com.zd.message.service.IUserOpenIdService;
-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.zd.common.response.ResultData;
-import com.zd.common.log.annotation.Log;
-import com.zd.common.log.enums.BusinessType;
-import com.zd.common.security.annotation.PreAuthorize;
-import com.zd.common.core.web.controller.BaseController;
-import com.zd.common.core.utils.poi.ExcelUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-
-import com.zd.common.core.web.page.TableDataInfo;
-
-/**
- * 用户和微信openID对应表Controller
- *
- * @author hanson
- */
-@RestController
-@Api(tags = "【用户和微信openID对应表】")
-@RequestMapping("/user/wx")
-public class UserOpenIdController extends BaseController<UserOpenId> {
-    @Autowired
-    private IUserOpenIdService userOpenIdService;
-
-    /**
-     * 查询用户和微信openID对应表列表
-     */
-    @GetMapping("/list")
-    @ApiOperation(value = "查询用户和微信openID对应表列表")
-    public TableDataInfo<UserOpenId> list(UserOpenId userOpenId) {
-        startPage();
-        List<UserOpenId> list = userOpenIdService.selectUserOpenIdList(userOpenId);
-        return getDataTable(list);
-    }
-
-    /**
-     * 导出用户和微信openID对应表列表
-     */
-    @ApiOperation(value = "导出用户和微信openID对应表列表")
-    @Log(title = "用户和微信openID对应表", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, UserOpenId userOpenId) throws IOException {
-        List<UserOpenId> list = userOpenIdService.selectUserOpenIdList(userOpenId);
-        ExcelUtil<UserOpenId> util = new ExcelUtil<>(UserOpenId.class);
-        util.exportExcel(response, list, "用户和微信openID对应表数据");
-    }
-
-    /**
-     * 获取用户和微信openID对应表详细信息
-     */
-    @ApiOperation(value = "获取用户和微信openID对应表详细信息")
-    @GetMapping(value = "/{id}")
-    public ResultData<UserOpenId> getInfo(@PathVariable("id") Long id) {
-        return ResultData.success(userOpenIdService.selectUserOpenIdById(id));
-    }
-
-    /**
-     * 获取用户和微信openID对应表详细信息
-     */
-    @ApiOperation(value = "获取用户和微信openID对应表详细信息")
-    @GetMapping(value = "openId/{userId}")
-    public R<String> getOpenIdByUserId(@PathVariable("userId") Long userId) {
-        UserOpenId openId = new UserOpenId();
-        openId.setUserId(userId);
-        List<UserOpenId> list = userOpenIdService.selectUserOpenIdList(openId);
-        if (list.size() != 1) {
-            throw new ServiceException("用户关联错误");
-        }
-        UserOpenId userOpenId = list.get(0);
-        return R.ok(userOpenId.getOpenId());
-    }
-
-    /**
-     * 根据小程序端传回的code,获取openId
-     */
-    @ApiOperation(value = "获取openID")
-    @Log(title = "获取openID", businessType = BusinessType.INSERT)
-    @GetMapping("getOpenId")
-    public ResultData<UserOpenId> getOpenId(String code) {
-        return ResultData.success(userOpenIdService.getOpenId(code));
-    }
-    /**
-     * 新增用户和微信openID对应表
-     */
-    @ApiOperation(value = "新增用户和微信openID对应表")
-    @Log(title = "用户和微信openID对应表", businessType = BusinessType.INSERT)
-    @PostMapping
-    public ResultData<Boolean> add(@RequestBody UserOpenId userOpenId) {
-        return ResultData.result(userOpenIdService.insertUserOpenId(userOpenId));
-    }
-
-    /**
-     * 修改用户和微信openID对应表
-     */
-    @ApiOperation(value = "修改用户和微信openID对应表")
-    @Log(title = "用户和微信openID对应表", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public ResultData<Boolean> edit(@RequestBody UserOpenId userOpenId) {
-        return ResultData.result(userOpenIdService.updateUserOpenId(userOpenId));
-    }
-
-    /**
-     * 删除用户和微信openID对应表
-     */
-    @ApiOperation(value = "删除用户和微信openID对应表")
-    @PreAuthorize(hasPermi = "airbottle:id:remove")
-    @Log(title = "用户和微信openID对应表", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{ids}")
-    public ResultData<Boolean> remove(@PathVariable Long[] ids) {
-        return ResultData.result(userOpenIdService.deleteUserOpenIdByIds(ids));
-    }
-}

+ 0 - 33
zd-modules/zd-message/src/main/java/com/zd/message/controller/WXTokenController.java

@@ -1,33 +0,0 @@
-package com.zd.message.controller;
-
-import com.zd.message.properties.WeChatProperties;
-import com.zd.message.utils.WXPublicUtils;
-import io.swagger.annotations.Api;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-
-@RestController
-@RequestMapping("/wx")
-@Api(tags = "验证公众平台token")
-@Slf4j
-public class WXTokenController {
-
-    @Autowired
-    private WeChatProperties properties;
-
-    @RequestMapping("/verify")
-    public String verifyWXToken(HttpServletRequest request) {
-        String msgSignature = request.getParameter("signature");
-        String msgTimestamp = request.getParameter("timestamp");
-        String msgNonce = request.getParameter("nonce");
-        String echostr = request.getParameter("echostr");
-        if (WXPublicUtils.verifyUrl(msgSignature, msgTimestamp, msgNonce,properties.getToken())) {
-            return echostr;
-        }
-        return null;
-    }
-}

+ 0 - 138
zd-modules/zd-message/src/main/java/com/zd/message/controller/WechatMsgController.java

@@ -1,138 +0,0 @@
-package com.zd.message.controller;
-
-import com.zd.common.core.domain.R;
-import com.zd.common.core.template.TemplateResult;
-import com.zd.common.response.ResultData;
-import com.zd.message.service.IWechatMsgSendService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Date;
-import java.util.List;
-
-@RestController
-@Api(tags = "微信模板消息发送")
-@RequestMapping("/wx")
-public class WechatMsgController {
-
-    @Autowired
-    private IWechatMsgSendService sendService;
-
-    /**
-     * 待办事项消息发送
-     */
-    @GetMapping("/list")
-    @ApiOperation(value = "订阅列表查询")
-    public ResultData<List<String>> list() {
-        return ResultData.success(sendService.getList());
-    }
-
-    /**
-     * 待办事项消息发送
-     * @param backlogName 待办事项名称
-     * @param remark 备注
-     * @return TemplateResult
-     */
-    @GetMapping("/backlog")
-    @ApiOperation(value = "待办事项消息发送")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "backlogName",value = "待办事项名称"),
-            @ApiImplicitParam(name = "remark",value = "备注")
-    })
-    public R<TemplateResult> backlog(Long userId, String backlogName, String remark) {
-        return  R.ok(sendService.sendBacklogResult(userId,backlogName,remark));
-    }
-
-    /**
-     * 资格申请、用气申请通知发送
-     * @param checkType 审核类型 1:资格申请 2:用气申请
-     * @param checkStatus 审核状态
-     * @param checkTime 审核时间
-     * @return TemplateResult 通知发送结果
-     */
-    @GetMapping("/check")
-    @ApiOperation(value = "审核消息发送")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "checkType",value = "审核类型 1:资格申请 2:用气申请"),
-            @ApiImplicitParam(name = "checkStatus",value = "审核状态 1:通过 2:已驳回"),
-            @ApiImplicitParam(name = "checkTime",value = "审核时间")
-    })
-    public R<TemplateResult> check(Long userId,Integer checkType, Integer checkStatus, Date checkTime,Long taskId) {
-        return R.ok(sendService.sendCheckResult(userId,checkType,checkStatus,checkTime,taskId));
-    }
-
-    /**
-     * 资格申请、用气申请通知发送
-     * @param checkType 审核类型 1:资格申请 2:用气申请
-     * @param checkStatus 审核状态
-     * @param checkTime 审核时间
-     * @return TemplateResult 通知发送结果
-     */
-    @GetMapping("stu/check")
-    @ApiOperation(value = "学生端审核消息发送")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "checkType",value = "审核类型 1:资格申请 2:用气申请"),
-            @ApiImplicitParam(name = "checkStatus",value = "审核状态 1:通过 2:已驳回"),
-            @ApiImplicitParam(name = "checkTime",value = "审核时间")
-    })
-    public R<TemplateResult> stuCheck(Long userId,Integer checkType, Integer checkStatus, Date checkTime,Long taskId) {
-        return R.ok(sendService.sendStuCheckResult(userId,checkType,checkStatus,checkTime,taskId));
-    }
-
-    /**
-     * 出库确认通知
-     *
-     * @param outType 出库类型
-     * @param outTime   出库时间
-     * @return TemplateResult 通知发送结果
-     */
-    @GetMapping("/storage/out")
-    @ApiOperation(value = "出库确认通知")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "outType",value = "出库类型"),
-            @ApiImplicitParam(name = "outTime",value = "出库时间")
-    })
-    public R<TemplateResult> storageOut(Long userId,String outType, Date outTime) {
-        return R.ok(sendService.sendStorageOutResult(userId,outType,outTime));
-    }
-
-    /**
-     * 资格申请、用气申请待审核通知发送
-     *
-     * @param checkType   审核类型 1:资格申请 2:用气申请
-     * @param name 申请人
-     * @param applyTime   申请时间
-     * @return TemplateResult 通知发送结果
-     */
-    @GetMapping("/wait/check")
-    @ApiOperation(value = "待审核消息发送")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "checkType",value = "审核类型 1:资格申请 2:用气申请"),
-            @ApiImplicitParam(name = "name",value = "申请人"),
-            @ApiImplicitParam(name = "applyTime",value = "申请时间")
-    })
-    public R<TemplateResult> waitCheck(Long userId,Integer checkType,String name, Date applyTime) {
-        return R.ok(sendService.sendWaitCheckResult(userId,checkType,name,applyTime));
-    }
-
-    /**
-     * 设备报警通知发送
-     *
-     * @param userIds   上报接收人
-     * @param address 报警位置
-     * @return TemplateResult 通知发送结果
-     */
-    @PostMapping("/send/alarm")
-    @ApiOperation(value = "气瓶超出范围通知")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "userIds",value = "上报接收人"),
-            @ApiImplicitParam(name = "address",value = "报警位置")
-    })
-    public R<TemplateResult> sendAlarm(@RequestBody List<Long> userIds, @RequestParam("address") String address) {
-        return R.ok(sendService.sendAlarm(userIds,address));
-    }
-}

+ 0 - 30
zd-modules/zd-message/src/main/java/com/zd/message/domain/UserOpenId.java

@@ -1,30 +0,0 @@
-package com.zd.message.domain;
-
-import com.zd.common.core.web.domain.BaseEntity;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.ToString;
-import lombok.experimental.Accessors;
-
-/**
- * 用户和微信openID对应表对象 sys_user_open_id
- * 
- * @author hanson
- */
-@ApiModel("用户和微信openID对应表")
-@Data
-@Accessors(chain = true)
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = false)
-public class UserOpenId extends BaseEntity
-{
-    private static final long serialVersionUID = 1L;
-
-    @ApiModelProperty(value = "${comment}")
-    private Long id;
-    @ApiModelProperty(value = "微信openId")
-    private String openId;
-
-}

+ 0 - 77
zd-modules/zd-message/src/main/java/com/zd/message/mapper/UserOpenIdMapper.java

@@ -1,77 +0,0 @@
-package com.zd.message.mapper;
-
-
-import com.zd.message.domain.UserOpenId;
-
-import java.util.List;
-
-/**
- * 用户和微信openID对应表Mapper接口
- * 
- * @author hanson
- */
-public interface UserOpenIdMapper 
-{
-    /**
-     * 查询用户和微信openID对应表
-     * 
-     * @param id 用户和微信openID对应表主键
-     * @return 用户和微信openID对应表
-     */
-    UserOpenId selectUserOpenIdById(Long id);
-
-    /**
-     * 查询用户和微信openID对应表列表
-     * 
-     * @param userOpenId 用户和微信openID对应表
-     * @return 用户和微信openID对应表集合
-     */
-    List<UserOpenId> selectUserOpenIdList(UserOpenId userOpenId);
-
-    /**
-     * 根据主键集合查询用户和微信openID对应表列表
-     *
-     * @param ids 主键集合
-     * @return 用户和微信openID对应表集合
-     */
-    List<UserOpenId> getListByIds(List<Long> ids);
-
-    /**
-     * 新增用户和微信openID对应表
-     * 
-     * @param userOpenId 用户和微信openID对应表
-     * @return 结果
-     */
-    int insertUserOpenId(UserOpenId userOpenId);
-
-    /**
-     * 修改用户和微信openID对应表
-     * 
-     * @param userOpenId 用户和微信openID对应表
-     * @return 结果
-     */
-    int updateUserOpenId(UserOpenId userOpenId);
-
-    /**
-     * 删除用户和微信openID对应表
-     * 
-     * @param id 用户和微信openID对应表主键
-     * @return 结果
-     */
-    int deleteUserOpenIdById(Long id);
-
-    /**
-     * 批量删除用户和微信openID对应表
-     * 
-     * @param ids 需要删除的数据主键集合
-     * @return 结果
-     */
-    int deleteUserOpenIdByIds(Long[] ids);
-
-    /**
-     * 根据用户ID查询openID
-     * @param userId 用户ID
-     * @return UserOpenId
-     */
-    UserOpenId getByUserId(Long userId);
-}

+ 0 - 108
zd-modules/zd-message/src/main/java/com/zd/message/properties/WeChatProperties.java

@@ -1,108 +0,0 @@
-package com.zd.message.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * 微信小程序属性配置
- */
-@RefreshScope
-@Data
-@Component
-@ConfigurationProperties(prefix = "sys.wx")
-public class WeChatProperties {
-
-    /**
-     * 小程序唯一凭证,即 AppID,可在「微信公众平台 - 设置 - 开发设置」页中获得。(需要已经成为开发者,且帐号没有异常状态)
-     */
-    private String appId;
-    /**
-     * 小程序唯一凭证密钥,即 AppSecret,获取方式同 appid
-     */
-    private String secret;
-
-    /**
-     * 微信消息推送地址,默认为:"<a href="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN">https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN</a>"
-     */
-    private String url;
-    /**
-     * 获取微信openID地址
-     */
-    private String openIdUrl;
-
-    /**
-     * 获取微信token地址
-     */
-    private String tokenUrl;
-
-    /**
-     * 出库确认消息模板ID
-     */
-    private String storageOutTemplateId;
-
-    /**
-     * 待审核消息模板ID
-     */
-    private String waitCheckTemplateId;
-
-    /**
-     * 设备报警消息模板ID
-     */
-    private String deviceAlarmTemplateId;
-
-    /**
-     * 用气待审核跳转微信小程序地址
-     */
-    private String waitCheckUrl;
-
-    private String initPage="pages/login";
-
-    /**
-     * 待办事项消息模板ID
-     */
-    private String backlogTemplateId;
-    /**
-     * 待办事项跳转微信小程序地址
-     */
-    private String backlogUrl;
-
-    /**
-     * 资格申请、用气申请消息模板ID
-     */
-    private String checkTemplateId;
-
-    /**
-     * 用气申请跳转微信小程序地址
-     */
-    private String airCheckUrl;
-
-    /**
-     * 学生端用气申请跳转微信小程序地址
-     */
-    private String stuAirCheckUrl;
-
-    /**
-     * 资格申请跳转微信小程序地址
-     */
-    private String qualificationCheckUrl;
-
-    /**
-     * 学生段端资格申请跳转微信小程序地址
-     */
-    private String stuQualificationCheckUrl;
-
-    /**
-     * Token(令牌),微信小程序消息推送配置的token值
-     */
-    private String token;
-
-    /**
-     * 模板ID集合
-     */
-    private List<String> templateIds;
-
-}

+ 0 - 17
zd-modules/zd-message/src/main/java/com/zd/message/service/ISendService.java

@@ -1,17 +0,0 @@
-package com.zd.message.service;
-
-import com.zd.system.api.domain.InventoryTag;
-
-public interface ISendService {
-
-    /**
-     * 发送读取到的编码
-     * @param tag frid数据
-     */
-    void send(InventoryTag tag);
-    /**
-     * 发送异常信息
-     * @param msg 异常消息
-     */
-    void sendError(String msg);
-}

+ 0 - 84
zd-modules/zd-message/src/main/java/com/zd/message/service/IUserOpenIdService.java

@@ -1,84 +0,0 @@
-package com.zd.message.service;
-
-import com.zd.message.domain.UserOpenId;
-
-import java.util.List;
-
-/**
- * 用户和微信openID对应表Service接口
- * 
- * @author hanson
- * @date 2022-06-10
- */
-public interface IUserOpenIdService 
-{
-    /**
-     * 查询用户和微信openID对应表
-     * 
-     * @param id 用户和微信openID对应表主键
-     * @return 用户和微信openID对应表
-     */
-    UserOpenId selectUserOpenIdById(Long id);
-
-    /**
-     * 查询用户和微信openID对应表列表
-     * 
-     * @param userOpenId 用户和微信openID对应表
-     * @return 用户和微信openID对应表集合
-     */
-    List<UserOpenId> selectUserOpenIdList(UserOpenId userOpenId);
-
-    /**
-     * 根据主键集合查询用户和微信openID对应表列表
-     *
-     * @param ids 主键集合
-     * @return 用户和微信openID对应表集合
-     */
-    List<UserOpenId> getListByIds(List<Long> ids);
-
-    /**
-     * 新增用户和微信openID对应表
-     * 
-     * @param userOpenId 用户和微信openID对应表
-     * @return 结果
-     */
-    int insertUserOpenId(UserOpenId userOpenId);
-
-    /**
-     * 修改用户和微信openID对应表
-     * 
-     * @param userOpenId 用户和微信openID对应表
-     * @return 结果
-     */
-    int updateUserOpenId(UserOpenId userOpenId);
-
-    /**
-     * 批量删除用户和微信openID对应表
-     * 
-     * @param ids 需要删除的用户和微信openID对应表主键集合
-     * @return 结果
-     */
-    int deleteUserOpenIdByIds(Long[] ids);
-
-    /**
-     * 删除用户和微信openID对应表信息
-     * 
-     * @param id 用户和微信openID对应表主键
-     * @return 结果
-     */
-    int deleteUserOpenIdById(Long id);
-
-    /**
-     * 根据小程序端传回的code,获取openId
-     * @param code 小程序端传回的code
-     * @return openId
-     */
-    UserOpenId getOpenId(String code);
-
-    /**
-     * 根据用户ID查询openID
-     * @param userId 用户ID
-     * @return UserOpenId
-     */
-    UserOpenId getByUserId(Long userId);
-}

+ 0 - 65
zd-modules/zd-message/src/main/java/com/zd/message/service/IWechatMsgSendService.java

@@ -1,65 +0,0 @@
-package com.zd.message.service;
-
-import com.zd.common.core.template.TemplateResult;
-
-import java.util.Date;
-import java.util.List;
-
-public interface IWechatMsgSendService {
-
-    /**
-     * 资格申请、用气申请通知发送
-     *
-     * @param userId 目标用户ID
-     * @param checkType   审核类型 1:资格申请 2:用气申请
-     * @param checkStatus 审核状态
-     * @param checkTime   审核时间
-     * @param taskId 任务ID
-     * @return TemplateResult 通知发送结果
-     */
-    TemplateResult sendCheckResult(Long userId, Integer checkType, Integer checkStatus, Date checkTime, Long taskId);
-
-    /**
-     * 根据小程序端传回的code,获取openId
-     * @param code 小程序端传回的code
-     * @return openId
-     */
-    String getOpenId(String code);
-
-    /**
-     * 出库确认通知
-     *
-     * @param userId 目标用户ID
-     * @param outType 出库类型
-     * @param outTime 出库时间
-     * @return TemplateResult 通知发送结果
-     */
-    TemplateResult sendStorageOutResult(Long userId, String outType, Date outTime);
-
-    /**
-     * 资格申请、用气申请待审核通知发送
-     *
-     * @param userId 目标用户ID
-     * @param checkType 审核类型 1:资格申请 2:用气申请
-     * @param name      申请人
-     * @param applyTime 申请时间
-     * @return TemplateResult 通知发送结果
-     */
-    TemplateResult sendWaitCheckResult(Long userId, Integer checkType, String name, Date applyTime);
-
-    /**
-     * 待办事项通知发送
-     *
-     * @param userId 目标用户ID
-     * @param backlogName 待办事项名称
-     * @param remark      备注
-     * @return TemplateResult 通知发送结果
-     */
-    TemplateResult sendBacklogResult(Long userId, String backlogName, String remark);
-
-    List<String> getList();
-
-    TemplateResult sendStuCheckResult(Long userId, Integer checkType, Integer checkStatus, Date checkTime, Long taskId);
-
-    TemplateResult sendAlarm(List<Long> userIds,String address);
-}

+ 0 - 21
zd-modules/zd-message/src/main/java/com/zd/message/service/impl/SendServiceImpl.java

@@ -1,21 +0,0 @@
-package com.zd.message.service.impl;
-
-import com.zd.message.service.ISendService;
-import com.zd.system.api.domain.InventoryTag;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-@Slf4j
-@Service
-public class SendServiceImpl implements ISendService {
-
-    @Override
-    public void send(InventoryTag tag) {
-        log.info("==============================================reader1 inventory tag :" + tag.toString());
-    }
-
-    @Override
-    public void sendError(String msg) {
-        log.info(msg);
-    }
-}

+ 0 - 143
zd-modules/zd-message/src/main/java/com/zd/message/service/impl/UserOpenIdServiceImpl.java

@@ -1,143 +0,0 @@
-package com.zd.message.service.impl;
-
-import com.zd.common.core.exception.ServiceException;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.common.security.service.TokenService;
-import com.zd.message.domain.UserOpenId;
-import com.zd.message.mapper.UserOpenIdMapper;
-import com.zd.message.service.IUserOpenIdService;
-import com.zd.message.service.IWechatMsgSendService;
-import com.zd.system.api.model.LoginUser;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 用户和微信openID对应表Service业务层处理
- *
- * @author hanson
- */
-@Service
-public class UserOpenIdServiceImpl implements IUserOpenIdService {
-    @Resource
-    private UserOpenIdMapper userOpenIdMapper;
-    @Resource
-    private IWechatMsgSendService wechatMsgSendService;
-
-    @Resource
-    private TokenService tokenService;
-
-    /**
-     * 查询用户和微信openID对应表
-     *
-     * @param id 用户和微信openID对应表主键
-     * @return 用户和微信openID对应表
-     */
-    @Override
-    public UserOpenId selectUserOpenIdById(Long id) {
-        return userOpenIdMapper.selectUserOpenIdById(id);
-    }
-
-    /**
-     * 查询用户和微信openID对应表列表
-     *
-     * @param userOpenId 用户和微信openID对应表
-     * @return 用户和微信openID对应表
-     */
-    @Override
-    public List<UserOpenId> selectUserOpenIdList(UserOpenId userOpenId) {
-        return userOpenIdMapper.selectUserOpenIdList(userOpenId);
-    }
-
-    @Override
-    public List<UserOpenId> getListByIds(List<Long> ids) {
-        if (ids.isEmpty()) {
-            new ArrayList<>();
-        }
-        return userOpenIdMapper.getListByIds(ids);
-    }
-
-    /**
-     * 新增用户和微信openID对应表
-     *
-     * @param userOpenId 用户和微信openID对应表
-     * @return 结果
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public int insertUserOpenId(UserOpenId userOpenId) {
-        return userOpenIdMapper.insertUserOpenId(userOpenId);
-    }
-
-    /**
-     * 修改用户和微信openID对应表
-     *
-     * @param userOpenId 用户和微信openID对应表
-     * @return 结果
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public int updateUserOpenId(UserOpenId userOpenId) {
-        return userOpenIdMapper.updateUserOpenId(userOpenId);
-    }
-
-    /**
-     * 批量删除用户和微信openID对应表
-     *
-     * @param ids 需要删除的用户和微信openID对应表主键
-     * @return 结果
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public int deleteUserOpenIdByIds(Long[] ids) {
-        return userOpenIdMapper.deleteUserOpenIdByIds(ids);
-    }
-
-    /**
-     * 删除用户和微信openID对应表信息
-     *
-     * @param id 用户和微信openID对应表主键
-     * @return 结果
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public int deleteUserOpenIdById(Long id) {
-        return userOpenIdMapper.deleteUserOpenIdById(id);
-    }
-
-    @Override
-    public UserOpenId getOpenId(String code) {
-        UserOpenId userOpenId;
-        LoginUser loginUser = tokenService.getLoginUser();
-        if (loginUser!=null){
-            Long userId = loginUser.getSysUser().getUserId();
-            userOpenId=userOpenIdMapper.getByUserId(userId);
-            if (userOpenId!=null){
-                return userOpenId;
-            }
-            String openId = wechatMsgSendService.getOpenId(code);
-            if (StringUtils.isEmpty(openId)){
-                return new UserOpenId();
-            }
-            userOpenId = new UserOpenId();
-            userOpenId.setOpenId(openId);
-            userOpenId.setUserId(userId);
-
-            List<UserOpenId> userOpenIds = userOpenIdMapper.selectUserOpenIdList(userOpenId);
-            if (userOpenIds.isEmpty()) {
-                userOpenIdMapper.insertUserOpenId(userOpenId);
-            }
-            return userOpenId;
-        }else {
-            throw new ServiceException("未检测到登录信息");
-        }
-    }
-
-    @Override
-    public UserOpenId getByUserId(Long userId) {
-        return userOpenIdMapper.getByUserId(userId);
-    }
-}

+ 0 - 283
zd-modules/zd-message/src/main/java/com/zd/message/service/impl/WechatMsgSendServiceImpl.java

@@ -1,283 +0,0 @@
-package com.zd.message.service.impl;
-
-import cn.hutool.http.HttpUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.message.properties.WeChatProperties;
-import com.zd.common.core.template.Template;
-import com.zd.common.core.template.TemplateParam;
-import com.zd.common.core.template.TemplateResult;
-import com.zd.common.core.template.WxUserInfo;
-import com.zd.message.domain.UserOpenId;
-import com.zd.message.service.IUserOpenIdService;
-import com.zd.message.service.IWechatMsgSendService;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.BoundValueOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-/**
- * 向微信小程序推送私密消息
- */
-@Slf4j
-@Service
-public class WechatMsgSendServiceImpl implements IWechatMsgSendService {
-
-    @Resource(name = "redisTemplate")
-    protected RedisTemplate<String, String> redisTemplate;
-    @Autowired
-    private WeChatProperties weChatProperties;
-
-    @Resource
-    private IUserOpenIdService openIdService;
-
-    private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
-    /**
-     * 微信获取openId的返回值
-     */
-    private static final Map<Integer, String> messageOpenIdMap = new HashMap<>();
-
-    static {
-        messageOpenIdMap.put(-1, "系统繁忙,此时请开发者稍候再试");
-        messageOpenIdMap.put(0, "请求成功");
-        messageOpenIdMap.put(40029, "code 无效");
-        messageOpenIdMap.put(45011, "频率限制,每个用户每分钟100次");
-        messageOpenIdMap.put(40226, "高风险等级用户,小程序登录拦截 。风险等级详见用户安全解方案");
-    }
-
-    /**
-     * 微信发送模板消息的返回值
-     */
-    private static final Map<Integer, String> sendMessageResultMap = new HashMap<>();
-
-    static {
-        sendMessageResultMap.put(40003, "openid 为空或者不正确");
-        sendMessageResultMap.put(40037, "订阅模板 id 为空不正确");
-        sendMessageResultMap.put(43101, "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系");
-        sendMessageResultMap.put(47003, "模板参数不准确,可能为空或者不满足规则");//errmsg会提示具体是哪个字段出错
-        sendMessageResultMap.put(41030, "page路径不正确,需要保证在现网版本小程序中存在,与 app.json 保持一致");
-    }
-
-    /**
-     * 资格申请、用气申请通知发送(跳转页面:资格申请-资格详情、用气申请-申请详情)
-     *
-     * @param userId      用户ID
-     * @param checkType   审核类型 1:资格申请 2:用气申请
-     * @param checkStatus 审核状态
-     * @param checkTime   审核时间
-     * @param taskId      任务ID
-     * @return TemplateResult 通知发送结果
-     */
-    @Override
-    public TemplateResult sendCheckResult(Long userId, Integer checkType, Integer checkStatus, Date checkTime, Long taskId) {
-        // checkType 双端页面不一致,判断跳转页面地址写入
-        String page = null;
-        if (checkType == 2) {
-            page = weChatProperties.getAirCheckUrl();
-        }
-        if (checkType == 1) {
-            page = weChatProperties.getQualificationCheckUrl();
-        }
-        return getTemplateResult(userId, checkType, checkStatus, checkTime, taskId, page);
-    }
-
-    private TemplateResult getTemplateResult(Long userId, Integer checkType, Integer checkStatus, Date checkTime, Long taskId, String page) {
-        page = page + "?id=" + taskId;
-        List<TemplateParam> paras = new ArrayList<>();
-        paras.add(new TemplateParam("thing39", checkType == 1 ? "资格申请" : "用气申请"));//申请事项
-        paras.add(new TemplateParam("phrase5", checkStatus == 1 ? "成功" : "失败"));//审核结果
-        paras.add(new TemplateParam("time24", dateFormat.format(checkTime)));//审核时间
-        return sendMessage(userId, weChatProperties.getCheckTemplateId(), page, paras);
-    }
-
-    /**
-     * 待办事项通知发送
-     *
-     * @param userId      用户ID
-     * @param backlogName 待办事项名称
-     * @param remark      备注
-     * @return TemplateResult 通知发送结果
-     */
-    @Override
-    public TemplateResult sendBacklogResult(Long userId, String backlogName, String remark) {
-        Template template = new Template();
-        String openId = getOpenId(userId);
-        template.setToUser(openId);
-        template.setTemplateId(weChatProperties.getBacklogTemplateId());
-        // 供应商端-待办事项-需求明细
-        template.setPage(weChatProperties.getBacklogUrl());
-
-        List<TemplateParam> paras = new ArrayList<>();
-        paras.add(new TemplateParam("thing3", backlogName));//待办事项
-        paras.add(new TemplateParam("time5", dateFormat.format(Calendar.getInstance().getTime())));//通知时间
-        paras.add(new TemplateParam("thing6", remark));//备注
-        template.setData(paras);
-        return sendMsgService(template);
-    }
-
-    @Override
-    public List<String> getList() {
-        return weChatProperties.getTemplateIds();
-    }
-
-    @Override
-    public TemplateResult sendStuCheckResult(Long userId, Integer checkType, Integer checkStatus, Date checkTime, Long taskId) {
-        // checkType 双端页面不一致,判断跳转页面地址写入
-        String page = null;
-        if (checkType == 2) {
-            page = weChatProperties.getStuAirCheckUrl();
-        }
-        if (checkType == 1) {
-            page = weChatProperties.getStuQualificationCheckUrl();
-        }
-        return getTemplateResult(userId, checkType, checkStatus, checkTime, taskId, page);
-    }
-
-    @Override
-    public TemplateResult sendAlarm(List<Long> userIds, String address) {
-        List<TemplateParam> paras = new ArrayList<>();
-        paras.add(new TemplateParam("thing1", address));//报警位置
-        paras.add(new TemplateParam("time3", dateFormat.format(Calendar.getInstance().getTime())));//上报时间
-        paras.add(new TemplateParam("thing2", "气瓶超出范围报警"));//报警原因
-        userIds.forEach(id -> sendMessage(id, weChatProperties.getDeviceAlarmTemplateId(), weChatProperties.getInitPage(), paras));
-        return null;
-    }
-
-    private TemplateResult sendMessage(Long userId, String weChatProperties, String page, List<TemplateParam> paras) {
-        Template template = getTemplate(userId, weChatProperties, page);
-        if (template==null){
-            return null;
-        }
-        template.setData(paras);
-        return sendMsgService(template);
-    }
-
-    /**
-     * 资格申请、用气申请管理端待审核通知发送
-     *
-     * @param userId    用户ID
-     * @param checkType 审核类型 1:资格申请 2:用气申请
-     * @param name      申请人
-     * @param applyTime 申请时间
-     * @return TemplateResult 通知发送结果
-     */
-    @Override
-    public TemplateResult sendWaitCheckResult(Long userId, Integer checkType, String name, Date applyTime) {
-        String page = weChatProperties.getWaitCheckUrl();
-        List<TemplateParam> paras = new ArrayList<>();
-        paras.add(new TemplateParam("name1", name));//申请事项
-        paras.add(new TemplateParam("thing3", checkType == 1 ? "资格申请" : "用气申请"));//审核结果
-        paras.add(new TemplateParam("time2", dateFormat.format(applyTime)));//审核时间
-        return sendMessage(userId, weChatProperties.getWaitCheckTemplateId(), page, paras);
-    }
-
-    private Template getTemplate(Long userId, String templateId, String page) {
-        Template template = new Template();
-        String openId = getOpenId(userId);
-        if (openId != null) {
-            template.setToUser(openId);
-            template.setTemplateId(templateId);
-            template.setPage(page);
-            return template;
-        }
-        return null;
-    }
-
-    /**
-     * 出库确认通知
-     *
-     * @param userId  用户ID
-     * @param outType 出库类型
-     * @param outTime 出库时间
-     * @return TemplateResult 通知发送结果
-     */
-    @Override
-    public TemplateResult sendStorageOutResult(Long userId, String outType, Date outTime) {
-        Template template = new Template();
-        String openId = getOpenId(userId);
-        template.setToUser(openId);
-        template.setTemplateId(weChatProperties.getStorageOutTemplateId());
-        List<TemplateParam> paras = new ArrayList<>();
-        paras.add(new TemplateParam("thing2", outType));//出库类型
-        paras.add(new TemplateParam("time9", dateFormat.format(outTime)));//出库时间
-        template.setData(paras);
-        return sendMsgService(template);
-    }
-
-    private String getOpenId(Long userId) {
-        UserOpenId userOpenId = openIdService.getByUserId(userId);
-        if (userOpenId == null) {
-            return null;
-        }
-        return userOpenId.getOpenId();
-    }
-
-    @Override
-    public String getOpenId(String code) {
-        String openIdUrl = weChatProperties.getOpenIdUrl().replace("APPID", weChatProperties.getAppId())
-                .replace("SECRET", weChatProperties.getSecret())
-                .replace("JSCODE", code);
-        String post = HttpUtil.get(openIdUrl);
-        JSONObject jsonObject = JSON.parseObject(post);
-        WxUserInfo wxUserInfo = JSON.toJavaObject(jsonObject, WxUserInfo.class);
-        if (wxUserInfo.getErrcode() != 0) {
-            String errMsg;
-            int errCode = wxUserInfo.getErrcode();
-            if (errCode == 40029) {
-                return null;
-            }
-            if (messageOpenIdMap.containsKey(errCode)) {
-                errMsg = messageOpenIdMap.get(errCode);
-                throw new ServiceException(errMsg);
-            }
-        }
-        return wxUserInfo.getOpenid();
-    }
-
-    private TemplateResult sendMsgService(Template template) {
-        String url = weChatProperties.getUrl().replace("ACCESS_TOKEN", getAccessToken());
-        String post = HttpUtil.post(url, template.toJSON());
-        JSONObject jsonObject = JSON.parseObject(post);
-        TemplateResult result = JSON.toJavaObject(jsonObject, TemplateResult.class);
-        int errCode = result.getErrcode();
-        if (errCode == 47003) {
-            result.setErrmsg(sendMessageResultMap.get(errCode) + ":" + result.getErrmsg());
-        } else if (sendMessageResultMap.containsKey(errCode)) {
-            result.setErrmsg(sendMessageResultMap.get(errCode));
-        }
-        return result;
-    }
-
-    private String getAccessToken() {
-        String accessToken = null;
-        try {
-            //查询是否还有缓存
-            BoundValueOperations<String, String> ops = redisTemplate.boundValueOps("account_token");
-            //缓存时长
-            if (StringUtils.isBlank(ops.get())) {
-                Map<String, Object> params = new HashMap<>();
-                params.put("grant_type", "client_credential");
-                params.put("appid", weChatProperties.getAppId());
-                params.put("secret", weChatProperties.getSecret());
-                String respData = HttpUtil.get(weChatProperties.getTokenUrl(), params);
-                log.info("get access_token=====\n{}", respData);
-                JSONObject json = JSON.parseObject(respData);
-                ops.set(json.getString("access_token"));
-                ops.expire(7100, TimeUnit.SECONDS);
-            }
-            accessToken = ops.get();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return accessToken;
-    }
-}

+ 0 - 49
zd-modules/zd-message/src/main/java/com/zd/message/utils/SHA1.java

@@ -1,49 +0,0 @@
-package com.zd.message.utils;
-
-import java.security.MessageDigest;
-import java.util.Arrays;
-
-public class SHA1 {
-
-    private SHA1() {
-        throw new IllegalStateException("SHA1 class");
-    }
-    /**
-     * 用SHA1算法验证Token
-     *
-     * @param token     票据
-     * @param timestamp 时间戳
-     * @param nonce     随机字符串
-     * @return 安全签名
-     */
-    public static String getSHA1(String token, String timestamp, String nonce) {
-        try {
-            String[] array = new String[]{token, timestamp, nonce};
-            StringBuilder sb = new StringBuilder();
-            // 字符串排序
-            Arrays.sort(array);
-            for (int i = 0; i < 3; i++) {
-                sb.append(array[i]);
-            }
-            String str = sb.toString();
-            // SHA1签名生成
-            MessageDigest md = MessageDigest.getInstance("SHA-1");
-            md.update(str.getBytes());
-            byte[] digest = md.digest();
-
-            StringBuilder hexstr = new StringBuilder();
-            String shaHex;
-            for (byte b : digest) {
-                shaHex = Integer.toHexString(b & 0xFF);
-                if (shaHex.length() < 2) {
-                    hexstr.append(0);
-                }
-                hexstr.append(shaHex);
-            }
-            return hexstr.toString();
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new SecurityException(e.getMessage());
-        }
-    }
-}

+ 0 - 26
zd-modules/zd-message/src/main/java/com/zd/message/utils/WXPublicUtils.java

@@ -1,26 +0,0 @@
-package com.zd.message.utils;
-
-import com.zd.common.core.exception.ServiceException;
-
-public class WXPublicUtils {
-
-    private WXPublicUtils() {
-        throw new IllegalStateException("WXPublicUtils class");
-    }
-
-    /**
-     * 验证Token
-     * @param msgSignature 签名串,对应URL参数的signature
-     * @param timeStamp 时间戳,对应URL参数的timestamp
-     * @param nonce 随机串,对应URL参数的nonce
-     * @param token Token(令牌)
-     * @return 是否为安全签名
-     */
-    public static boolean verifyUrl(String msgSignature, String timeStamp, String nonce, String token) {
-        String signature = SHA1.getSHA1(token, timeStamp, nonce);
-        if (!signature.equals(msgSignature)) {
-            throw new ServiceException("token 验证失败");
-        }
-        return true;
-    }
-}

+ 0 - 10
zd-modules/zd-message/src/main/resources/banner.txt

@@ -1,10 +0,0 @@
-Spring Boot Version: ${spring-boot.version}
-Spring Application Name: ${spring.application.name}
-                            _                           _                    
-                           (_)                         | |                   
- _ __  _   _   ___   _   _  _  ______  ___  _   _  ___ | |_   ___  _ __ ___  
-| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ 
-| |   | |_| || (_) || |_| || |        \__ \| |_| |\__ \| |_ |  __/| | | | | |
-|_|    \__,_| \___/  \__, ||_|        |___/ \__, ||___/ \__| \___||_| |_| |_|
-                      __/ |                  __/ |                           
-                     |___/                  |___/                            

+ 0 - 29
zd-modules/zd-message/src/main/resources/bootstrap.yml

@@ -1,29 +0,0 @@
-# Tomcat
-server:
-  port: 9500
-# Spring
-#logging:
-#  level:
-#    root: debug
-spring:
-  application:
-    # 应用名称
-    name: zd-message
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-      config:
-        # 配置中心地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-        # 配置文件格式
-        file-extension: yml
-        # 动态刷新
-        refresh-enabled: true
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

BIN
zd-modules/zd-message/src/main/resources/libs/connect-lib.jar


BIN
zd-modules/zd-message/src/main/resources/libs/reader-lib.jar


+ 0 - 74
zd-modules/zd-message/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-message"/>
-    <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-    <logger name="com.zd" level="info"/>
-    <!-- Spring日志级别控制  -->
-    <logger name="org.springframework" level="error"/>
-
-    <root level="info">
-        <appender-ref ref="console"/>
-    </root>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info"/>
-        <appender-ref ref="file_error"/>
-    </root>
-</configuration>

+ 0 - 78
zd-modules/zd-message/src/main/resources/mapper/message/UserOpenIdMapper.xml

@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zd.message.mapper.UserOpenIdMapper">
-    
-    <resultMap type="com.zd.message.domain.UserOpenId" id="UserOpenIdResult">
-        <result property="id"    column="id"    />
-        <result property="userId"    column="user_id"    />
-        <result property="openId"    column="open_id"    />
-    </resultMap>
-
-    <sql id="selectUserOpenIdVo">
-        select id, user_id, open_id from qp_user_open_id
-    </sql>
-    <sql id="selectUserOpenIdListVo">
-        select t.id, t.user_id, t.open_id from qp_user_open_id as t
-    </sql>
-    <select id="selectUserOpenIdList" parameterType="com.zd.message.domain.UserOpenId" resultMap="UserOpenIdResult">
-        <include refid="selectUserOpenIdVo"/>
-        <where>  
-            <if test="openId != null  and openId != ''"> and open_id = #{openId}</if>
-        </where>
-    </select>
-
-    <select id="getListByIds" resultMap="UserOpenIdResult">
-        <include refid="selectUserOpenIdVo"/>
-        <where>
-            id in
-            <foreach item="id" collection="list" open="(" separator="," close=")">
-                #{id}
-            </foreach>
-        </where>
-    </select>
-    
-    <select id="selectUserOpenIdById" resultMap="UserOpenIdResult">
-        <include refid="selectUserOpenIdVo"/>
-        where id = #{id}
-    </select>
-    <select id="getByUserId" resultType="com.zd.message.domain.UserOpenId" parameterType="java.lang.Long">
-        <include refid="selectUserOpenIdVo"/>
-        where user_id = #{userId}
-    </select>
-
-    <insert id="insertUserOpenId" parameterType="com.zd.message.domain.UserOpenId" useGeneratedKeys="true" keyProperty="id">
-        insert into qp_user_open_id
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-    <if test="userId != null">user_id,</if>
-
-    <if test="openId != null">open_id,</if>
-
-         </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-    <if test="userId != null">#{userId},</if>
-    <if test="openId != null">#{openId},</if>
-         </trim>
-    </insert>
-
-    <update id="updateUserOpenId" parameterType="com.zd.message.domain.UserOpenId">
-        update qp_user_open_id
-        <trim prefix="SET" suffixOverrides=",">
-            <if test="userId != null">user_id = #{userId},</if>
-            <if test="openId != null">open_id = #{openId},</if>
-        </trim>
-        where id = #{id}
-    </update>
-
-    <delete id="deleteUserOpenIdById">
-        delete from qp_user_open_id where id = #{id}
-    </delete>
-
-    <delete id="deleteUserOpenIdByIds">
-        delete from qp_user_open_id where id in
-        <foreach item="id" collection="array" open="(" separator="," close=")">
-            #{id}
-        </foreach>
-    </delete>
-</mapper>

+ 0 - 182
zd-modules/zd-message/wait-for-it.sh

@@ -1,182 +0,0 @@
-#!/usr/bin/env bash
-# Use this script to test if a given TCP host/port are available
-
-WAITFORIT_cmdname=${0##*/}
-
-echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
-
-usage()
-{
-    cat << USAGE >&2
-Usage:
-    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-    -h HOST | --host=HOST       Host or IP under test
-    -p PORT | --port=PORT       TCP port under test
-                                Alternatively, you specify the host and port as host:port
-    -s | --strict               Only execute subcommand if the test succeeds
-    -q | --quiet                Don't output any status messages
-    -t TIMEOUT | --timeout=TIMEOUT
-                                Timeout in seconds, zero for no timeout
-    -- COMMAND ARGS             Execute command with args after the test finishes
-USAGE
-    exit 1
-}
-
-wait_for()
-{
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    else
-        echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
-    fi
-    WAITFORIT_start_ts=$(date +%s)
-    while :
-    do
-        if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
-            nc -z $WAITFORIT_HOST $WAITFORIT_PORT
-            WAITFORIT_result=$?
-        else
-            (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
-            WAITFORIT_result=$?
-        fi
-        if [[ $WAITFORIT_result -eq 0 ]]; then
-            WAITFORIT_end_ts=$(date +%s)
-            echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
-            break
-        fi
-        sleep 1
-    done
-    return $WAITFORIT_result
-}
-
-wait_for_wrapper()
-{
-    # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
-    if [[ $WAITFORIT_QUIET -eq 1 ]]; then
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    else
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    fi
-    WAITFORIT_PID=$!
-    trap "kill -INT -$WAITFORIT_PID" INT
-    wait $WAITFORIT_PID
-    WAITFORIT_RESULT=$?
-    if [[ $WAITFORIT_RESULT -ne 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    fi
-    return $WAITFORIT_RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]
-do
-    case "$1" in
-        *:* )
-        WAITFORIT_hostport=(${1//:/ })
-        WAITFORIT_HOST=${WAITFORIT_hostport[0]}
-        WAITFORIT_PORT=${WAITFORIT_hostport[1]}
-        shift 1
-        ;;
-        --child)
-        WAITFORIT_CHILD=1
-        shift 1
-        ;;
-        -q | --quiet)
-        WAITFORIT_QUIET=1
-        shift 1
-        ;;
-        -s | --strict)
-        WAITFORIT_STRICT=1
-        shift 1
-        ;;
-        -h)
-        WAITFORIT_HOST="$2"
-        if [[ $WAITFORIT_HOST == "" ]]; then break; fi
-        shift 2
-        ;;
-        --host=*)
-        WAITFORIT_HOST="${1#*=}"
-        shift 1
-        ;;
-        -p)
-        WAITFORIT_PORT="$2"
-        if [[ $WAITFORIT_PORT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --port=*)
-        WAITFORIT_PORT="${1#*=}"
-        shift 1
-        ;;
-        -t)
-        WAITFORIT_TIMEOUT="$2"
-        if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --timeout=*)
-        WAITFORIT_TIMEOUT="${1#*=}"
-        shift 1
-        ;;
-        --)
-        shift
-        WAITFORIT_CLI=("$@")
-        break
-        ;;
-        --help)
-        usage
-        ;;
-        *)
-        echoerr "Unknown argument: $1"
-        usage
-        ;;
-    esac
-done
-
-if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
-    echoerr "Error: you need to provide a host and port to test."
-    usage
-fi
-
-WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
-WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
-WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
-WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
-
-# Check to see if timeout is from busybox?
-WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
-WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
-
-WAITFORIT_BUSYTIMEFLAG=""
-if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
-    WAITFORIT_ISBUSY=1
-    # Check if busybox timeout uses -t flag
-    # (recent Alpine versions don't support -t anymore)
-    if timeout &>/dev/stdout | grep -q -e '-t '; then
-        WAITFORIT_BUSYTIMEFLAG="-t"
-    fi
-else
-    WAITFORIT_ISBUSY=0
-fi
-
-if [[ $WAITFORIT_CHILD -gt 0 ]]; then
-    wait_for
-    WAITFORIT_RESULT=$?
-    exit $WAITFORIT_RESULT
-else
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        wait_for_wrapper
-        WAITFORIT_RESULT=$?
-    else
-        wait_for
-        WAITFORIT_RESULT=$?
-    fi
-fi
-
-if [[ $WAITFORIT_CLI != "" ]]; then
-    if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
-        echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
-        exit $WAITFORIT_RESULT
-    fi
-    exec "${WAITFORIT_CLI[@]}"
-else
-    exit $WAITFORIT_RESULT
-fi

Plik diff jest za duży
+ 0 - 10
zd-modules/zd-modules-file/Dockerfile


+ 0 - 117
zd-modules/zd-modules-file/pom.xml

@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <groupId>com.zd</groupId>
-        <artifactId>zd-modules</artifactId>
-        <version>3.1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>zd-modules-file</artifactId>
-    <packaging>jar</packaging>
-    <description>文件服务</description>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-redis</artifactId>
-        </dependency>
-
-    	<!-- SpringCloud Alibaba Nacos -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Nacos Config -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
-        </dependency>
-
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
-
-        <!-- FastDFS -->
-        <dependency>
-            <groupId>com.github.tobato</groupId>
-            <artifactId>fastdfs-client</artifactId>
-        </dependency>
-
-        <!-- Minio -->
-        <dependency>
-            <groupId>io.minio</groupId>
-            <artifactId>minio</artifactId>
-            <version>${minio.version}</version>
-        </dependency>
-
-        <!-- zd Api System -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-api-system</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>net.sf.json-lib</groupId>
-            <artifactId>json-lib</artifactId>
-            <version>2.4</version>
-            <classifier>jdk15</classifier>
-        </dependency>
-
-        <!-- zd Common Swagger -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-swagger</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.8.2</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-            <version>20140107</version>
-        </dependency>
-
-    </dependencies>
-
-    <build>
-        <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 20
zd-modules/zd-modules-file/src/main/java/com/zd/ZdFileApplication.java

@@ -1,20 +0,0 @@
-package com.zd;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-//import com.zd.common.swagger.annotation.EnableCustomSwagger2;
-
-/**
- * 文件服务
- *
- * @author zd
- */
-//@EnableCustomSwagger2
-@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
-public class ZdFileApplication {
-    public static void main(String[] args) {
-        SpringApplication.run(ZdFileApplication.class, args);
-        System.out.println("(♥◠‿◠)ノ゙  文件服务模块启动成功   ლ(´ڡ`ლ)゙");
-    }
-}

+ 0 - 43
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/config/RedisConfig.java

@@ -1,43 +0,0 @@
-package com.zd.bigupload.config;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-/**
- * @Author donggaosheng
- * @Date 2020/12/2 11:26
- * @Version 1.0
- **/
-@Configuration
-public class RedisConfig {
-
-    @Bean
-    @SuppressWarnings("all")
-    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
-        RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
-        template.setConnectionFactory(factory);
-        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
-        ObjectMapper om = new ObjectMapper();
-        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
-        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
-        jackson2JsonRedisSerializer.setObjectMapper(om);
-        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
-        // key采用String的序列化方式
-        template.setKeySerializer(stringRedisSerializer);
-        // hash的key也采用String的序列化方式
-        template.setHashKeySerializer(stringRedisSerializer);
-        // value序列化方式采用jackson
-        template.setValueSerializer(jackson2JsonRedisSerializer);
-        template.setHashValueSerializer(jackson2JsonRedisSerializer);
-        template.afterPropertiesSet();
-        return template;
-    }
-}

+ 0 - 71
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/controller/UploadController.java

@@ -1,71 +0,0 @@
-package com.zd.bigupload.controller;
-
-import com.zd.bigupload.dto.FileChunkDTO;
-import com.zd.bigupload.dto.FileChunkResultDTO;
-import com.zd.bigupload.response.RestApiResponse;
-import com.zd.bigupload.service.IUploadService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 19:22
- * @Version 1.0
- **/
-@RestController
-@RequestMapping("upload")
-public class UploadController {
-
-    @Autowired
-    private IUploadService uploadService;
-
-    /**
-     * 检查分片是否存在
-     *
-     * @return
-     */
-    @GetMapping("chunk")
-    public RestApiResponse<Object> checkChunkExist(FileChunkDTO chunkDTO) {
-        FileChunkResultDTO fileChunkCheckDTO;
-        try {
-            fileChunkCheckDTO = uploadService.checkChunkExist(chunkDTO);
-            return RestApiResponse.success(fileChunkCheckDTO);
-        } catch (Exception e) {
-            return RestApiResponse.error(e.getMessage());
-        }
-    }
-
-
-    /**
-     * 上传文件分片
-     *
-     * @param chunkDTO
-     * @return
-     */
-    @PostMapping("chunk")
-    public RestApiResponse<Object> uploadChunk(FileChunkDTO chunkDTO) {
-        try {
-            uploadService.uploadChunk(chunkDTO);
-            return RestApiResponse.success(chunkDTO.getIdentifier());
-        } catch (Exception e) {
-            return RestApiResponse.error(e.getMessage());
-        }
-    }
-
-    /**
-     * 请求合并文件分片
-     *
-     * @param chunkDTO
-     * @return
-     */
-    @PostMapping("merge")
-    public RestApiResponse<Object> mergeChunks(@RequestBody FileChunkDTO chunkDTO) {
-        try {
-            String filePath = uploadService.mergeChunk(chunkDTO.getIdentifier(), chunkDTO.getFilename(), chunkDTO.getTotalChunks());
-            return RestApiResponse.success(filePath);
-        } catch (Exception e) {
-            return RestApiResponse.error(e.getMessage());
-        }
-    }
-
-}

+ 0 - 124
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/dto/FileChunkDTO.java

@@ -1,124 +0,0 @@
-package com.zd.bigupload.dto;
-
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * 文件分片
- *
- * @Author donggaosheng
- * @Date 2021/1/16 19:35
- * @Version 1.0
- **/
-public class FileChunkDTO {
-    /**
-     * 文件md5
-     */
-    private String identifier;
-    /**
-     * 分块文件
-     */
-    MultipartFile file;
-    /**
-     * 当前分块序号
-     */
-    private Integer chunkNumber;
-    /**
-     * 分块大小
-     */
-    private Long chunkSize;
-    /**
-     * 当前分块大小
-     */
-    private Long currentChunkSize;
-    /**
-     * 文件总大小
-     */
-    private Long totalSize;
-    /**
-     * 分块总数
-     */
-    private Integer totalChunks;
-    /**
-     * 文件名
-     */
-    private String filename;
-
-    public String getIdentifier() {
-        return identifier;
-    }
-
-    public void setIdentifier(String identifier) {
-        this.identifier = identifier;
-    }
-
-    public MultipartFile getFile() {
-        return file;
-    }
-
-    public void setFile(MultipartFile file) {
-        this.file = file;
-    }
-
-
-    public Integer getChunkNumber() {
-        return chunkNumber;
-    }
-
-    public void setChunkNumber(Integer chunkNumber) {
-        this.chunkNumber = chunkNumber;
-    }
-
-    public Long getChunkSize() {
-        return chunkSize;
-    }
-
-    public void setChunkSize(Long chunkSize) {
-        this.chunkSize = chunkSize;
-    }
-
-    public Long getCurrentChunkSize() {
-        return currentChunkSize;
-    }
-
-    public void setCurrentChunkSize(Long currentChunkSize) {
-        this.currentChunkSize = currentChunkSize;
-    }
-
-    public Long getTotalSize() {
-        return totalSize;
-    }
-
-    public void setTotalSize(Long totalSize) {
-        this.totalSize = totalSize;
-    }
-
-    public Integer getTotalChunks() {
-        return totalChunks;
-    }
-
-    public void setTotalChunks(Integer totalChunks) {
-        this.totalChunks = totalChunks;
-    }
-
-    public String getFilename() {
-        return filename;
-    }
-
-    public void setFilename(String filename) {
-        this.filename = filename;
-    }
-
-    @Override
-    public String toString() {
-        return "FileChunkDTO{" +
-                "identifier='" + identifier + '\'' +
-                ", file=" + file +
-                ", chunkNumber=" + chunkNumber +
-                ", chunkSize=" + chunkSize +
-                ", currentChunkSize=" + currentChunkSize +
-                ", totalSize=" + totalSize +
-                ", totalChunks=" + totalChunks +
-                ", filename='" + filename + '\'' +
-                '}';
-    }
-}

+ 0 - 46
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/dto/FileChunkResultDTO.java

@@ -1,46 +0,0 @@
-package com.zd.bigupload.dto;
-
-import java.util.Set;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/17 10:14
- * @Version 1.0
- **/
-public class FileChunkResultDTO {
-    /**
-     * 是否跳过上传
-     */
-    private Boolean skipUpload;
-
-    /**
-     * 已上传分片的集合
-     */
-    private Set<Integer> uploaded;
-
-    public Boolean getSkipUpload() {
-        return skipUpload;
-    }
-
-    public void setSkipUpload(Boolean skipUpload) {
-        this.skipUpload = skipUpload;
-    }
-
-    public Set<Integer> getUploaded() {
-        return uploaded;
-    }
-
-    public void setUploaded(Set<Integer> uploaded) {
-        this.uploaded = uploaded;
-    }
-
-
-    public FileChunkResultDTO(Boolean skipUpload, Set<Integer> uploaded) {
-        this.skipUpload = skipUpload;
-        this.uploaded = uploaded;
-    }
-
-    public FileChunkResultDTO(Boolean skipUpload) {
-        this.skipUpload = skipUpload;
-    }
-}

+ 0 - 75
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/RestApiResponse.java

@@ -1,75 +0,0 @@
-package com.zd.bigupload.response;
-
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:37
- * @Version 1.0
- **/
-public class RestApiResponse<T> {
-
-    private int code;
-
-    /**
-     * 是否成功
-     */
-    private boolean success;
-
-    /**
-     * 响应数据
-     */
-    private T data;
-
-    public boolean isSuccess() {
-        return success;
-    }
-
-    public void setSuccess(boolean success) {
-        this.success = success;
-    }
-
-    public T getData() {
-        return data;
-    }
-
-    public void setData(T data) {
-        this.data = data;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-    public void setCode(int code) {
-        this.code = code;
-    }
-
-    public static <T> RestApiResponse<T> success(T data) {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = true;
-        result.code=200;
-        result.data = data;
-        return result;
-    }
-
-    public static <T> RestApiResponse<T> success() {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = true;
-        result.code=200;
-        return result;
-    }
-
-    public static <T> RestApiResponse<T> error(T data) {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = false;
-        result.code=500;
-        result.data = data;
-        return result;
-    }
-
-    public static <T> RestApiResponse<T> flag(boolean data) {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = data;
-        return result;
-    }
-}

+ 0 - 29
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/error/BaseErrorCode.java

@@ -1,29 +0,0 @@
-package com.zd.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:40
- * @Version 1.0
- **/
-public interface BaseErrorCode {
-    /**
-     * 获取错误码
-     *
-     * @return
-     */
-    int getErrorCode();
-
-    /**
-     * 获取错误信息
-     *
-     * @return
-     */
-    String getErrorMsg();
-
-    /**
-     * 设置错误信息
-     *
-     * @param errorMsg
-     */
-    void setErrorMsg(String errorMsg);
-}

+ 0 - 42
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/error/BusinessErrorCode.java

@@ -1,42 +0,0 @@
-package com.zd.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:49
- * @Version 1.0
- **/
-public enum BusinessErrorCode implements BaseErrorCode {
-
-    USER_NOT_LOGIN(10001, "用户未登入"),
-    INVALID_PARAMETER(10002, "参数错误");
-
-    /**
-     * 错误消息
-     */
-    private String errorMsg;
-    /**
-     * 错误码
-     */
-    private Integer errorCode;
-
-    BusinessErrorCode(Integer errorCode, String errorMsg) {
-        this.errorMsg = errorMsg;
-        this.errorCode = errorCode;
-    }
-
-    @Override
-    public int getErrorCode() {
-        return this.errorCode;
-    }
-
-    @Override
-    public String getErrorMsg() {
-        return this.errorMsg;
-    }
-
-    @Override
-    public void setErrorMsg(String errorMsg) {
-        this.errorMsg = errorMsg;
-    }
-
-}

+ 0 - 34
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/response/error/BusinessException.java

@@ -1,34 +0,0 @@
-package com.zd.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:45
- * @Version 1.0
- **/
-public class BusinessException extends Exception {
-
-    private BaseErrorCode errorCode;
-
-    public BusinessException(BaseErrorCode errorCode) {
-        super(errorCode.getErrorMsg());
-        this.errorCode = errorCode;
-    }
-
-    public BusinessException(BaseErrorCode errorCode, String customizedErrorMsg) {
-        super(customizedErrorMsg);
-        this.errorCode = errorCode;
-        errorCode.setErrorMsg(customizedErrorMsg);
-    }
-
-    public static void main(String[] args) throws BusinessException {
-        throw new BusinessException(BusinessErrorCode.USER_NOT_LOGIN);
-    }
-
-    public BaseErrorCode getErrorCode() {
-        return errorCode;
-    }
-
-    public void setErrorCode(BaseErrorCode errorCode) {
-        this.errorCode = errorCode;
-    }
-}

+ 0 - 45
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/service/IUploadService.java

@@ -1,45 +0,0 @@
-package com.zd.bigupload.service;
-
-import com.zd.bigupload.dto.FileChunkDTO;
-import com.zd.bigupload.dto.FileChunkResultDTO;
-import com.zd.bigupload.response.error.BusinessException;
-
-import java.io.IOException;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/17 10:21
- * @Version 1.0
- * @Modify XJLZ
- **/
-public interface IUploadService {
-
-    /**
-     * 检查文件是否存在,如果存在则跳过该文件的上传,如果不存在,返回需要上传的分片集合
-     *
-     * @param chunkDTO
-     * @return
-     */
-    FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException;
-
-
-    /**
-     * 上传文件分片
-     *
-     * @param chunkDTO
-     */
-    void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException, IOException;
-
-
-    /**
-     * 合并文件分片
-     *
-     * @param identifier
-     * @param fileName
-     * @param totalChunks
-     * @return
-     * @throws BusinessException
-     * @throws IOException
-     */
-    String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException;
-}

+ 0 - 306
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/service/impl/UploadServiceImpl.java

@@ -1,306 +0,0 @@
-package com.zd.bigupload.service.impl;
-
-import com.zd.bigupload.dto.FileChunkDTO;
-import com.zd.bigupload.dto.FileChunkResultDTO;
-import com.zd.bigupload.response.error.BusinessErrorCode;
-import com.zd.bigupload.response.error.BusinessException;
-import com.zd.bigupload.service.IUploadService;
-import com.zd.bigupload.utils.FileUtils;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import java.io.*;
-import java.net.UnknownHostException;
-import java.util.*;
-
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/17 10:24
- * @Version 1.0
- * @Modify XJLZ
- **/
-@Service
-@SuppressWarnings("all")
-public class UploadServiceImpl implements IUploadService {
-
-    private static final String FILE_PREFIX = "bigfile:";
-
-    private Logger logger = LoggerFactory.getLogger(UploadServiceImpl.class);
-
-    @Autowired
-    private RedisTemplate<String, Object> redisTemplate;
-
-    /**
-     * 域名或本机访问地址
-     */
-    @Value("${file.domain}")
-    public String domain;
-
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String uploadFolder;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String filePrefix;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.bigFile}")
-    public String bigFile;
-
-    /**
-     * 检查文件是否存在,如果存在则跳过该文件的上传,如果不存在,返回需要上传的分片集合
-     *
-     * @param chunkDTO
-     * @return
-     */
-    @Override
-    public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException {
-        //1.检查文件是否已上传过
-        //1.1)检查在磁盘中是否存在
-        String fileFolderPath = getFileFolderPath(chunkDTO.getIdentifier());
-        logger.info("fileFolderPath-->{}", fileFolderPath);
-        String filePath = getFilePath(chunkDTO.getIdentifier(), chunkDTO.getFilename());
-        File file = new File(filePath);
-        boolean exists = file.exists();
-        //1.2)检查Redis中是否存在,并且所有分片已经上传完成。
-        Set<Integer> uploaded = (Set<Integer>) redisTemplate.opsForHash().get(FILE_PREFIX + chunkDTO.getIdentifier(), "uploaded");
-        if (uploaded != null && uploaded.size() == chunkDTO.getTotalChunks() && exists) {
-            return new FileChunkResultDTO(true);
-        }
-        File fileFolder = new File(fileFolderPath);
-        if (!fileFolder.exists()) {
-            boolean mkdirs = fileFolder.mkdirs();
-            logger.info("准备工作,创建文件夹,fileFolderPath:{},mkdirs:{}", fileFolderPath, mkdirs);
-        }
-        // 断点续传,返回已上传的分片
-        return new FileChunkResultDTO(false, uploaded);
-    }
-
-
-    /**
-     * 上传分片
-     *
-     * @param chunkDTO
-     */
-    @Override
-    public void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException {
-        //分块的目录
-        String chunkFileFolderPath = getChunkFileFolderPath(chunkDTO.getIdentifier());
-        logger.info("分块的目录 -> {}", chunkFileFolderPath);
-        File chunkFileFolder = new File(chunkFileFolderPath);
-        if (!chunkFileFolder.exists()) {
-            boolean mkdirs = chunkFileFolder.mkdirs();
-            logger.info("创建分片文件夹:{}", mkdirs);
-        }
-        //写入分片
-        try (
-                InputStream inputStream = chunkDTO.getFile().getInputStream();
-                FileOutputStream outputStream = new FileOutputStream(new File(chunkFileFolderPath + chunkDTO.getChunkNumber()))
-        ) {
-            IOUtils.copy(inputStream, outputStream);
-            logger.info("文件标识:{},chunkNumber:{}", chunkDTO.getIdentifier(), chunkDTO.getChunkNumber());
-            //将该分片写入redis
-            long size = saveToRedis(chunkDTO);
-        } catch (Exception e) {
-            throw new BusinessException(BusinessErrorCode.INVALID_PARAMETER, e.getMessage());
-        }
-    }
-
-
-    @Override
-    public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException {
-        String suffix = fileName.substring(fileName.lastIndexOf("."));
-        if(null==suffix){
-            throw new RuntimeException("文件格式有误");
-        }
-        fileName= UUID.randomUUID().toString()+suffix;
-        return mergeChunks(identifier, fileName, totalChunks);
-    }
-
-    /**
-     * 合并分片
-     *
-     * @param identifier
-     * @param filename
-     */
-    private String mergeChunks(String identifier,String filename, Integer totalChunks) throws IOException {
-        String chunkFileFolderPath = getChunkFileFolderPath(identifier);
-        String prefixFileFolderPath = getPrefixFileFolderPath(identifier);
-        String filePath = getFilePath(identifier, filename);
-        String accessPath = getNetWorkPath(filename);
-        // 检查分片是否都存在
-        if (checkChunks(chunkFileFolderPath, totalChunks)) {
-            File chunkFileFolder = new File(chunkFileFolderPath);
-            File mergeFile = new File(filePath);
-            if (!mergeFile.exists()) {
-                mergeFile.createNewFile();
-            }
-            File[] chunks = chunkFileFolder.listFiles();
-            //排序
-            List fileList = Arrays.asList(chunks);
-            Collections.sort(fileList, (Comparator<File>) (o1, o2) -> {
-                return Integer.parseInt(o1.getName()) - (Integer.parseInt(o2.getName()));
-            });
-            try {
-                RandomAccessFile randomAccessFileWriter = new RandomAccessFile(mergeFile, "rw");
-                byte[] bytes = new byte[1024];
-                for (File chunk : chunks) {
-                    RandomAccessFile randomAccessFileReader = new RandomAccessFile(chunk, "r");
-                    int len;
-                    while ((len = randomAccessFileReader.read(bytes)) != -1) {
-                        randomAccessFileWriter.write(bytes, 0, len);
-                    }
-                    randomAccessFileReader.close();
-                }
-                randomAccessFileWriter.close();
-                FileUtils.delFolder(prefixFileFolderPath);
-            } catch (Exception e) {
-                return null;
-            }
-            return accessPath;
-        }
-        return accessPath;
-    }
-
-    private String getAcessPath(String prefix, String filename) {
-        if (!StringUtils.isEmpty(prefix)) {
-            return prefix + "/" + FileUtils.getFormatter() + "/" + filename;
-        }
-        return FileUtils.getFormatter() + "/" + filename;
-    }
-
-
-    private String getNetWorkPath(String fileName) throws UnknownHostException {
-        /*String urlPrefix = domain;
-        String localIP = "127.0.0.1";
-        if (urlPrefix.contains(localIP)) {
-            String ip = InetAddress.getLocalHost().getHostAddress();;
-            urlPrefix = urlPrefix.replace(localIP, ip);
-        }
-        String url = urlPrefix + filePrefix+"/"+bigFile+"/"+ FileUtils.getFormatter() + "/" + fileName;*/
-        String url = filePrefix+"/"+bigFile+"/"+ FileUtils.getFormatter() + "/" + fileName;
-        return url.replace("//","/").replace("./",".//");
-    }
-
-    /**
-     * 检查分片是否都存在
-     *
-     * @param chunkFileFolderPath
-     * @param totalChunks
-     * @return
-     */
-    private boolean checkChunks(String chunkFileFolderPath, Integer totalChunks) {
-        try {
-            for (int i = 1; i <= totalChunks + 1; i++) {
-                File file = new File(chunkFileFolderPath + File.separator + i);
-                if (file.exists()) {
-                    continue;
-                } else {
-                    return false;
-                }
-            }
-        } catch (Exception e) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * 分片写入Redis
-     *
-     * @param chunkDTO
-     */
-    private synchronized long saveToRedis(FileChunkDTO chunkDTO) {
-        Set<Integer> uploaded = (Set<Integer>) redisTemplate.opsForHash().get(FILE_PREFIX + chunkDTO.getIdentifier(), "uploaded");
-        if (uploaded == null) {
-            uploaded = new HashSet<>(Arrays.asList(chunkDTO.getChunkNumber()));
-            HashMap<String, Object> objectObjectHashMap = new HashMap<>();
-            objectObjectHashMap.put("uploaded", uploaded);
-            objectObjectHashMap.put("totalChunks", chunkDTO.getTotalChunks());
-            objectObjectHashMap.put("totalSize", chunkDTO.getTotalSize());
-            objectObjectHashMap.put("path", chunkDTO.getFilename());
-            redisTemplate.opsForHash().putAll(FILE_PREFIX + chunkDTO.getIdentifier(), objectObjectHashMap);
-        } else {
-            uploaded.add(chunkDTO.getChunkNumber());
-            redisTemplate.opsForHash().put(FILE_PREFIX + chunkDTO.getIdentifier(), "uploaded", uploaded);
-        }
-        return uploaded.size();
-    }
-
-    /**
-     * 得到文件的绝对路径
-     *
-     * @param identifier
-     * @param filename
-     * @return
-     */
-    private String getFilePath(String identifier, String filename) {
-        String ext = filename.substring(filename.lastIndexOf("."));
-        String filePath=uploadFolder +"/"+bigFile+"/"+ FileUtils.getFormatter();
-        File file = new File(filePath);
-        if (!file.exists()) {
-            file.mkdirs();
-        }
-        filePath=filePath+"/" + filename;
-        return filePath.replace("//","/");
-    }
-
-    /**
-     * 得到文件的相对路径
-     *
-     * @param identifier
-     * @param filename
-     * @return
-     */
-    private String getFileRelativelyPath(String identifier, String filename) {
-        String ext = filename.substring(filename.lastIndexOf("."));
-        return "/" + identifier.substring(0, 1) + "/" +
-                identifier.substring(1, 2) + "/" +
-                identifier + "/" + identifier
-                + ext;
-    }
-
-
-    /**
-     * 得到分块文件所属的目录
-     *
-     * @param identifier
-     * @return
-     */
-    private String getChunkFileFolderPath(String identifier) {
-        return getFileFolderPath(identifier) + "chunks" + File.separator;
-    }
-
-
-    private String getPrefixFileFolderPath(String identifier) {
-        String prefixFile=uploadFolder +"/"+filePrefix+"/"+bigFile +"/"+identifier.substring(0, 1);
-        return prefixFile.replace("//","/");
-    }
-
-    /**
-     * 得到文件所属的目录
-     *
-     * @param identifier
-     * @return
-     */
-    private String getFileFolderPath(String identifier) {
-        String fileFolderPath=uploadFolder+"/"+filePrefix+"/"+bigFile+"/"+identifier.substring(0, 1) + File.separator +
-                identifier.substring(1, 2) + File.separator +
-                identifier + File.separator;
-        return fileFolderPath.replace("//","/");
-    }
-}

+ 0 - 64
zd-modules/zd-modules-file/src/main/java/com/zd/bigupload/utils/FileUtils.java

@@ -1,64 +0,0 @@
-package com.zd.bigupload.utils;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class FileUtils {
-    //删除文件夹
-    public static void delFolder(String folderPath) {
-        try {
-            delAllFile(folderPath); //删除完里面所有内容
-            String filePath = folderPath;
-            File myFilePath = new File(filePath);
-            myFilePath.delete(); //删除空文件夹
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    //删除指定文件夹下的所有文件
-
-    public static boolean delAllFile(String path) {
-        boolean flag = false;
-        File file = new File(path);
-        if (!file.exists()) {
-            return flag;
-        }
-        if (!file.isDirectory()) {
-            return flag;
-        }
-        String[] tempList = file.list();
-        File temp = null;
-        for (int i = 0; i < tempList.length; i++) {
-            if (path.endsWith(File.separator)) {
-                temp = new File(path + tempList[i]);
-            } else {
-                temp = new File(path + File.separator + tempList[i]);
-            }
-            if (temp.isFile()) {
-                temp.delete();
-            }
-            if (temp.isDirectory()) {
-                delAllFile(path + File.separator + tempList[i]);//先删除文件夹里面的文件
-                delFolder(path + File.separator + tempList[i]);//再删除空文件夹
-                flag = true;
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 格式化数据
-     *
-     * @return
-     */
-    public static String getFormatter() {
-        Date d = new Date();
-        System.out.println(d);
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
-        String dateNowStr = sdf.format(d);
-        return dateNowStr;
-    }
-
-}

+ 0 - 74
zd-modules/zd-modules-file/src/main/java/com/zd/file/config/MinioConfig.java

@@ -1,74 +0,0 @@
-package com.zd.file.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import io.minio.MinioClient;
-
-/**
- * Minio 配置信息
- *
- * @author zd
- */
-@Configuration
-@RefreshScope
-@ConfigurationProperties(prefix = "minio")
-public class MinioConfig {
-    /**
-     * 服务地址
-     */
-    private String url;
-
-    /**
-     * 用户名
-     */
-    private String accessKey;
-
-    /**
-     * 密码
-     */
-    private String secretKey;
-
-    /**
-     * 存储桶名称
-     */
-    private String bucketName;
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getAccessKey() {
-        return accessKey;
-    }
-
-    public void setAccessKey(String accessKey) {
-        this.accessKey = accessKey;
-    }
-
-    public String getSecretKey() {
-        return secretKey;
-    }
-
-    public void setSecretKey(String secretKey) {
-        this.secretKey = secretKey;
-    }
-
-    public String getBucketName() {
-        return bucketName;
-    }
-
-    public void setBucketName(String bucketName) {
-        this.bucketName = bucketName;
-    }
-
-    @Bean
-    public MinioClient getMinioClient() {
-        return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
-    }
-}

+ 0 - 51
zd-modules/zd-modules-file/src/main/java/com/zd/file/config/ResourcesConfig.java

@@ -1,51 +0,0 @@
-package com.zd.file.config;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-import java.io.File;
-
-/**
- * 通用映射配置
- *
- * @author zd
- */
-@Configuration
-@RefreshScope
-public class ResourcesConfig implements WebMvcConfigurer {
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String localFilePath;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String localFilePrefix;
-
-    @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-        /** 本地文件上传路径 */
-        registry.addResourceHandler(localFilePrefix + "/**")
-                .addResourceLocations("file:" + localFilePath + File.separator);
-    }
-
-    /**
-     * 开启跨域
-     */
-    @Override
-    public void addCorsMappings(CorsRegistry registry) {
-        // 设置允许跨域的路由
-        registry.addMapping(localFilePrefix + "/**")
-                // 设置允许跨域请求的域名
-                .allowedOrigins("*")
-                // 设置允许的方法
-                .allowedMethods("GET");
-    }
-}

+ 0 - 43
zd-modules/zd-modules-file/src/main/java/com/zd/file/controller/SysFileController.java

@@ -1,43 +0,0 @@
-package com.zd.file.controller;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-import com.zd.common.core.domain.R;
-import com.zd.common.core.utils.file.FileUtils;
-import com.zd.file.service.ISysFileService;
-import com.zd.system.api.domain.SysFile;
-
-/**
- * 文件请求处理
- *
- * @author zd
- */
-@RestController
-public class SysFileController {
-    private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
-
-    @Autowired
-    private ISysFileService sysFileService;
-
-    /**
-     * 文件上传请求
-     */
-    @PostMapping("upload")
-    public R<SysFile> upload(MultipartFile file) {
-        try {
-            // 上传并返回访问地址
-            String url = sysFileService.uploadFile(file);
-            SysFile sysFile = new SysFile();
-            sysFile.setName(FileUtils.getName(url));
-            sysFile.setUrl(url);
-            return R.ok(sysFile);
-        } catch (Exception e) {
-            log.error("上传文件失败", e);
-            return R.fail(e.getMessage());
-        }
-    }
-}

+ 0 - 40
zd-modules/zd-modules-file/src/main/java/com/zd/file/service/FastDfsSysFileServiceImpl.java

@@ -1,40 +0,0 @@
-package com.zd.file.service;
-
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-import com.github.tobato.fastdfs.domain.fdfs.StorePath;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
-
-/**
- * FastDFS 文件存储
- *
- * @author zd
- */
-@Service
-public class FastDfsSysFileServiceImpl implements ISysFileService {
-    /**
-     * 域名或本机访问地址
-     */
-    @Value("${fdfs.domain}")
-    public String domain;
-
-    @Autowired
-    private FastFileStorageClient storageClient;
-
-    /**
-     * FastDfs文件上传接口
-     *
-     * @param file 上传的文件
-     * @return 访问地址
-     * @throws Exception
-     */
-    @Override
-    public String uploadFile(MultipartFile file) throws Exception {
-        StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
-                FilenameUtils.getExtension(file.getOriginalFilename()), null);
-        return domain + "/" + storePath.getFullPath();
-    }
-}

+ 0 - 19
zd-modules/zd-modules-file/src/main/java/com/zd/file/service/ISysFileService.java

@@ -1,19 +0,0 @@
-package com.zd.file.service;
-
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * 文件上传接口
- *
- * @author zd
- */
-public interface ISysFileService {
-    /**
-     * 文件上传接口
-     *
-     * @param file 上传的文件
-     * @return 访问地址
-     * @throws Exception
-     */
-    public String uploadFile(MultipartFile file) throws Exception;
-}

+ 0 - 55
zd-modules/zd-modules-file/src/main/java/com/zd/file/service/LocalSysFileServiceImpl.java

@@ -1,55 +0,0 @@
-package com.zd.file.service;
-
-import com.zd.file.utils.FileUploadUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * 本地文件存储
- *
- * @author zd
- */
-@Primary
-@Service
-public class LocalSysFileServiceImpl implements ISysFileService {
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String localFilePrefix;
-
-    /**
-     * 域名或本机访问地址
-     */
-    @Value("${file.domain}")
-    public String domain;
-
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String localFilePath;
-
-    /**
-     * 本地文件上传接口
-     *
-     * @param file 上传的文件
-     * @return 访问地址
-     * @throws Exception
-     */
-    @Override
-    public String uploadFile(MultipartFile file) throws Exception {
-        String name = FileUploadUtils.upload(localFilePath, file);
-        //TODO 去掉拼接前缀
-//        String urlPrefix = domain;
-//        String localIP = "127.0.0.1";
-//        if (urlPrefix.contains(localIP)) {
-//            String ip = InetAddress.getLocalHost().getHostAddress();;
-//            urlPrefix = urlPrefix.replace(localIP, ip);
-//        }
-        String url =localFilePrefix + name;
-        return url;
-    }
-}

+ 0 - 43
zd-modules/zd-modules-file/src/main/java/com/zd/file/service/MinioSysFileServiceImpl.java

@@ -1,43 +0,0 @@
-package com.zd.file.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-import com.zd.file.config.MinioConfig;
-import com.zd.file.utils.FileUploadUtils;
-import io.minio.MinioClient;
-import io.minio.PutObjectArgs;
-
-/**
- * Minio 文件存储
- *
- * @author zd
- */
-@Service
-public class MinioSysFileServiceImpl implements ISysFileService {
-    @Autowired
-    private MinioConfig minioConfig;
-
-    @Autowired
-    private MinioClient client;
-
-    /**
-     * 本地文件上传接口
-     *
-     * @param file 上传的文件
-     * @return 访问地址
-     * @throws Exception
-     */
-    @Override
-    public String uploadFile(MultipartFile file) throws Exception {
-        String fileName = FileUploadUtils.extractFilename(file);
-        PutObjectArgs args = PutObjectArgs.builder()
-                .bucket(minioConfig.getBucketName())
-                .object(fileName)
-                .stream(file.getInputStream(), file.getSize(), -1)
-                .contentType(file.getContentType())
-                .build();
-        client.putObject(args);
-        return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
-    }
-}

+ 0 - 201
zd-modules/zd-modules-file/src/main/java/com/zd/file/utils/FileUploadUtils.java

@@ -1,201 +0,0 @@
-package com.zd.file.utils;
-
-import java.io.File;
-import java.io.IOException;
-
-import com.zd.common.core.exception.ServiceException;
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.web.multipart.MultipartFile;
-import com.zd.common.core.exception.file.FileNameLengthLimitExceededException;
-import com.zd.common.core.exception.file.FileSizeLimitExceededException;
-import com.zd.common.core.exception.file.InvalidExtensionException;
-import com.zd.common.core.utils.DateUtils;
-import com.zd.common.core.utils.IdUtils;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.common.core.utils.file.MimeTypeUtils;
-
-/**
- * 文件上传工具类
- *
- * @author zd
- */
-public class FileUploadUtils {
-    /**
-     * 默认大小 50M
-     */
-    public static final long DEFAULT_MAX_SIZE = 3000000 * 1024 * 1024;
-
-    /**
-     * 默认的文件名最大长度 100
-     */
-    public static final int DEFAULT_FILE_NAME_LENGTH = 100;
-
-    /**
-     * 根据文件路径上传
-     *
-     * @param baseDir 相对应用的基目录
-     * @param file    上传的文件
-     * @return 文件名称
-     * @throws IOException
-     */
-    public static final String upload(String baseDir, MultipartFile file) throws IOException {
-        try {
-            return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
-        } catch (Exception e) {
-            throw new IOException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * 文件上传
-     *
-     * @param baseDir          相对应用的基目录
-     * @param file             上传的文件
-     * @param allowedExtension 上传文件类型
-     * @return 返回上传成功的文件名
-     * @throws FileSizeLimitExceededException       如果超出最大大小
-     * @throws FileNameLengthLimitExceededException 文件名太长
-     * @throws IOException                          比如读写文件出错时
-     * @throws InvalidExtensionException            文件校验异常
-     */
-    public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
-            throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
-            InvalidExtensionException {
-        int fileNamelength = file.getOriginalFilename().length();
-        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
-//            throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
-            throw new ServiceException("图片名字太长,请修改名字后,从新上传!");
-        }
-
-        assertAllowed(file, allowedExtension);
-
-        String fileName = extractFilename(file);
-
-        File desc = getAbsoluteFile(baseDir, fileName);
-        file.transferTo(desc);
-        String pathFileName = getPathFileName(fileName);
-        return pathFileName;
-    }
-//
-//    /**
-//     * 文件上传 -不修改文件名
-//     *
-//     * @param baseDir          相对应用的基目录
-//     * @param file             上传的文件
-//     * @param allowedExtension 上传文件类型
-//     * @return 返回上传成功的文件名
-//     * @throws FileSizeLimitExceededException       如果超出最大大小
-//     * @throws FileNameLengthLimitExceededException 文件名太长
-//     * @throws IOException                          比如读写文件出错时
-//     * @throws InvalidExtensionException            文件校验异常
-//     */
-//    public static final String uploadNoUpdateName(String baseDir, MultipartFile file, String[] allowedExtension)
-//            throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
-//            InvalidExtensionException {
-//        int fileNamelength = file.getOriginalFilename().length();
-//        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
-//            throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
-//        }
-//
-//        assertAllowed(file, allowedExtension);
-//
-////        String fileName = extractFilename(file);
-//
-//        String originalFilename = file.getOriginalFilename();
-//        File desc = getAbsoluteFile(baseDir, originalFilename);
-//        file.transferTo(desc);
-//        String pathFileName = getPathFileName(originalFilename);
-//        return pathFileName;
-//    }
-
-    /**
-     * 编码文件名
-     */
-    public static final String extractFilename(MultipartFile file) {
-        String fileName = file.getOriginalFilename();
-        String extension = getExtension(file);
-        fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
-        return fileName;
-    }
-
-    private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
-        File desc = new File(uploadDir + File.separator + fileName);
-
-        if (!desc.exists()) {
-            if (!desc.getParentFile().exists()) {
-                desc.getParentFile().mkdirs();
-            }
-        }
-        return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
-    }
-
-    private static final String getPathFileName(String fileName) throws IOException {
-        String pathFileName = "/" + fileName;
-        return pathFileName;
-    }
-
-    /**
-     * 文件大小校验
-     *
-     * @param file 上传的文件
-     * @throws FileSizeLimitExceededException 如果超出最大大小
-     * @throws InvalidExtensionException      文件校验异常
-     */
-    public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
-            throws FileSizeLimitExceededException, InvalidExtensionException {
-        long size = file.getSize();
-        if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) {
-            throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
-        }
-
-        String fileName = file.getOriginalFilename();
-        String extension = getExtension(file);
-        if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) {
-            if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) {
-                throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
-                        fileName);
-            } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) {
-                throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
-                        fileName);
-            } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) {
-                throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
-                        fileName);
-            } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) {
-                throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
-                        fileName);
-            } else {
-                throw new InvalidExtensionException(allowedExtension, extension, fileName);
-            }
-        }
-    }
-
-    /**
-     * 判断MIME类型是否是允许的MIME类型
-     *
-     * @param extension        上传文件类型
-     * @param allowedExtension 允许上传文件类型
-     * @return true/false
-     */
-    public static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
-        for (String str : allowedExtension) {
-            if (str.equalsIgnoreCase(extension)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 获取文件名的后缀
-     *
-     * @param file 表单文件
-     * @return 后缀名
-     */
-    public static final String getExtension(MultipartFile file) {
-        String extension = FilenameUtils.getExtension(file.getOriginalFilename());
-        if (StringUtils.isEmpty(extension)) {
-            extension = MimeTypeUtils.getExtension(file.getContentType());
-        }
-        return extension;
-    }
-}

+ 0 - 124
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/ActionEnter.java

@@ -1,124 +0,0 @@
-package com.zd.ueditor;
-
-import com.alibaba.fastjson.JSONObject;
-import com.zd.ueditor.define.ActionMap;
-import com.zd.ueditor.define.BaseState;
-import com.zd.ueditor.define.State;
-import com.zd.ueditor.hunter.FileManager;
-import com.zd.ueditor.hunter.ImageHunter;
-import com.zd.ueditor.upload.Uploader;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Map;
-
-public class ActionEnter {
-    private HttpServletRequest request;
-    private String rootPath;
-    private String contextPath;
-    private String actionType;
-    private String localFilePath;
-    private String localFilePrefix;
-    private String domain;
-    private ConfigManager configManager;
-
-    public ActionEnter(HttpServletRequest request, String rootPath,String localFilePath,String localFilePrefix,String domain) {
-        this.request = null;
-        this.rootPath = null;
-        this.contextPath = null;
-        this.actionType = null;
-        this.configManager = null;
-        this.localFilePath=localFilePath;
-        this.localFilePrefix=localFilePrefix;
-        this.domain=domain;
-        this.request = request;
-        this.rootPath = rootPath;
-        this.actionType = request.getParameter("action");
-        this.contextPath = request.getContextPath();
-        this.configManager = ConfigManager.getInstance(this.rootPath, this.contextPath, request.getRequestURI(),localFilePath);
-    }
-
-    public String exec() {
-        String callbackName = this.request.getParameter("callback");
-        if (callbackName == null) {
-            return this.invoke();
-        }
-        if (!this.validCallbackName(callbackName)) {
-            return new BaseState(false, 401).toJSONString();
-        }
-        return callbackName + "(" + this.invoke() + ");";
-    }
-
-    public String invoke() {
-        if (this.actionType == null || !ActionMap.mapping.containsKey(this.actionType)) {
-            return new BaseState(false, 101).toJSONString();
-        }
-        if (this.configManager == null || !this.configManager.valid()) {
-            return new BaseState(false, 102).toJSONString();
-        }
-        State state = null;
-        int actionCode = ActionMap.getType(this.actionType);
-        Map<String, Object> conf = null;
-        switch (actionCode) {
-            case 0: {
-                return this.configManager.getAllConfig().toString();
-            }
-            case 1:
-            case 2:
-            case 3:
-            case 4: {
-                conf = this.configManager.getConfig(actionCode);
-                state = new Uploader(this.request, conf).doExec();
-                String localIP = "127.0.0.1";
-                String urlPrefix=this.domain;
-                String jsonStr=state.toJSONString();
-                JSONObject jsonObject=JSONObject.parseObject(jsonStr);
-                String url=getIpUrl(localIP, urlPrefix, localFilePrefix);
-                state.putInfo("url",url+jsonObject.getString("url"));
-                break;
-            }
-            case 5: {
-                conf = this.configManager.getConfig(actionCode);
-                String[] list = this.request.getParameterValues((String) conf.get("fieldName"));
-                state = new ImageHunter(conf).capture(list);
-                break;
-            }
-            case 6:
-            case 7: {
-                conf = this.configManager.getConfig(actionCode);
-                conf.put("domain",this.domain);
-                conf.put("localFilePrefix",this.localFilePrefix);
-                int start = this.getStartIndex();
-                state = new FileManager(conf).listFile(start);
-                break;
-            }
-        }
-        return state.toJSONString();
-    }
-
-    public static String getIpUrl(String localIP, String urlPrefix, String localFilePrefix) {
-//        if (urlPrefix.contains(localIP)) {
-//            String ip= null;
-//            try {
-//                ip = InetAddress.getLocalHost().getHostAddress();
-//            } catch (UnknownHostException e) {
-//                ip="";
-//                e.printStackTrace();
-//            }
-//            urlPrefix = urlPrefix.replace(localIP, ip);
-//        }
-        return localFilePrefix;
-    }
-
-    public int getStartIndex() {
-        String start = this.request.getParameter("start");
-        try {
-            return Integer.parseInt(start);
-        } catch (Exception e) {
-            return 0;
-        }
-    }
-
-    public boolean validCallbackName(String name) {
-        return name.matches("^[a-zA-Z_]+[\\w0-9_]*$");
-    }
-}

+ 0 - 160
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/ConfigManager.java

@@ -1,160 +0,0 @@
-package com.zd.ueditor;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
-
-public class ConfigManager {
-    private String rootPath;
-    private String originalPath;
-    private String contextPath;
-    private String realPath;
-    private static String configFileName = "config.json";
-    private String parentPath;
-    private JSONObject jsonConfig;
-    private static String SCRAWL_FILE_NAME = "scrawl";
-    private static String REMOTE_FILE_NAME = "remote";
-
-    private ConfigManager(String rootPath, String contextPath, String uri,String realPath) throws FileNotFoundException, IOException {
-        this.parentPath = null;
-        this.jsonConfig = null;
-        rootPath = rootPath.replace("\\", "/");
-        this.rootPath = rootPath;
-        this.realPath = realPath;
-        this.contextPath = contextPath;
-        if (contextPath.length() > 0) {
-            this.originalPath = this.rootPath + uri.substring(contextPath.length());
-        } else {
-            this.originalPath = this.rootPath + uri;
-        }
-        this.initEnv();
-    }
-
-    public static ConfigManager getInstance(String rootPath, String contextPath, String uri,String realPath) {
-        try {
-            return new ConfigManager(rootPath, contextPath, uri,realPath);
-        } catch (Exception e) {
-            return null;
-        }
-    }
-
-    public boolean valid() {
-        return this.jsonConfig != null;
-    }
-
-    public JSONObject getAllConfig() {
-        return this.jsonConfig;
-    }
-
-    public Map<String, Object> getConfig(int type) {
-        Map<String, Object> conf = new HashMap<String, Object>();
-        String savePath = null;
-        switch (type) {
-            case 4: {
-                conf.put("isBase64", "false");
-                conf.put("maxSize", this.jsonConfig.getLong("fileMaxSize"));
-                conf.put("allowFiles", this.getArray("fileAllowFiles"));
-                conf.put("fieldName", this.jsonConfig.getString("fileFieldName"));
-                savePath = this.jsonConfig.getString("filePathFormat");
-                break;
-            }
-            case 1: {
-                conf.put("isBase64", "false");
-                conf.put("maxSize", this.jsonConfig.getLong("imageMaxSize"));
-                conf.put("allowFiles", this.getArray("imageAllowFiles"));
-                conf.put("fieldName", this.jsonConfig.getString("imageFieldName"));
-                savePath = this.jsonConfig.getString("imagePathFormat");
-                break;
-            }
-            case 3: {
-                conf.put("maxSize", this.jsonConfig.getLong("videoMaxSize"));
-                conf.put("allowFiles", this.getArray("videoAllowFiles"));
-                conf.put("fieldName", this.jsonConfig.getString("videoFieldName"));
-                savePath = this.jsonConfig.getString("videoPathFormat");
-                break;
-            }
-            case 2: {
-                conf.put("filename", "scrawl");
-                conf.put("maxSize", this.jsonConfig.getLong("scrawlMaxSize"));
-                conf.put("fieldName", this.jsonConfig.getString("scrawlFieldName"));
-                conf.put("isBase64", "true");
-                savePath = this.jsonConfig.getString("scrawlPathFormat");
-                break;
-            }
-            case 5: {
-                conf.put("filename", "remote");
-                conf.put("filter", this.getArray("catcherLocalDomain"));
-                conf.put("maxSize", this.jsonConfig.getLong("catcherMaxSize"));
-                conf.put("allowFiles", this.getArray("catcherAllowFiles"));
-                conf.put("fieldName", String.valueOf(this.jsonConfig.getString("catcherFieldName")) + "[]");
-                savePath = this.jsonConfig.getString("catcherPathFormat");
-                break;
-            }
-            case 7: {
-                conf.put("allowFiles", this.getArray("imageManagerAllowFiles"));
-                conf.put("dir", this.jsonConfig.getString("imageManagerListPath"));
-                conf.put("count", this.jsonConfig.getInt("imageManagerListSize"));
-                break;
-            }
-            case 6: {
-                conf.put("allowFiles", this.getArray("fileManagerAllowFiles"));
-                conf.put("dir", this.jsonConfig.getString("fileManagerListPath"));
-                conf.put("count", this.jsonConfig.getInt("fileManagerListSize"));
-                break;
-            }
-        }
-        conf.put("savePath", savePath);
-        conf.put("rootPath", this.realPath);
-        return conf;
-    }
-
-    private void initEnv() throws FileNotFoundException, IOException {
-        File file = new File(this.originalPath);
-        if (!file.isAbsolute()) {
-            file = new File(file.getAbsolutePath());
-        }
-        this.parentPath = file.getParent();
-        String configContent = this.readFile(this.getConfigPath());
-        try {
-            JSONObject jsonConfig = new JSONObject(configContent);
-            this.jsonConfig = jsonConfig;
-        } catch (Exception e) {
-            this.jsonConfig = null;
-        }
-    }
-
-    private String getConfigPath() {
-        return String.valueOf(this.parentPath) + File.separator + "config.json";
-    }
-
-    private String[] getArray(String key) {
-        JSONArray jsonArray = this.jsonConfig.getJSONArray(key);
-        String[] result = new String[jsonArray.length()];
-        for (int i = 0, len = jsonArray.length(); i < len; ++i) {
-            result[i] = jsonArray.getString(i);
-        }
-        return result;
-    }
-
-    private String readFile(String path) throws IOException {
-        StringBuilder builder = new StringBuilder();
-        try {
-            InputStreamReader reader = new InputStreamReader(new FileInputStream(path), "UTF-8");
-            BufferedReader bfReader = new BufferedReader(reader);
-            String tmpContent = null;
-            while ((tmpContent = bfReader.readLine()) != null) {
-                builder.append(tmpContent);
-            }
-            bfReader.close();
-        } catch (UnsupportedEncodingException ex) {
-        }
-        return this.filter(builder.toString());
-    }
-
-    private String filter(String input) {
-        return input.replaceAll("/\\*[\\s\\S]*?\\*/", "");
-    }
-}

+ 0 - 18
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/Encoder.java

@@ -1,18 +0,0 @@
-package com.zd.ueditor;
-
-public class Encoder {
-    public static String toUnicode(String input) {
-        StringBuilder builder = new StringBuilder();
-        char[] chars = input.toCharArray();
-        char[] array;
-        for (int length = (array = chars).length, i = 0; i < length; ++i) {
-            char ch = array[i];
-            if (ch < '\u0100') {
-                builder.append(ch);
-            } else {
-                builder.append("\\u" + Integer.toHexString(ch & '\uffff'));
-            }
-        }
-        return builder.toString();
-    }
-}

+ 0 - 131
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/PathFormat.java

@@ -1,131 +0,0 @@
-package com.zd.ueditor;
-
-import java.util.*;
-import java.util.regex.*;
-import java.text.*;
-
-public class PathFormat {
-    private static String TIME = "time";
-    private static String FULL_YEAR = "yyyy";
-    private static String YEAR = "yy";
-    private static String MONTH = "mm";
-    private static String DAY = "dd";
-    private static String HOUR = "hh";
-    private static String MINUTE = "ii";
-    private static String SECOND = "ss";
-    private static String RAND = "rand";
-    private static Date currentDate;
-
-    static {
-        PathFormat.currentDate = null;
-    }
-
-    public static String parse(String input) {
-        Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}", 2);
-        Matcher matcher = pattern.matcher(input);
-        PathFormat.currentDate = new Date();
-        StringBuffer sb = new StringBuffer();
-        while (matcher.find()) {
-            matcher.appendReplacement(sb, getString(matcher.group(1)));
-        }
-        matcher.appendTail(sb);
-        return sb.toString();
-    }
-
-    public static String format(String input) {
-        return input.replace("\\", "/");
-    }
-
-    public static String parse(String input, String filename) {
-        Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}", 2);
-        Matcher matcher = pattern.matcher(input);
-        String matchStr = null;
-        PathFormat.currentDate = new Date();
-        StringBuffer sb = new StringBuffer();
-        while (matcher.find()) {
-            matchStr = matcher.group(1);
-            if (matchStr.indexOf("filename") != -1) {
-                filename = filename.replace("$", "\\$").replaceAll("[\\/:*?\"<>|]", "");
-                matcher.appendReplacement(sb, filename);
-            } else {
-                matcher.appendReplacement(sb, getString(matchStr));
-            }
-        }
-        matcher.appendTail(sb);
-        return sb.toString();
-    }
-
-    private static String getString(String pattern) {
-        pattern = pattern.toLowerCase();
-        if (pattern.indexOf("time") != -1) {
-            return getTimestamp();
-        }
-        if (pattern.indexOf("yyyy") != -1) {
-            return getFullYear();
-        }
-        if (pattern.indexOf("yy") != -1) {
-            return getYear();
-        }
-        if (pattern.indexOf("mm") != -1) {
-            return getMonth();
-        }
-        if (pattern.indexOf("dd") != -1) {
-            return getDay();
-        }
-        if (pattern.indexOf("hh") != -1) {
-            return getHour();
-        }
-        if (pattern.indexOf("ii") != -1) {
-            return getMinute();
-        }
-        if (pattern.indexOf("ss") != -1) {
-            return getSecond();
-        }
-        if (pattern.indexOf("rand") != -1) {
-            return getRandom(pattern);
-        }
-        return pattern;
-    }
-
-    private static String getTimestamp() {
-        return new StringBuilder(String.valueOf(System.currentTimeMillis())).toString();
-    }
-
-    private static String getFullYear() {
-        return new SimpleDateFormat("yyyy").format(PathFormat.currentDate);
-    }
-
-    private static String getYear() {
-        return new SimpleDateFormat("yy").format(PathFormat.currentDate);
-    }
-
-    private static String getMonth() {
-        return new SimpleDateFormat("MM").format(PathFormat.currentDate);
-    }
-
-    private static String getDay() {
-        return new SimpleDateFormat("dd").format(PathFormat.currentDate);
-    }
-
-    private static String getHour() {
-        return new SimpleDateFormat("HH").format(PathFormat.currentDate);
-    }
-
-    private static String getMinute() {
-        return new SimpleDateFormat("mm").format(PathFormat.currentDate);
-    }
-
-    private static String getSecond() {
-        return new SimpleDateFormat("ss").format(PathFormat.currentDate);
-    }
-
-    private static String getRandom(String pattern) {
-        int length = 0;
-        pattern = pattern.split(":")[1].trim();
-        length = Integer.parseInt(pattern);
-        return new StringBuilder(String.valueOf(Math.random())).toString().replace(".", "").substring(0, length);
-    }
-
-    public static void main(String[] args) {
-    }
-}

+ 0 - 23
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/SpringUtil.java

@@ -1,23 +0,0 @@
-package com.zd.ueditor;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SpringUtil implements ApplicationContextAware {
-
-    private static ApplicationContext applicationContext;
-
-    @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        if (SpringUtil.applicationContext == null) {
-            SpringUtil.applicationContext = applicationContext;
-        }
-    }
-
-    public static ApplicationContext getApplicationContext() {
-        return applicationContext;
-    }
-}

+ 0 - 56
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/contorller/UeditorController.java

@@ -1,56 +0,0 @@
-package com.zd.ueditor.contorller;
-
-import com.alibaba.fastjson.JSONException;
-import com.zd.ueditor.ActionEnter;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * 用于处理关于ueditor插件相关的请求
- *
- * @date 2017-11-29
- */
-@Controller
-public class UeditorController {
-
-    @Value("${file.config}")
-    private String rootConfig;
-
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String localFilePath;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String localFilePrefix;
-
-
-    @Value("${file.domain}")
-    public String domain;
-
-
-    @RequestMapping("exec")
-    public void getConfigInfo(HttpServletRequest request, HttpServletResponse response) {
-        try {
-            request.setCharacterEncoding("utf-8");
-            response.setContentType("application/json");
-            String exec = new ActionEnter(request, rootConfig,localFilePath,localFilePrefix,domain).exec();
-            PrintWriter writer = response.getWriter();
-            writer.write(exec);
-            writer.flush();
-            writer.close();
-        } catch (IOException | JSONException e) {
-            e.printStackTrace();
-        }
-    }
-}

+ 0 - 34
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/ActionMap.java

@@ -1,34 +0,0 @@
-package com.zd.ueditor.define;
-
-import java.util.*;
-
-public final class ActionMap {
-    public static final Map<String, Integer> mapping;
-    public static final int CONFIG = 0;
-    public static final int UPLOAD_IMAGE = 1;
-    public static final int UPLOAD_SCRAWL = 2;
-    public static final int UPLOAD_VIDEO = 3;
-    public static final int UPLOAD_FILE = 4;
-    public static final int CATCH_IMAGE = 5;
-    public static final int LIST_FILE = 6;
-    public static final int LIST_IMAGE = 7;
-
-    static {
-        mapping = new HashMap<String, Integer>() {
-            {
-                this.put("config", 0);
-                this.put("uploadimage", 1);
-                this.put("uploadscrawl", 2);
-                this.put("uploadvideo", 3);
-                this.put("uploadfile", 4);
-                this.put("catchimage", 5);
-                this.put("listfile", 6);
-                this.put("listimage", 7);
-            }
-        };
-    }
-
-    public static int getType(final String key) {
-        return ActionMap.mapping.get(key);
-    }
-}

+ 0 - 8
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/ActionState.java

@@ -1,8 +0,0 @@
-package com.zd.ueditor.define;
-
-public enum ActionState {
-    UNKNOW_ERROR("UNKNOW_ERROR", 0);
-
-    private ActionState(String s,int n) {
-    }
-}

+ 0 - 52
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/AppInfo.java

@@ -1,52 +0,0 @@
-package com.zd.ueditor.define;
-
-import java.util.*;
-
-public final class AppInfo {
-    public static final int SUCCESS = 0;
-    public static final int MAX_SIZE = 1;
-    public static final int PERMISSION_DENIED = 2;
-    public static final int FAILED_CREATE_FILE = 3;
-    public static final int IO_ERROR = 4;
-    public static final int NOT_MULTIPART_CONTENT = 5;
-    public static final int PARSE_REQUEST_ERROR = 6;
-    public static final int NOTFOUND_UPLOAD_DATA = 7;
-    public static final int NOT_ALLOW_FILE_TYPE = 8;
-    public static final int INVALID_ACTION = 101;
-    public static final int CONFIG_ERROR = 102;
-    public static final int PREVENT_HOST = 201;
-    public static final int CONNECTION_ERROR = 202;
-    public static final int REMOTE_FAIL = 203;
-    public static final int NOT_DIRECTORY = 301;
-    public static final int NOT_EXIST = 302;
-    public static final int ILLEGAL = 401;
-    public static Map<Integer, String> info;
-
-    static {
-        AppInfo.info = new HashMap<Integer, String>() {
-            {
-                this.put(0, "SUCCESS");
-                this.put(101, "\u65e0\u6548\u7684Action");
-                this.put(102, "\u914d\u7f6e\u6587\u4ef6\u521d\u59cb\u5316\u5931\u8d25");
-                this.put(203, "\u6293\u53d6\u8fdc\u7a0b\u56fe\u7247\u5931\u8d25");
-                this.put(201, "\u88ab\u963b\u6b62\u7684\u8fdc\u7a0b\u4e3b\u673a");
-                this.put(202, "\u8fdc\u7a0b\u8fde\u63a5\u51fa\u9519");
-                this.put(1, "\u6587\u4ef6\u5927\u5c0f\u8d85\u51fa\u9650\u5236");
-                this.put(2, "\u6743\u9650\u4e0d\u8db3");
-                this.put(3, "\u521b\u5efa\u6587\u4ef6\u5931\u8d25");
-                this.put(4, "IO\u9519\u8bef");
-                this.put(5, "\u4e0a\u4f20\u8868\u5355\u4e0d\u662fmultipart/form-data\u7c7b\u578b");
-                this.put(6, "\u89e3\u6790\u4e0a\u4f20\u8868\u5355\u9519\u8bef");
-                this.put(7, "\u672a\u627e\u5230\u4e0a\u4f20\u6570\u636e");
-                this.put(8, "\u4e0d\u5141\u8bb8\u7684\u6587\u4ef6\u7c7b\u578b");
-                this.put(301, "\u6307\u5b9a\u8def\u5f84\u4e0d\u662f\u76ee\u5f55");
-                this.put(302, "\u6307\u5b9a\u8def\u5f84\u5e76\u4e0d\u5b58\u5728");
-                this.put(401, "Callback\u53c2\u6570\u540d\u4e0d\u5408\u6cd5");
-            }
-        };
-    }
-
-    public static String getStateInfo(final int key) {
-        return AppInfo.info.get(key);
-    }
-}

+ 0 - 90
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/BaseState.java

@@ -1,90 +0,0 @@
-package com.zd.ueditor.define;
-
-import com.zd.ueditor.Encoder;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class BaseState implements State {
-    private boolean state;
-    private String info;
-    private Map<String, String> infoMap;
-
-    public BaseState() {
-        this.state = false;
-        this.info = null;
-        this.infoMap = new HashMap<String, String>();
-        this.state = true;
-    }
-
-    public BaseState(final boolean state) {
-        this.state = false;
-        this.info = null;
-        this.infoMap = new HashMap<String, String>();
-        this.setState(state);
-    }
-
-    public BaseState(final boolean state, final String info) {
-        this.state = false;
-        this.info = null;
-        this.infoMap = new HashMap<String, String>();
-        this.setState(state);
-        this.info = info;
-    }
-
-    public BaseState(final boolean state, final int infoCode) {
-        this.state = false;
-        this.info = null;
-        this.infoMap = new HashMap<String, String>();
-        this.setState(state);
-        this.info = AppInfo.getStateInfo(infoCode);
-    }
-
-    @Override
-    public boolean isSuccess() {
-        return this.state;
-    }
-
-    public void setState(final boolean state) {
-        this.state = state;
-    }
-
-    public void setInfo(final String info) {
-        this.info = info;
-    }
-
-    public void setInfo(final int infoCode) {
-        this.info = AppInfo.getStateInfo(infoCode);
-    }
-
-    @Override
-    public String toJSONString() {
-        return this.toString();
-    }
-
-    @Override
-    public String toString() {
-        String key = null;
-        final String stateVal = this.isSuccess() ? AppInfo.getStateInfo(0) : this.info;
-        final StringBuilder builder = new StringBuilder();
-        builder.append("{\"state\": \"" + stateVal + "\"");
-        final Iterator<String> iterator = this.infoMap.keySet().iterator();
-        while (iterator.hasNext()) {
-            key = iterator.next();
-            builder.append(",\"" + key + "\": \"" + this.infoMap.get(key) + "\"");
-        }
-        builder.append("}");
-        return Encoder.toUnicode(builder.toString());
-    }
-
-    @Override
-    public void putInfo(final String name, final String val) {
-        this.infoMap.put(name, val);
-    }
-
-    @Override
-    public void putInfo(final String name, final long val) {
-        this.putInfo(name, new StringBuilder(String.valueOf(val)).toString());
-    }
-}

+ 0 - 24
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/FileType.java

@@ -1,24 +0,0 @@
-package com.zd.ueditor.define;
-
-import java.util.*;
-
-public class FileType {
-    public static final String JPG = "JPG";
-    private static final Map<String, String> types;
-
-    static {
-        types = new HashMap<String, String>() {
-            {
-                this.put("JPG", ".jpg");
-            }
-        };
-    }
-
-    public static String getSuffix(final String key) {
-        return FileType.types.get(key);
-    }
-
-    public static String getSuffixByFilename(final String filename) {
-        return filename.substring(filename.lastIndexOf(".")).toLowerCase();
-    }
-}

+ 0 - 23
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/MIMEType.java

@@ -1,23 +0,0 @@
-package com.zd.ueditor.define;
-
-import java.util.*;
-
-public class MIMEType {
-    public static final Map<String, String> types;
-
-    static {
-        types = new HashMap<String, String>() {
-            {
-                this.put("image/gif", ".gif");
-                this.put("image/jpeg", ".jpg");
-                this.put("image/jpg", ".jpg");
-                this.put("image/png", ".png");
-                this.put("image/bmp", ".bmp");
-            }
-        };
-    }
-
-    public static String getSuffix(final String mime) {
-        return MIMEType.types.get(mime);
-    }
-}

+ 0 - 88
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/MultiState.java

@@ -1,88 +0,0 @@
-package com.zd.ueditor.define;
-
-import com.zd.ueditor.Encoder;
-
-import java.util.*;
-
-public class MultiState implements State {
-    private boolean state;
-    private String info;
-    private Map<String, Long> intMap;
-    private Map<String, String> infoMap;
-    private List<String> stateList;
-
-    public MultiState(final boolean state) {
-        this.state = false;
-        this.info = null;
-        this.intMap = new HashMap<String, Long>();
-        this.infoMap = new HashMap<String, String>();
-        this.stateList = new ArrayList<String>();
-        this.state = state;
-    }
-
-    public MultiState(final boolean state, final String info) {
-        this.state = false;
-        this.info = null;
-        this.intMap = new HashMap<String, Long>();
-        this.infoMap = new HashMap<String, String>();
-        this.stateList = new ArrayList<String>();
-        this.state = state;
-        this.info = info;
-    }
-
-    public MultiState(final boolean state, final int infoKey) {
-        this.state = false;
-        this.info = null;
-        this.intMap = new HashMap<String, Long>();
-        this.infoMap = new HashMap<String, String>();
-        this.stateList = new ArrayList<String>();
-        this.state = state;
-        this.info = AppInfo.getStateInfo(infoKey);
-    }
-
-    @Override
-    public boolean isSuccess() {
-        return this.state;
-    }
-
-    public void addState(final State state) {
-        this.stateList.add(state.toJSONString());
-    }
-
-    @Override
-    public void putInfo(final String name, final String val) {
-        this.infoMap.put(name, val);
-    }
-
-    @Override
-    public String toJSONString() {
-        String stateVal = this.isSuccess() ? AppInfo.getStateInfo(0) : this.info;
-        final StringBuilder builder = new StringBuilder();
-        builder.append("{\"state\": \"" + stateVal + "\"");
-        Iterator<String> iterator = this.intMap.keySet().iterator();
-        while (iterator.hasNext()) {
-            stateVal = iterator.next();
-            builder.append(",\"" + stateVal + "\": " + this.intMap.get(stateVal));
-        }
-        iterator = this.infoMap.keySet().iterator();
-        while (iterator.hasNext()) {
-            stateVal = iterator.next();
-            builder.append(",\"" + stateVal + "\": \"" + this.infoMap.get(stateVal) + "\"");
-        }
-        builder.append(", list: [");
-        iterator = this.stateList.iterator();
-        while (iterator.hasNext()) {
-            builder.append(String.valueOf(iterator.next()) + ",");
-        }
-        if (this.stateList.size() > 0) {
-            builder.deleteCharAt(builder.length() - 1);
-        }
-        builder.append(" ]}");
-        return Encoder.toUnicode(builder.toString());
-    }
-
-    @Override
-    public void putInfo(final String name, final long val) {
-        this.intMap.put(name, val);
-    }
-}

+ 0 - 11
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/define/State.java

@@ -1,11 +0,0 @@
-package com.zd.ueditor.define;
-
-public interface State {
-    boolean isSuccess();
-
-    void putInfo(String p0,String p1);
-
-    void putInfo(String p0,long p1);
-
-    String toJSONString();
-}

+ 0 - 102
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/hunter/FileManager.java

@@ -1,102 +0,0 @@
-package com.zd.ueditor.hunter;
-
-import com.zd.ueditor.ActionEnter;
-import com.zd.ueditor.define.BaseState;
-import com.zd.ueditor.define.MultiState;
-import com.zd.ueditor.define.State;
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-
-
-public class FileManager {
-    private String dir;
-    private String rootPath;
-    private String[] allowFiles;
-    private int count;
-    private String domain;
-    private String localFilePrefix;
-
-    public FileManager(Map<String, Object> conf) {
-        this.dir = null;
-        this.rootPath = null;
-        this.allowFiles = null;
-        this.count = 0;
-        this.domain=String.valueOf(conf.get("domain"));
-        this.localFilePrefix=String.valueOf(conf.get("localFilePrefix"));
-        this.rootPath = String.valueOf(conf.get("rootPath"));
-        this.dir = String.valueOf(this.rootPath) + conf.get("dir");
-        this.allowFiles = this.getAllowFiles(conf.get("allowFiles"));
-        this.count = Integer.parseInt(conf.get("count") + "");
-    }
-
-    public State listFile(int index) {
-        File dir = new File(this.dir);
-        State state = null;
-        if (!dir.exists()) {
-            return new BaseState(false, 302);
-        }
-        if (!dir.isDirectory()) {
-            return new BaseState(false, 301);
-        }
-        Collection<File> list = (Collection<File>) FileUtils.listFiles(dir, this.allowFiles, true);
-        if (index < 0 || index > list.size()) {
-            state = new MultiState(true);
-        } else {
-            Object[] fileList = Arrays.copyOfRange(list.toArray(), index, index + this.count);
-            state = this.getState(fileList);
-        }
-        state.putInfo("start", index);
-        state.putInfo("total", list.size());
-        return state;
-    }
-
-    private State getState(Object[] files) {
-        MultiState state = new MultiState(true);
-        BaseState fileState = null;
-        File file = null;
-        for (Object obj : files) {
-            if (obj == null) {
-                break;
-            }
-            file = (File) obj;
-            String realPath = file.getAbsolutePath();
-            String oSystem=System.getProperty("os.name").toLowerCase();
-            if(oSystem.equals("windows")){
-                String changePath=rootPath.replace("/","\\");
-                realPath=realPath.replace(changePath,"/").replace("\\","/");
-            }else{
-                realPath=realPath.replace(rootPath,"/");
-            }
-            String urlPrefix=this.domain;
-            String localIP="127.0.0.1";
-            String url=ActionEnter.getIpUrl(localIP, urlPrefix, localFilePrefix);
-            fileState = new BaseState(true);
-            fileState.putInfo("url", url+realPath);
-            state.addState(fileState);
-        }
-        return state;
-    }
-
-    private String getPath(File file) {
-        String path = file.getAbsolutePath();
-        return path.replace(this.rootPath, "/");
-    }
-
-    private String[] getAllowFiles(Object fileExt) {
-        String[] exts = null;
-        String ext = null;
-        if (fileExt == null) {
-            return new String[0];
-        }
-        exts = (String[]) fileExt;
-        for (int i = 0, len = exts.length; i < len; ++i) {
-            ext = exts[i];
-            exts[i] = ext.replace(".", "");
-        }
-        return exts;
-    }
-}

+ 0 - 111
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/hunter/ImageHunter.java

@@ -1,111 +0,0 @@
-package com.zd.ueditor.hunter;
-
-import com.zd.ueditor.PathFormat;
-import com.zd.ueditor.define.BaseState;
-import com.zd.ueditor.define.MIMEType;
-import com.zd.ueditor.define.MultiState;
-import com.zd.ueditor.define.State;
-import com.zd.ueditor.upload.StorageManager;
-
-import java.net.HttpURLConnection;
-import java.net.InetAddress;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-public class ImageHunter {
-    private String filename;
-    private String savePath;
-    private String rootPath;
-    private List<String> allowTypes;
-    private long maxSize;
-    private List<String> filters;
-
-    public ImageHunter(Map<String, Object> conf) {
-        this.filename = null;
-        this.savePath = null;
-        this.rootPath = null;
-        this.allowTypes = null;
-        this.maxSize = -1L;
-        this.filters = null;
-        this.filename = String.valueOf(conf.get("filename"));
-        this.savePath = String.valueOf(conf.get("savePath"));
-        this.rootPath = String.valueOf(conf.get("rootPath"));
-        this.maxSize = Long.parseLong(conf.get("maxSize") + "");
-        this.allowTypes = Arrays.asList((String[]) conf.get("allowFiles"));
-        this.filters = Arrays.asList((String[]) conf.get("filter"));
-    }
-
-    public State capture(String[] list) {
-        MultiState state = new MultiState(true);
-        for (String source : list) {
-            state.addState(this.captureRemoteData(source));
-        }
-        return state;
-    }
-
-    public State captureRemoteData(String urlStr) {
-        HttpURLConnection connection = null;
-        URL url = null;
-        String suffix = null;
-        try {
-            url = new URL(urlStr);
-            if (!this.validHost(url.getHost())) {
-                return new BaseState(false, 201);
-            }
-            connection = (HttpURLConnection) url.openConnection();
-            connection.setInstanceFollowRedirects(true);
-            connection.setUseCaches(true);
-            if (!this.validContentState(connection.getResponseCode())) {
-                return new BaseState(false, 202);
-            }
-            suffix = MIMEType.getSuffix(connection.getContentType());
-            if (!this.validFileType(suffix)) {
-                return new BaseState(false, 8);
-            }
-            if (!this.validFileSize(connection.getContentLength())) {
-                return new BaseState(false, 1);
-            }
-            String savePath = this.getPath(this.savePath, this.filename, suffix);
-            String physicalPath = this.rootPath + savePath;
-            State state = StorageManager.saveFileByInputStream(connection.getInputStream(), physicalPath);
-            if (state.isSuccess()) {
-                state.putInfo("url", PathFormat.format(savePath));
-                state.putInfo("source", urlStr);
-            }
-            return state;
-        } catch (Exception e) {
-            return new BaseState(false, 203);
-        }
-    }
-
-    private String getPath(String savePath, String filename, String suffix) {
-        return PathFormat.parse(savePath + suffix, filename);
-    }
-
-    private boolean validHost(String hostname) {
-        try {
-            InetAddress ip = InetAddress.getByName(hostname);
-            if (ip.isSiteLocalAddress()) {
-                return false;
-            }
-        } catch (UnknownHostException e) {
-            return false;
-        }
-        return !this.filters.contains(hostname);
-    }
-
-    private boolean validContentState(int code) {
-        return 200 == code;
-    }
-
-    private boolean validFileType(String type) {
-        return this.allowTypes.contains(type);
-    }
-
-    private boolean validFileSize(int size) {
-        return size < this.maxSize;
-    }
-}

+ 0 - 38
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/Base64Uploader.java

@@ -1,38 +0,0 @@
-package com.zd.ueditor.upload;
-
-import com.zd.ueditor.PathFormat;
-import com.zd.ueditor.define.BaseState;
-import com.zd.ueditor.define.FileType;
-import com.zd.ueditor.define.State;
-import org.apache.commons.codec.binary.Base64;
-
-import java.util.Map;
-
-public class Base64Uploader {
-    public static State save(String content, Map<String, Object> conf) {
-        byte[] data = decode(content);
-        long maxSize = Long.parseLong(conf.get("maxSize") + "");
-        if (!validSize(data, maxSize)) {
-            return new BaseState(false, 1);
-        }
-        String suffix = FileType.getSuffix("JPG");
-        String savePath = PathFormat.parse(String.valueOf(conf.get("savePath")), String.valueOf(conf.get("filename")));
-        savePath = savePath + suffix;
-        String physicalPath = conf.get("rootPath") + savePath;
-        State storageState = StorageManager.saveBinaryFile(data, physicalPath);
-        if (storageState.isSuccess()) {
-            storageState.putInfo("url", PathFormat.format(savePath));
-            storageState.putInfo("type", suffix);
-            storageState.putInfo("original", "");
-        }
-        return storageState;
-    }
-
-    private static byte[] decode(String content) {
-        return Base64.decodeBase64(content);
-    }
-
-    private static boolean validSize(byte[] data, long length) {
-        return data.length <= length;
-    }
-}

+ 0 - 65
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/BinaryUploader.java

@@ -1,65 +0,0 @@
-package com.zd.ueditor.upload;
-
-import com.zd.ueditor.PathFormat;
-import com.zd.ueditor.define.BaseState;
-import com.zd.ueditor.define.FileType;
-import com.zd.ueditor.define.State;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-public class BinaryUploader {
-
-    public static State save(HttpServletRequest request, Map<String, Object> conf) {
-        boolean isAjaxUpload = request.getHeader("X_Requested_With") != null;
-        if (!ServletFileUpload.isMultipartContent(request)) {
-            return new BaseState(false, 5);
-        }
-        ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
-        if (isAjaxUpload) {
-            upload.setHeaderEncoding("UTF-8");
-        }
-        try {
-            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-            MultipartFile file = multipartRequest.getFile("upfile");
-            if (file == null) {
-                return new BaseState(false, 7);
-            }
-            String savePath = String.valueOf(conf.get("savePath"));
-            String originFileName = file.getOriginalFilename();
-            String suffix = FileType.getSuffixByFilename(originFileName);
-            originFileName = originFileName.substring(0, originFileName.length() - suffix.length());
-            savePath = savePath + suffix;
-            long maxSize = Long.parseLong(conf.get("maxSize") + "");
-            if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
-                return new BaseState(false, 8);
-            }
-            savePath = PathFormat.parse(savePath, originFileName);
-            String physicalPath = conf.get("rootPath") + savePath;
-            InputStream is = file.getInputStream();
-            State storageState = StorageManager.saveFileByInputStream(is, physicalPath, maxSize);
-            is.close();
-            if (storageState.isSuccess()) {
-                storageState.putInfo("url",PathFormat.format(savePath));
-                storageState.putInfo("type", suffix);
-                storageState.putInfo("original", originFileName + suffix);
-            }
-            return storageState;
-        } catch (IOException ex) {
-            return new BaseState(false, 4);
-        }
-    }
-
-    private static boolean validType(String type, String[] allowTypes) {
-        List<String> list = Arrays.asList(allowTypes);
-        return list.contains(type);
-    }
-}

+ 0 - 120
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/StorageManager.java

@@ -1,120 +0,0 @@
-package com.zd.ueditor.upload;
-
-import com.zd.ueditor.define.BaseState;
-import com.zd.ueditor.define.State;
-import org.apache.commons.io.FileUtils;
-
-import java.io.*;
-
-public class StorageManager
-{
-    public static final int BUFFER_SIZE = 8192;
-
-    public static State saveBinaryFile( byte[] data,  String path) {
-         File file = new File(path);
-        State state = valid(file);
-        if (!state.isSuccess()) {
-            return state;
-        }
-        try {
-             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
-            bos.write(data);
-            bos.flush();
-            bos.close();
-        }
-        catch (IOException ioe) {
-            return new BaseState(false, 4);
-        }
-        state = new BaseState(true, file.getAbsolutePath());
-        state.putInfo("size", data.length);
-        state.putInfo("title", file.getName());
-        return state;
-    }
-
-    public static State saveFileByInputStream( InputStream is,  String path,  long maxSize) {
-        State state = null;
-         File tmpFile = getTmpFile();
-         byte[] dataBuf = new byte[2048];
-         BufferedInputStream bis = new BufferedInputStream(is, 8192);
-        try {
-             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile), 8192);
-            int count = 0;
-            while ((count = bis.read(dataBuf)) != -1) {
-                bos.write(dataBuf, 0, count);
-            }
-            bos.flush();
-            bos.close();
-            if (tmpFile.length() > maxSize) {
-                tmpFile.delete();
-                return new BaseState(false, 1);
-            }
-            state = saveTmpFile(tmpFile, path);
-            if (!state.isSuccess()) {
-                tmpFile.delete();
-            }
-            return state;
-        }
-        catch (IOException ex) {
-            return new BaseState(false, 4);
-        }
-    }
-
-    public static State saveFileByInputStream( InputStream is,  String path) {
-        State state = null;
-         File tmpFile = getTmpFile();
-         byte[] dataBuf = new byte[2048];
-         BufferedInputStream bis = new BufferedInputStream(is, 8192);
-        try {
-             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile), 8192);
-            int count = 0;
-            while ((count = bis.read(dataBuf)) != -1) {
-                bos.write(dataBuf, 0, count);
-            }
-            bos.flush();
-            bos.close();
-            state = saveTmpFile(tmpFile, path);
-            if (!state.isSuccess()) {
-                tmpFile.delete();
-            }
-            return state;
-        }
-        catch (IOException ex) {
-            return new BaseState(false, 4);
-        }
-    }
-
-    private static File getTmpFile() {
-         File tmpDir = FileUtils.getTempDirectory();
-         String tmpFileName = new StringBuilder(String.valueOf(Math.random() * 10000.0)).toString().replace(".", "");
-        return new File(tmpDir, tmpFileName);
-    }
-
-    private static State saveTmpFile( File tmpFile,  String path) {
-        State state = null;
-         File targetFile = new File(path);
-        if (targetFile.canWrite()) {
-            return new BaseState(false, 2);
-        }
-        try {
-            FileUtils.moveFile(tmpFile, targetFile);
-        }
-        catch (IOException e) {
-            return new BaseState(false, 4);
-        }
-        state = new BaseState(true);
-        state.putInfo("size", targetFile.length());
-        state.putInfo("title", targetFile.getName());
-        return state;
-    }
-
-    private static State valid( File file) {
-        File parentPath = file.getParentFile();
-        if (!parentPath.exists() && !parentPath.mkdirs()) {
-            return new BaseState(false, 3);
-        }
-        if (!parentPath.canWrite()) {
-            return new BaseState(false, 2);
-        }
-        return new BaseState(true);
-    }
-}

+ 0 - 60
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/UploadUtils.java

@@ -1,60 +0,0 @@
-package com.zd.ueditor.upload;
-
-import io.netty.util.internal.StringUtil;
-import org.apache.commons.io.FileUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-@Component
-public class UploadUtils {
-
-    private static String filePathStatic;
-
-    @Value("${file.path}")
-    public void setFilePathStatic(String filePath) {
-        this.filePathStatic = filePath;
-    }
-
-    /**
-     * 上传方法
-     *
-     * @param in
-     * @param typePath
-     * @param picName
-     * @return
-     * @throws IOException
-     */
-    public boolean uploadFile(InputStream in, String typePath, String picName) throws IOException {
-        String appendPath = typePath;
-        File filepath = new File(filePathStatic + File.separator + appendPath);
-        if (!filepath.exists()) { //如果不存在则创建
-            filepath.mkdirs();
-        }
-        filepath = new File(filePathStatic + File.separator + appendPath + File.separator + picName);
-        FileUtils.touch(filepath);
-        FileUtils.copyInputStreamToFile(in, filepath);
-        return true;
-    }
-
-
-    /**
-     * 添加上传文件目录
-     *
-     * @param typePath
-     * @return
-     */
-    private String getFilesPath(String typePath) {
-        StringBuilder path = new StringBuilder("/uploadFile");
-        if (StringUtil.isNullOrEmpty(typePath)) {
-            path.append("/uploads");
-        } else {
-            path.append("/" + typePath);
-        }
-        path = path.append("/");
-        return path.toString();
-    }
-}

+ 0 - 29
zd-modules/zd-modules-file/src/main/java/com/zd/ueditor/upload/Uploader.java

@@ -1,29 +0,0 @@
-package com.zd.ueditor.upload;
-
-import com.zd.ueditor.define.State;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Map;
-
-public class Uploader {
-    private HttpServletRequest request;
-    private Map<String, Object> conf;
-
-    public Uploader(HttpServletRequest request, Map<String, Object> conf) {
-        this.request = null;
-        this.conf = null;
-        this.request = request;
-        this.conf = conf;
-    }
-
-    public State doExec() {
-        String filedName = String.valueOf(this.conf.get("fieldName"));
-        State state = null;
-        if ("true".equals(this.conf.get("isBase64"))) {
-            state = Base64Uploader.save(this.request.getParameter(filedName), this.conf);
-        } else {
-            state = BinaryUploader.save(this.request, this.conf);
-        }
-        return state;
-    }
-}

+ 0 - 10
zd-modules/zd-modules-file/src/main/resources/banner.txt

@@ -1,10 +0,0 @@
-Spring Boot Version: ${spring-boot.version}
-Spring Application Name: ${spring.application.name}
-                            _           __  _  _       
-                           (_)         / _|(_)| |      
- _ __  _   _   ___   _   _  _  ______ | |_  _ | |  ___ 
-| '__|| | | | / _ \ | | | || ||______||  _|| || | / _ \
-| |   | |_| || (_) || |_| || |        | |  | || ||  __/
-|_|    \__,_| \___/  \__, ||_|        |_|  |_||_| \___|
-                      __/ |                            
-                     |___/                             

+ 0 - 26
zd-modules/zd-modules-file/src/main/resources/bootstrap.yml

@@ -1,26 +0,0 @@
-# Tomcat
-server:
-  port: 9300
-
-# Spring
-spring:
-  application:
-    # 应用名称
-    name: zd-file
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-      config:
-        # 配置中心地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-        # 配置文件格式
-        file-extension: yml
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-

+ 0 - 68
zd-modules/zd-modules-file/src/main/resources/config.json

@@ -1,68 +0,0 @@
-{
-    "imageActionName": "uploadimage",
-    "imageFieldName": "upfile",
-    "imageMaxSize": 2048000,
-    "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
-    "imageCompressEnable": true,
-    "imageCompressBorder": 1600,
-    "imageInsertAlign": "none",
-    "imageUrlPrefix": "",
-    "localSavePathPrefix":"statics/upload/images/inform",
-    "imagePathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
-    "scrawlActionName": "uploadscrawl",
-    "scrawlFieldName": "upfile",
-    "scrawlPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
-    "scrawlMaxSize": 2048000,
-    "scrawlUrlPrefix": "",
-    "scrawlInsertAlign": "none",
-    "snapscreenActionName": "uploadimage",
-    "snapscreenPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
-    "snapscreenUrlPrefix": "",
-    "snapscreenInsertAlign": "none",
-    "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
-    "catcherActionName": "catchimage",
-    "catcherFieldName": "source",
-    "catcherPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
-    "catcherUrlPrefix": "",
-    "catcherMaxSize": 2048000,
-    "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
-    "catchRemoteImageEnable": false,
-    "videoActionName": "uploadvideo",
-    "videoFieldName": "upfile",
-    "videoPathFormat": "/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}",
-    "videoUrlPrefix": "",
-    "videoMaxSize": 10240000000,
-    "videoAllowFiles": [
-        ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
-        ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"],
-    "fileActionName": "uploadfile",
-    "fileFieldName": "upfile",
-    "filePathFormat": "/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}",
-    "fileUrlPrefix": "",
-    "fileMaxSize": 5120000000,
-    "fileAllowFiles": [
-        ".png", ".jpg", ".jpeg", ".gif", ".bmp",
-        ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
-        ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
-        ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
-        ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
-    ],
-    "imageManagerActionName": "listimage",
-    "imageManagerListPath": "/ueditor/jsp/upload/image/",
-    "imageManagerListSize": 20,
-    "imageManagerUrlPrefix": "",
-    "imageManagerInsertAlign": "none",
-    "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
-    "fileManagerActionName": "listfile",
-    "fileManagerListPath": "/ueditor/jsp/upload/file/",
-    "fileManagerUrlPrefix": "",
-    "fileManagerListSize": 20,
-    "fileManagerAllowFiles": [
-        ".png", ".jpg", ".jpeg", ".gif", ".bmp",
-        ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
-        ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
-        ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
-        ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
-    ]
-
-}

+ 0 - 74
zd-modules/zd-modules-file/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-file"/>
-    <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-    <logger name="com.zd" level="info"/>
-    <!-- Spring日志级别控制  -->
-    <logger name="org.springframework" level="info"/>
-
-    <root level="info">
-        <appender-ref ref="console"/>
-    </root>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info"/>
-        <appender-ref ref="file_error"/>
-    </root>
-</configuration>

+ 0 - 182
zd-modules/zd-modules-file/wait-for-it.sh

@@ -1,182 +0,0 @@
-#!/usr/bin/env bash
-# Use this script to test if a given TCP host/port are available
-
-WAITFORIT_cmdname=${0##*/}
-
-echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
-
-usage()
-{
-    cat << USAGE >&2
-Usage:
-    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-    -h HOST | --host=HOST       Host or IP under test
-    -p PORT | --port=PORT       TCP port under test
-                                Alternatively, you specify the host and port as host:port
-    -s | --strict               Only execute subcommand if the test succeeds
-    -q | --quiet                Don't output any status messages
-    -t TIMEOUT | --timeout=TIMEOUT
-                                Timeout in seconds, zero for no timeout
-    -- COMMAND ARGS             Execute command with args after the test finishes
-USAGE
-    exit 1
-}
-
-wait_for()
-{
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    else
-        echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
-    fi
-    WAITFORIT_start_ts=$(date +%s)
-    while :
-    do
-        if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
-            nc -z $WAITFORIT_HOST $WAITFORIT_PORT
-            WAITFORIT_result=$?
-        else
-            (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
-            WAITFORIT_result=$?
-        fi
-        if [[ $WAITFORIT_result -eq 0 ]]; then
-            WAITFORIT_end_ts=$(date +%s)
-            echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
-            break
-        fi
-        sleep 1
-    done
-    return $WAITFORIT_result
-}
-
-wait_for_wrapper()
-{
-    # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
-    if [[ $WAITFORIT_QUIET -eq 1 ]]; then
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    else
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    fi
-    WAITFORIT_PID=$!
-    trap "kill -INT -$WAITFORIT_PID" INT
-    wait $WAITFORIT_PID
-    WAITFORIT_RESULT=$?
-    if [[ $WAITFORIT_RESULT -ne 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    fi
-    return $WAITFORIT_RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]
-do
-    case "$1" in
-        *:* )
-        WAITFORIT_hostport=(${1//:/ })
-        WAITFORIT_HOST=${WAITFORIT_hostport[0]}
-        WAITFORIT_PORT=${WAITFORIT_hostport[1]}
-        shift 1
-        ;;
-        --child)
-        WAITFORIT_CHILD=1
-        shift 1
-        ;;
-        -q | --quiet)
-        WAITFORIT_QUIET=1
-        shift 1
-        ;;
-        -s | --strict)
-        WAITFORIT_STRICT=1
-        shift 1
-        ;;
-        -h)
-        WAITFORIT_HOST="$2"
-        if [[ $WAITFORIT_HOST == "" ]]; then break; fi
-        shift 2
-        ;;
-        --host=*)
-        WAITFORIT_HOST="${1#*=}"
-        shift 1
-        ;;
-        -p)
-        WAITFORIT_PORT="$2"
-        if [[ $WAITFORIT_PORT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --port=*)
-        WAITFORIT_PORT="${1#*=}"
-        shift 1
-        ;;
-        -t)
-        WAITFORIT_TIMEOUT="$2"
-        if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --timeout=*)
-        WAITFORIT_TIMEOUT="${1#*=}"
-        shift 1
-        ;;
-        --)
-        shift
-        WAITFORIT_CLI=("$@")
-        break
-        ;;
-        --help)
-        usage
-        ;;
-        *)
-        echoerr "Unknown argument: $1"
-        usage
-        ;;
-    esac
-done
-
-if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
-    echoerr "Error: you need to provide a host and port to test."
-    usage
-fi
-
-WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
-WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
-WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
-WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
-
-# Check to see if timeout is from busybox?
-WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
-WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
-
-WAITFORIT_BUSYTIMEFLAG=""
-if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
-    WAITFORIT_ISBUSY=1
-    # Check if busybox timeout uses -t flag
-    # (recent Alpine versions don't support -t anymore)
-    if timeout &>/dev/stdout | grep -q -e '-t '; then
-        WAITFORIT_BUSYTIMEFLAG="-t"
-    fi
-else
-    WAITFORIT_ISBUSY=0
-fi
-
-if [[ $WAITFORIT_CHILD -gt 0 ]]; then
-    wait_for
-    WAITFORIT_RESULT=$?
-    exit $WAITFORIT_RESULT
-else
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        wait_for_wrapper
-        WAITFORIT_RESULT=$?
-    else
-        wait_for
-        WAITFORIT_RESULT=$?
-    fi
-fi
-
-if [[ $WAITFORIT_CLI != "" ]]; then
-    if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
-        echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
-        exit $WAITFORIT_RESULT
-    fi
-    exec "${WAITFORIT_CLI[@]}"
-else
-    exit $WAITFORIT_RESULT
-fi

Plik diff jest za duży
+ 0 - 10
zd-modules/zd-modules-gen/Dockerfile


+ 0 - 105
zd-modules/zd-modules-gen/pom.xml

@@ -1,105 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <groupId>com.zd</groupId>
-        <artifactId>zd-modules</artifactId>
-        <version>3.1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>zd-modules-gen</artifactId>
-    <packaging>jar</packaging>
-    <description>代码生成</description>
-
-    <dependencies>
-    	<!-- SpringCloud Alibaba Nacos -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Nacos Config -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
-        </dependency>
-
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
-
-        <!-- Swagger UI -->
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>${swagger.fox.version}</version>
-        </dependency>
-
-        <!-- Apache Velocity -->
-        <dependency>
-            <groupId>org.apache.velocity</groupId>
-            <artifactId>velocity</artifactId>
-        </dependency>
-
-        <!-- Commons Collections -->
-        <dependency>
-            <groupId>commons-collections</groupId>
-            <artifactId>commons-collections</artifactId>
-        </dependency>
-
-        <!-- Mysql Connector -->
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-
-        <!-- zd Common Log -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-log</artifactId>
-        </dependency>
-
-        <!-- zd Common Swagger -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-swagger</artifactId>
-        </dependency>
-
-    </dependencies>
-
-    <build>
-        <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 24
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/ZdGenApplication.java

@@ -1,24 +0,0 @@
-package com.zd.gen;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import com.zd.common.security.annotation.EnableCustomConfig;
-import com.zd.common.security.annotation.EnableRyFeignClients;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-//import com.zd.common.swagger.annotation.EnableCustomSwagger2;
-
-/**
- * 代码生成
- *
- * @author zd
- */
-@EnableCustomConfig
-//@EnableCustomSwagger2
-@EnableRyFeignClients
-@SpringBootApplication
-public class ZdGenApplication {
-    public static void main(String[] args) {
-        SpringApplication.run(ZdGenApplication.class, args);
-        System.out.println("(♥◠‿◠)ノ゙  代码生成模块启动成功   ლ(´ڡ`ლ)゙");
-    }
-}

+ 0 - 65
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/config/GenConfig.java

@@ -1,65 +0,0 @@
-package com.zd.gen.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * 代码生成相关配置
- *
- * @author zd
- */
-@Component
-@ConfigurationProperties(prefix = "gen")
-public class GenConfig {
-    /**
-     * 作者
-     */
-    public static String author;
-
-    /**
-     * 生成包路径
-     */
-    public static String packageName;
-
-    /**
-     * 自动去除表前缀,默认是false
-     */
-    public static boolean autoRemovePre;
-
-    /**
-     * 表前缀(类名不会包含表前缀)
-     */
-    public static String tablePrefix;
-
-    public static String getAuthor() {
-        return author;
-    }
-
-    public void setAuthor(String author) {
-        GenConfig.author = author;
-    }
-
-    public static String getPackageName() {
-        return packageName;
-    }
-
-    public void setPackageName(String packageName) {
-        GenConfig.packageName = packageName;
-    }
-
-    public static boolean getAutoRemovePre() {
-        return autoRemovePre;
-    }
-
-    public void setAutoRemovePre(boolean autoRemovePre) {
-        GenConfig.autoRemovePre = autoRemovePre;
-    }
-
-    public static String getTablePrefix() {
-        return tablePrefix;
-    }
-
-    public void setTablePrefix(String tablePrefix) {
-        GenConfig.tablePrefix = tablePrefix;
-    }
-}

+ 0 - 195
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/controller/GenController.java

@@ -1,195 +0,0 @@
-package com.zd.gen.controller;
-
-import com.zd.common.core.domain.per.PerFun;
-import com.zd.common.core.domain.per.PerPrefix;
-import com.zd.common.core.text.Convert;
-import com.zd.common.core.web.controller.BaseController;
-import com.zd.common.core.web.domain.AjaxResult;
-import com.zd.common.core.web.page.TableDataInfo;
-import com.zd.common.log.annotation.Log;
-import com.zd.common.log.enums.BusinessType;
-import com.zd.common.security.annotation.PreAuthorize;
-import com.zd.gen.domain.GenTable;
-import com.zd.gen.domain.GenTableColumn;
-import com.zd.gen.service.IGenTableColumnService;
-import com.zd.gen.service.IGenTableService;
-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.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 代码生成 操作处理
- *
- * @author zd
- */
-@RequestMapping("/gen")
-@RestController
-public class GenController extends BaseController {
-    @Autowired
-    private IGenTableService genTableService;
-
-    @Autowired
-    private IGenTableColumnService genTableColumnService;
-
-    /**
-     * 查询代码生成列表
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.LIST)
-    @GetMapping("/list")
-    public TableDataInfo genList(GenTable genTable) {
-        startPage();
-        List<GenTable> list = genTableService.selectGenTableList(genTable);
-        return getDataTable(list);
-    }
-
-    /**
-     * 修改代码生成业务
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.QUERY)
-    @GetMapping(value = "/{talbleId}")
-    public AjaxResult getInfo(@PathVariable Long talbleId) {
-        GenTable table = genTableService.selectGenTableById(talbleId);
-        List<GenTable> tables = genTableService.selectGenTableAll();
-        List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("info", table);
-        map.put("rows", list);
-        map.put("tables", tables);
-        return AjaxResult.success(map);
-    }
-
-    /**
-     * 查询数据库列表
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.LIST)
-    @GetMapping("/db/list")
-    public TableDataInfo dataList(GenTable genTable) {
-        startPage();
-        List<GenTable> list = genTableService.selectDbTableList(genTable);
-        return getDataTable(list);
-    }
-
-    /**
-     * 查询数据表字段列表
-     */
-    @GetMapping(value = "/column/{talbleId}")
-    public TableDataInfo columnList(Long tableId) {
-        TableDataInfo dataInfo = new TableDataInfo();
-        List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
-        dataInfo.setRows(list);
-        dataInfo.setTotal(list.size());
-        return dataInfo;
-    }
-
-    /**
-     * 导入表结构(保存)
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.IMPORT)
-    @Log(title = "代码生成", businessType = BusinessType.IMPORT)
-    @PostMapping("/importTable")
-    public AjaxResult importTableSave(String tables) {
-        String[] tableNames = Convert.toStrArray(tables);
-        // 查询表信息
-        List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
-        genTableService.importGenTable(tableList);
-        return AjaxResult.success();
-    }
-
-    /**
-     * 修改保存代码生成业务
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.EDIT)
-    @Log(title = "代码生成", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult editSave(@Validated @RequestBody GenTable genTable) {
-        genTableService.validateEdit(genTable);
-        genTableService.updateGenTable(genTable);
-        return AjaxResult.success();
-    }
-
-    /**
-     * 删除代码生成
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.REMOVE)
-    @Log(title = "代码生成", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{tableIds}")
-    public AjaxResult remove(@PathVariable Long[] tableIds) {
-        genTableService.deleteGenTableByIds(tableIds);
-        return AjaxResult.success();
-    }
-
-    /**
-     * 预览代码
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.PREVIEW)
-    @GetMapping("/preview/{tableId}")
-    public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException {
-        Map<String, String> dataMap = genTableService.previewCode(tableId);
-        return AjaxResult.success(dataMap);
-    }
-
-    /**
-     * 生成代码(下载方式)
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.CODE)
-    @Log(title = "代码生成", businessType = BusinessType.GENCODE)
-    @GetMapping("/download/{tableName}")
-    public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
-        byte[] data = genTableService.downloadCode(tableName);
-        genCode(response, data);
-    }
-
-    /**
-     * 生成代码(自定义路径)
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.CODE)
-    @Log(title = "代码生成", businessType = BusinessType.GENCODE)
-    @GetMapping("/genCode/{tableName}")
-    public AjaxResult genCode(@PathVariable("tableName") String tableName) {
-        genTableService.generatorCode(tableName);
-        return AjaxResult.success();
-    }
-
-    /**
-     * 同步数据库
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.EDIT)
-    @Log(title = "代码生成", businessType = BusinessType.UPDATE)
-    @GetMapping("/synchDb/{tableName}")
-    public AjaxResult synchDb(@PathVariable("tableName") String tableName) {
-        genTableService.synchDb(tableName);
-        return AjaxResult.success();
-    }
-
-    /**
-     * 批量生成代码
-     */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_TOOLGEN + PerFun.CODE)
-    @Log(title = "代码生成", businessType = BusinessType.GENCODE)
-    @GetMapping("/batchGenCode")
-    public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
-        String[] tableNames = Convert.toStrArray(tables);
-        byte[] data = genTableService.downloadCode(tableNames);
-        genCode(response, data);
-    }
-
-    /**
-     * 生成zip文件
-     */
-    private void genCode(HttpServletResponse response, byte[] data) throws IOException {
-        response.reset();
-        response.addHeader("Access-Control-Allow-Origin", "*");
-        response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
-        response.setHeader("Content-Disposition", "attachment; filename=\"zd.zip\"");
-        response.addHeader("Content-Length", "" + data.length);
-        response.setContentType("application/octet-stream; charset=UTF-8");
-        IOUtils.write(data, response.getOutputStream());
-    }
-}

+ 0 - 363
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/domain/GenTable.java

@@ -1,363 +0,0 @@
-package com.zd.gen.domain;
-
-import java.util.List;
-import javax.validation.Valid;
-import javax.validation.constraints.NotBlank;
-
-import org.apache.commons.lang3.ArrayUtils;
-import com.zd.common.core.constant.GenConstants;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.common.core.web.domain.BaseEntity;
-
-/**
- * 业务表 gen_table
- *
- * @author zd
- */
-public class GenTable extends BaseEntity {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 编号
-     */
-    private Long tableId;
-
-    /**
-     * 表名称
-     */
-    @NotBlank(message = "表名称不能为空")
-    private String tableName;
-
-    /**
-     * 表描述
-     */
-    @NotBlank(message = "表描述不能为空")
-    private String tableComment;
-
-    /**
-     * 关联父表的表名
-     */
-    private String subTableName;
-
-    /**
-     * 本表关联父表的外键名
-     */
-    private String subTableFkName;
-
-    /**
-     * 实体类名称(首字母大写)
-     */
-    @NotBlank(message = "实体类名称不能为空")
-    private String className;
-
-    /**
-     * 使用的模板(crud单表操作 tree树表操作 sub主子表操作)
-     */
-    private String tplCategory;
-
-    /**
-     * 生成包路径
-     */
-    @NotBlank(message = "生成包路径不能为空")
-    private String packageName;
-
-    /**
-     * 生成模块名
-     */
-    @NotBlank(message = "生成模块名不能为空")
-    private String moduleName;
-
-    /**
-     * 生成业务名
-     */
-    @NotBlank(message = "生成业务名不能为空")
-    private String businessName;
-
-    /**
-     * 生成功能名
-     */
-    @NotBlank(message = "生成功能名不能为空")
-    private String functionName;
-
-    /**
-     * 生成作者
-     */
-    @NotBlank(message = "作者不能为空")
-    private String functionAuthor;
-
-    /**
-     * 生成代码方式(0zip压缩包 1自定义路径)
-     */
-    private String genType;
-
-    /**
-     * 生成路径(不填默认项目路径)
-     */
-    private String genPath;
-
-    /**
-     * 主键信息
-     */
-    private GenTableColumn pkColumn;
-
-    /**
-     * 子表信息
-     */
-    private GenTable subTable;
-
-    /**
-     * 表列信息
-     */
-    @Valid
-    private List<GenTableColumn> columns;
-
-    /**
-     * 其它生成选项
-     */
-    private String options;
-
-    /**
-     * 树编码字段
-     */
-    private String treeCode;
-
-    /**
-     * 树父编码字段
-     */
-    private String treeParentCode;
-
-    /**
-     * 树名称字段
-     */
-    private String treeName;
-
-    /**
-     * 上级菜单ID字段
-     */
-    private String parentMenuId;
-
-    /**
-     * 上级菜单名称字段
-     */
-    private String parentMenuName;
-
-    public Long getTableId() {
-        return tableId;
-    }
-
-    public void setTableId(Long tableId) {
-        this.tableId = tableId;
-    }
-
-    public String getTableName() {
-        return tableName;
-    }
-
-    public void setTableName(String tableName) {
-        this.tableName = tableName;
-    }
-
-    public String getTableComment() {
-        return tableComment;
-    }
-
-    public void setTableComment(String tableComment) {
-        this.tableComment = tableComment;
-    }
-
-    public String getSubTableName() {
-        return subTableName;
-    }
-
-    public void setSubTableName(String subTableName) {
-        this.subTableName = subTableName;
-    }
-
-    public String getSubTableFkName() {
-        return subTableFkName;
-    }
-
-    public void setSubTableFkName(String subTableFkName) {
-        this.subTableFkName = subTableFkName;
-    }
-
-    public String getClassName() {
-        return className;
-    }
-
-    public void setClassName(String className) {
-        this.className = className;
-    }
-
-    public String getTplCategory() {
-        return tplCategory;
-    }
-
-    public void setTplCategory(String tplCategory) {
-        this.tplCategory = tplCategory;
-    }
-
-    public String getPackageName() {
-        return packageName;
-    }
-
-    public void setPackageName(String packageName) {
-        this.packageName = packageName;
-    }
-
-    public String getModuleName() {
-        return moduleName;
-    }
-
-    public void setModuleName(String moduleName) {
-        this.moduleName = moduleName;
-    }
-
-    public String getBusinessName() {
-        return businessName;
-    }
-
-    public void setBusinessName(String businessName) {
-        this.businessName = businessName;
-    }
-
-    public String getFunctionName() {
-        return functionName;
-    }
-
-    public void setFunctionName(String functionName) {
-        this.functionName = functionName;
-    }
-
-    public String getFunctionAuthor() {
-        return functionAuthor;
-    }
-
-    public void setFunctionAuthor(String functionAuthor) {
-        this.functionAuthor = functionAuthor;
-    }
-
-    public String getGenType() {
-        return genType;
-    }
-
-    public void setGenType(String genType) {
-        this.genType = genType;
-    }
-
-    public String getGenPath() {
-        return genPath;
-    }
-
-    public void setGenPath(String genPath) {
-        this.genPath = genPath;
-    }
-
-    public GenTableColumn getPkColumn() {
-        return pkColumn;
-    }
-
-    public void setPkColumn(GenTableColumn pkColumn) {
-        this.pkColumn = pkColumn;
-    }
-
-    public GenTable getSubTable() {
-        return subTable;
-    }
-
-    public void setSubTable(GenTable subTable) {
-        this.subTable = subTable;
-    }
-
-    public List<GenTableColumn> getColumns() {
-        return columns;
-    }
-
-    public void setColumns(List<GenTableColumn> columns) {
-        this.columns = columns;
-    }
-
-    public String getOptions() {
-        return options;
-    }
-
-    public void setOptions(String options) {
-        this.options = options;
-    }
-
-    public String getTreeCode() {
-        return treeCode;
-    }
-
-    public void setTreeCode(String treeCode) {
-        this.treeCode = treeCode;
-    }
-
-    public String getTreeParentCode() {
-        return treeParentCode;
-    }
-
-    public void setTreeParentCode(String treeParentCode) {
-        this.treeParentCode = treeParentCode;
-    }
-
-    public String getTreeName() {
-        return treeName;
-    }
-
-    public void setTreeName(String treeName) {
-        this.treeName = treeName;
-    }
-
-    public String getParentMenuId() {
-        return parentMenuId;
-    }
-
-    public void setParentMenuId(String parentMenuId) {
-        this.parentMenuId = parentMenuId;
-    }
-
-    public String getParentMenuName() {
-        return parentMenuName;
-    }
-
-    public void setParentMenuName(String parentMenuName) {
-        this.parentMenuName = parentMenuName;
-    }
-
-    public boolean isSub() {
-        return isSub(this.tplCategory);
-    }
-
-    public static boolean isSub(String tplCategory) {
-        return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
-    }
-
-    public boolean isTree() {
-        return isTree(this.tplCategory);
-    }
-
-    public static boolean isTree(String tplCategory) {
-        return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
-    }
-
-    public boolean isCrud() {
-        return isCrud(this.tplCategory);
-    }
-
-    public static boolean isCrud(String tplCategory) {
-        return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
-    }
-
-    public boolean isSuperColumn(String javaField) {
-        return isSuperColumn(this.tplCategory, javaField);
-    }
-
-    public static boolean isSuperColumn(String tplCategory, String javaField) {
-        if (isTree(tplCategory)) {
-            return StringUtils.equalsAnyIgnoreCase(javaField,
-                    ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
-        }
-        return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
-    }
-}

+ 0 - 362
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/domain/GenTableColumn.java

@@ -1,362 +0,0 @@
-package com.zd.gen.domain;
-
-import javax.validation.constraints.NotBlank;
-
-import com.zd.common.core.utils.StringUtils;
-import com.zd.common.core.web.domain.BaseEntity;
-
-/**
- * 代码生成业务字段表 gen_table_column
- *
- * @author zd
- */
-public class GenTableColumn extends BaseEntity {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 编号
-     */
-    private Long columnId;
-
-    /**
-     * 归属表编号
-     */
-    private Long tableId;
-
-    /**
-     * 列名称
-     */
-    private String columnName;
-
-    /**
-     * 列描述
-     */
-    private String columnComment;
-
-    /**
-     * 列类型
-     */
-    private String columnType;
-
-    /**
-     * JAVA类型
-     */
-    private String javaType;
-
-    /**
-     * JAVA字段名
-     */
-    @NotBlank(message = "Java属性不能为空")
-    private String javaField;
-
-    /**
-     * 是否主键(1是)
-     */
-    private String isPk;
-
-    /**
-     * 是否自增(1是)
-     */
-    private String isIncrement;
-
-    /**
-     * 是否必填(1是)
-     */
-    private String isRequired;
-
-    /**
-     * 是否为插入字段(1是)
-     */
-    private String isInsert;
-
-    /**
-     * 是否编辑字段(1是)
-     */
-    private String isEdit;
-
-    /**
-     * 是否列表字段(1是)
-     */
-    private String isList;
-
-    /**
-     * 是否查询字段(1是)
-     */
-    private String isQuery;
-
-    /**
-     * 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围)
-     */
-    private String queryType;
-
-    /**
-     * 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件)
-     */
-    private String htmlType;
-
-    /**
-     * 字典类型
-     */
-    private String dictType;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    /**
-     * 长度 当为Strting 类型有值
-     */
-    private Integer length;
-
-
-    public Integer getLength() {
-        return length;
-    }
-
-    public void setLength(Integer length) {
-        this.length = length;
-    }
-
-    public void setColumnId(Long columnId) {
-        this.columnId = columnId;
-    }
-
-    public Long getColumnId() {
-        return columnId;
-    }
-
-    public void setTableId(Long tableId) {
-        this.tableId = tableId;
-    }
-
-    public Long getTableId() {
-        return tableId;
-    }
-
-    public void setColumnName(String columnName) {
-        this.columnName = columnName;
-    }
-
-    public String getColumnName() {
-        return columnName;
-    }
-
-    public void setColumnComment(String columnComment) {
-        this.columnComment = columnComment;
-    }
-
-    public String getColumnComment() {
-        return columnComment;
-    }
-
-    public void setColumnType(String columnType) {
-        this.columnType = columnType;
-    }
-
-    public String getColumnType() {
-        return columnType;
-    }
-
-    public void setJavaType(String javaType) {
-        this.javaType = javaType;
-    }
-
-    public String getJavaType() {
-        return javaType;
-    }
-
-    public void setJavaField(String javaField) {
-        this.javaField = javaField;
-    }
-
-    public String getJavaField() {
-        return javaField;
-    }
-
-    public String getCapJavaField() {
-        return StringUtils.capitalize(javaField);
-    }
-
-    public void setIsPk(String isPk) {
-        this.isPk = isPk;
-    }
-
-    public String getIsPk() {
-        return isPk;
-    }
-
-    public boolean isPk() {
-        return isPk(this.isPk);
-    }
-
-    public boolean isPk(String isPk) {
-        return isPk != null && StringUtils.equals("1", isPk);
-    }
-
-    public String getIsIncrement() {
-        return isIncrement;
-    }
-
-    public void setIsIncrement(String isIncrement) {
-        this.isIncrement = isIncrement;
-    }
-
-    public boolean isIncrement() {
-        return isIncrement(this.isIncrement);
-    }
-
-    public boolean isIncrement(String isIncrement) {
-        return isIncrement != null && StringUtils.equals("1", isIncrement);
-    }
-
-    public void setIsRequired(String isRequired) {
-        this.isRequired = isRequired;
-    }
-
-    public String getIsRequired() {
-        return isRequired;
-    }
-
-    public boolean isRequired() {
-        return isRequired(this.isRequired);
-    }
-
-    public boolean isRequired(String isRequired) {
-        return isRequired != null && StringUtils.equals("1", isRequired);
-    }
-
-    public void setIsInsert(String isInsert) {
-        this.isInsert = isInsert;
-    }
-
-    public String getIsInsert() {
-        return isInsert;
-    }
-
-    public boolean isInsert() {
-        return isInsert(this.isInsert);
-    }
-
-    public boolean isInsert(String isInsert) {
-        return isInsert != null && StringUtils.equals("1", isInsert);
-    }
-
-    public void setIsEdit(String isEdit) {
-        this.isEdit = isEdit;
-    }
-
-    public String getIsEdit() {
-        return isEdit;
-    }
-
-    public boolean isEdit() {
-        return isInsert(this.isEdit);
-    }
-
-    public boolean isEdit(String isEdit) {
-        return isEdit != null && StringUtils.equals("1", isEdit);
-    }
-
-    public void setIsList(String isList) {
-        this.isList = isList;
-    }
-
-    public String getIsList() {
-        return isList;
-    }
-
-    public boolean isList() {
-        return isList(this.isList);
-    }
-
-    public boolean isList(String isList) {
-        return isList != null && StringUtils.equals("1", isList);
-    }
-
-    public void setIsQuery(String isQuery) {
-        this.isQuery = isQuery;
-    }
-
-    public String getIsQuery() {
-        return isQuery;
-    }
-
-    public boolean isQuery() {
-        return isQuery(this.isQuery);
-    }
-
-    public boolean isQuery(String isQuery) {
-        return isQuery != null && StringUtils.equals("1", isQuery);
-    }
-
-    public void setQueryType(String queryType) {
-        this.queryType = queryType;
-    }
-
-    public String getQueryType() {
-        return queryType;
-    }
-
-    public String getHtmlType() {
-        return htmlType;
-    }
-
-    public void setHtmlType(String htmlType) {
-        this.htmlType = htmlType;
-    }
-
-    public void setDictType(String dictType) {
-        this.dictType = dictType;
-    }
-
-    public String getDictType() {
-        return dictType;
-    }
-
-    public void setSort(Integer sort) {
-        this.sort = sort;
-    }
-
-    public Integer getSort() {
-        return sort;
-    }
-
-    public boolean isSuperColumn() {
-        return isSuperColumn(this.javaField);
-    }
-
-    public static boolean isSuperColumn(String javaField) {
-        return StringUtils.equalsAnyIgnoreCase(javaField,
-                // BaseEntity
-                "createBy", "createTime", "updateBy", "updateTime", "remark", "userId", "deptName", "deptId",
-                // TreeEntity
-                "parentName", "parentId", "orderNum", "ancestors");
-    }
-
-    public boolean isUsableColumn() {
-        return isUsableColumn(javaField);
-    }
-
-    public static boolean isUsableColumn(String javaField) {
-        // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
-        return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
-    }
-
-    public String readConverterExp() {
-        String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
-        StringBuffer sb = new StringBuffer();
-        if (StringUtils.isNotEmpty(remarks)) {
-            for (String value : remarks.split(" ")) {
-                if (StringUtils.isNotEmpty(value)) {
-                    Object startStr = value.subSequence(0, 1);
-                    String endStr = value.substring(1);
-                    sb.append("").append(startStr).append("=").append(endStr).append(",");
-                }
-            }
-            return sb.deleteCharAt(sb.length() - 1).toString();
-        } else {
-            return this.columnComment;
-        }
-    }
-}

+ 0 - 60
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/mapper/GenTableColumnMapper.java

@@ -1,60 +0,0 @@
-package com.zd.gen.mapper;
-
-import java.util.List;
-
-import com.zd.gen.domain.GenTableColumn;
-
-/**
- * 业务字段 数据层
- *
- * @author zd
- */
-public interface GenTableColumnMapper {
-    /**
-     * 根据表名称查询列信息
-     *
-     * @param tableName 表名称
-     * @return 列信息
-     */
-    public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
-
-    /**
-     * 查询业务字段列表
-     *
-     * @param tableId 业务字段编号
-     * @return 业务字段集合
-     */
-    public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
-
-    /**
-     * 新增业务字段
-     *
-     * @param genTableColumn 业务字段信息
-     * @return 结果
-     */
-    public int insertGenTableColumn(GenTableColumn genTableColumn);
-
-    /**
-     * 修改业务字段
-     *
-     * @param genTableColumn 业务字段信息
-     * @return 结果
-     */
-    public int updateGenTableColumn(GenTableColumn genTableColumn);
-
-    /**
-     * 删除业务字段
-     *
-     * @param genTableColumns 列数据
-     * @return 结果
-     */
-    public int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
-
-    /**
-     * 批量删除业务字段
-     *
-     * @param ids 需要删除的数据ID
-     * @return 结果
-     */
-    public int deleteGenTableColumnByIds(Long[] ids);
-}

+ 0 - 83
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/mapper/GenTableMapper.java

@@ -1,83 +0,0 @@
-package com.zd.gen.mapper;
-
-import java.util.List;
-
-import com.zd.gen.domain.GenTable;
-
-/**
- * 业务 数据层
- *
- * @author zd
- */
-public interface GenTableMapper {
-    /**
-     * 查询业务列表
-     *
-     * @param genTable 业务信息
-     * @return 业务集合
-     */
-    public List<GenTable> selectGenTableList(GenTable genTable);
-
-    /**
-     * 查询据库列表
-     *
-     * @param genTable 业务信息
-     * @return 数据库表集合
-     */
-    public List<GenTable> selectDbTableList(GenTable genTable);
-
-    /**
-     * 查询据库列表
-     *
-     * @param tableNames 表名称组
-     * @return 数据库表集合
-     */
-    public List<GenTable> selectDbTableListByNames(String[] tableNames);
-
-    /**
-     * 查询所有表信息
-     *
-     * @return 表信息集合
-     */
-    public List<GenTable> selectGenTableAll();
-
-    /**
-     * 查询表ID业务信息
-     *
-     * @param id 业务ID
-     * @return 业务信息
-     */
-    public GenTable selectGenTableById(Long id);
-
-    /**
-     * 查询表名称业务信息
-     *
-     * @param tableName 表名称
-     * @return 业务信息
-     */
-    public GenTable selectGenTableByName(String tableName);
-
-    /**
-     * 新增业务
-     *
-     * @param genTable 业务信息
-     * @return 结果
-     */
-    public int insertGenTable(GenTable genTable);
-
-    /**
-     * 修改业务
-     *
-     * @param genTable 业务信息
-     * @return 结果
-     */
-    public int updateGenTable(GenTable genTable);
-
-    /**
-     * 批量删除业务
-     *
-     * @param ids 需要删除的数据ID
-     * @return 结果
-     */
-    public int deleteGenTableByIds(Long[] ids);
-}

+ 0 - 64
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/GenTableColumnServiceImpl.java

@@ -1,64 +0,0 @@
-package com.zd.gen.service;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.zd.common.core.text.Convert;
-import com.zd.gen.domain.GenTableColumn;
-import com.zd.gen.mapper.GenTableColumnMapper;
-
-/**
- * 业务字段 服务层实现
- *
- * @author zd
- */
-@Service
-public class GenTableColumnServiceImpl implements IGenTableColumnService {
-    @Autowired
-    private GenTableColumnMapper genTableColumnMapper;
-
-    /**
-     * 查询业务字段列表
-     *
-     * @param tableId 业务字段编号
-     * @return 业务字段集合
-     */
-    @Override
-    public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
-        return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
-    }
-
-    /**
-     * 新增业务字段
-     *
-     * @param genTableColumn 业务字段信息
-     * @return 结果
-     */
-    @Override
-    public int insertGenTableColumn(GenTableColumn genTableColumn) {
-        return genTableColumnMapper.insertGenTableColumn(genTableColumn);
-    }
-
-    /**
-     * 修改业务字段
-     *
-     * @param genTableColumn 业务字段信息
-     * @return 结果
-     */
-    @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));
-    }
-}

+ 0 - 438
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/GenTableServiceImpl.java

@@ -1,438 +0,0 @@
-package com.zd.gen.service;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.zd.common.core.constant.Constants;
-import com.zd.common.core.constant.GenConstants;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.common.core.text.CharsetKit;
-import com.zd.common.core.utils.SecurityUtils;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.gen.domain.GenTable;
-import com.zd.gen.domain.GenTableColumn;
-import com.zd.gen.mapper.GenTableColumnMapper;
-import com.zd.gen.mapper.GenTableMapper;
-import com.zd.gen.util.GenUtils;
-import com.zd.gen.util.VelocityInitializer;
-import com.zd.gen.util.VelocityUtils;
-
-/**
- * 业务 服务层实现
- *
- * @author zd
- */
-@Service
-public class GenTableServiceImpl implements IGenTableService {
-    private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
-
-    @Autowired
-    private GenTableMapper genTableMapper;
-
-    @Autowired
-    private GenTableColumnMapper genTableColumnMapper;
-
-    /**
-     * 查询业务信息
-     *
-     * @param id 业务ID
-     * @return 业务信息
-     */
-    @Override
-    public GenTable selectGenTableById(Long id) {
-        GenTable genTable = genTableMapper.selectGenTableById(id);
-        setTableFromOptions(genTable);
-        return genTable;
-    }
-
-    /**
-     * 查询业务列表
-     *
-     * @param genTable 业务信息
-     * @return 业务集合
-     */
-    @Override
-    public List<GenTable> selectGenTableList(GenTable genTable) {
-        return genTableMapper.selectGenTableList(genTable);
-    }
-
-    /**
-     * 查询据库列表
-     *
-     * @param genTable 业务信息
-     * @return 数据库表集合
-     */
-    @Override
-    public List<GenTable> selectDbTableList(GenTable genTable) {
-        return genTableMapper.selectDbTableList(genTable);
-    }
-
-    /**
-     * 查询据库列表
-     *
-     * @param tableNames 表名称组
-     * @return 数据库表集合
-     */
-    @Override
-    public List<GenTable> selectDbTableListByNames(String[] tableNames) {
-        return genTableMapper.selectDbTableListByNames(tableNames);
-    }
-
-    /**
-     * 查询所有表信息
-     *
-     * @return 表信息集合
-     */
-    @Override
-    public List<GenTable> selectGenTableAll() {
-        return genTableMapper.selectGenTableAll();
-    }
-
-    /**
-     * 修改业务
-     *
-     * @param genTable 业务信息
-     * @return 结果
-     */
-    @Override
-    @Transactional
-    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()) {
-                genTableColumnMapper.updateGenTableColumn(cenTableColumn);
-            }
-        }
-    }
-
-    /**
-     * 删除业务对象
-     *
-     * @param tableIds 需要删除的数据ID
-     * @return 结果
-     */
-    @Override
-    @Transactional
-    public void deleteGenTableByIds(Long[] tableIds) {
-        genTableMapper.deleteGenTableByIds(tableIds);
-        genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
-    }
-
-    /**
-     * 导入表结构
-     *
-     * @param tableList 导入表列表
-     */
-    @Override
-    @Transactional
-    public void importGenTable(List<GenTable> tableList) {
-        String operName = SecurityUtils.getUsername();
-        try {
-            for (GenTable table : tableList) {
-                String tableName = table.getTableName();
-                GenUtils.initTable(table, operName);
-                int row = genTableMapper.insertGenTable(table);
-                if (row > 0) {
-                    // 保存列信息
-                    List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
-                    for (GenTableColumn column : genTableColumns) {
-                        GenUtils.initColumnField(column, table);
-                        genTableColumnMapper.insertGenTableColumn(column);
-                    }
-                }
-            }
-        } catch (Exception e) {
-            throw new ServiceException("导入失败:" + e.getMessage());
-        }
-    }
-
-    /**
-     * 预览代码
-     *
-     * @param tableId 表编号
-     * @return 预览数据列表
-     */
-    @Override
-    public Map<String, String> previewCode(Long tableId) {
-        Map<String, String> dataMap = new LinkedHashMap<>();
-        // 查询表信息
-        GenTable table = genTableMapper.selectGenTableById(tableId);
-        // 设置主子表信息
-        setSubTable(table);
-        // 设置主键列信息
-        setPkColumn(table);
-        VelocityInitializer.initVelocity();
-
-        VelocityContext context = VelocityUtils.prepareContext(table);
-
-        // 获取模板列表
-        List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
-        for (String template : templates) {
-            // 渲染模板
-            StringWriter sw = new StringWriter();
-            Template tpl = Velocity.getTemplate(template, Constants.UTF8);
-            tpl.merge(context, sw);
-            dataMap.put(template, sw.toString());
-        }
-        return dataMap;
-    }
-
-    /**
-     * 生成代码(下载方式)
-     *
-     * @param tableName 表名称
-     * @return 数据
-     */
-    @Override
-    public byte[] downloadCode(String tableName) {
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        ZipOutputStream zip = new ZipOutputStream(outputStream);
-        generatorCode(tableName, zip);
-        IOUtils.closeQuietly(zip);
-        return outputStream.toByteArray();
-    }
-
-    /**
-     * 生成代码(自定义路径)
-     *
-     * @param tableName 表名称
-     */
-    @Override
-    public void generatorCode(String tableName) {
-        // 查询表信息
-        GenTable table = genTableMapper.selectGenTableByName(tableName);
-        // 设置主子表信息
-        setSubTable(table);
-        // 设置主键列信息
-        setPkColumn(table);
-
-        VelocityInitializer.initVelocity();
-
-        VelocityContext context = VelocityUtils.prepareContext(table);
-
-        // 获取模板列表
-        List<String> 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")) {
-                // 渲染模板
-                StringWriter sw = new StringWriter();
-                Template tpl = Velocity.getTemplate(template, Constants.UTF8);
-                tpl.merge(context, sw);
-                try {
-                    String path = getGenPath(table, template);
-                    FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
-                } catch (IOException e) {
-                    throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
-                }
-            }
-        }
-    }
-
-    /**
-     * 同步数据库
-     *
-     * @param tableName 表名称
-     */
-    @Override
-    @Transactional
-    public void synchDb(String tableName) {
-        GenTable table = genTableMapper.selectGenTableByName(tableName);
-        List<GenTableColumn> tableColumns = table.getColumns();
-        List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
-
-        List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
-        if (StringUtils.isEmpty(dbTableColumns)) {
-            throw new ServiceException("同步数据失败,原表结构不存在");
-        }
-        List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
-
-        dbTableColumns.forEach(column -> {
-            if (!tableColumnNames.contains(column.getColumnName())) {
-                GenUtils.initColumnField(column, table);
-                genTableColumnMapper.insertGenTableColumn(column);
-            }
-        });
-
-        List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
-        if (StringUtils.isNotEmpty(delColumns)) {
-            genTableColumnMapper.deleteGenTableColumns(delColumns);
-        }
-    }
-
-    /**
-     * 批量生成代码(下载方式)
-     *
-     * @param tableNames 表数组
-     * @return 数据
-     */
-    @Override
-    public byte[] downloadCode(String[] tableNames) {
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        ZipOutputStream zip = new ZipOutputStream(outputStream);
-        for (String tableName : tableNames) {
-            generatorCode(tableName, zip);
-        }
-        IOUtils.closeQuietly(zip);
-        return outputStream.toByteArray();
-    }
-
-    /**
-     * 查询表信息并生成代码
-     */
-    private void generatorCode(String tableName, ZipOutputStream zip) {
-        // 查询表信息
-        GenTable table = genTableMapper.selectGenTableByName(tableName);
-        // 设置主子表信息
-        setSubTable(table);
-        // 设置主键列信息
-        setPkColumn(table);
-
-        VelocityInitializer.initVelocity();
-
-        VelocityContext context = VelocityUtils.prepareContext(table);
-
-        // 获取模板列表
-        List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
-        for (String template : templates) {
-            // 渲染模板
-            StringWriter sw = new StringWriter();
-            Template tpl = Velocity.getTemplate(template, Constants.UTF8);
-            tpl.merge(context, sw);
-            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) {
-                log.error("渲染模板失败,表名:" + table.getTableName(), e);
-            }
-        }
-    }
-
-    /**
-     * 修改保存参数校验
-     *
-     * @param genTable 业务信息
-     */
-    @Override
-    public void validateEdit(GenTable genTable) {
-        if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
-            String options = JSON.toJSONString(genTable.getParams());
-            JSONObject paramsObj = JSONObject.parseObject(options);
-            if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
-                throw new ServiceException("树编码字段不能为空");
-            } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
-                throw new ServiceException("树父编码字段不能为空");
-            } 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())) {
-                    throw new ServiceException("关联子表的表名不能为空");
-                } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
-                    throw new ServiceException("子表关联的外键名不能为空");
-                }
-            }
-        }
-    }
-
-    /**
-     * 设置主键列信息
-     *
-     * @param table 业务表信息
-     */
-    public void setPkColumn(GenTable table) {
-        for (GenTableColumn column : table.getColumns()) {
-            if (column.isPk()) {
-                table.setPkColumn(column);
-                break;
-            }
-        }
-        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()) {
-                    table.getSubTable().setPkColumn(column);
-                    break;
-                }
-            }
-            if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
-                table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
-            }
-        }
-    }
-
-    /**
-     * 设置主子表信息
-     *
-     * @param table 业务表信息
-     */
-    public void setSubTable(GenTable table) {
-        String subTableName = table.getSubTableName();
-        if (StringUtils.isNotEmpty(subTableName)) {
-            table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
-        }
-    }
-
-    /**
-     * 设置代码生成其他选项值
-     *
-     * @param genTable 设置后的生成对象
-     */
-    public void setTableFromOptions(GenTable genTable) {
-        JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
-        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);
-            String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
-            String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
-
-            genTable.setTreeCode(treeCode);
-            genTable.setTreeParentCode(treeParentCode);
-            genTable.setTreeName(treeName);
-            genTable.setParentMenuId(parentMenuId);
-            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);
-    }
-}

+ 0 - 44
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/IGenTableColumnService.java

@@ -1,44 +0,0 @@
-package com.zd.gen.service;
-
-import java.util.List;
-
-import com.zd.gen.domain.GenTableColumn;
-
-/**
- * 业务字段 服务层
- *
- * @author zd
- */
-public interface IGenTableColumnService {
-    /**
-     * 查询业务字段列表
-     *
-     * @param tableId 业务字段编号
-     * @return 业务字段集合
-     */
-    public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
-
-    /**
-     * 新增业务字段
-     *
-     * @param genTableColumn 业务字段信息
-     * @return 结果
-     */
-    public int insertGenTableColumn(GenTableColumn genTableColumn);
-
-    /**
-     * 修改业务字段
-     *
-     * @param genTableColumn 业务字段信息
-     * @return 结果
-     */
-    public int updateGenTableColumn(GenTableColumn genTableColumn);
-
-    /**
-     * 删除业务字段信息
-     *
-     * @param ids 需要删除的数据ID
-     * @return 结果
-     */
-    public int deleteGenTableColumnByIds(String ids);
-}

+ 0 - 121
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/service/IGenTableService.java

@@ -1,121 +0,0 @@
-package com.zd.gen.service;
-
-import java.util.List;
-import java.util.Map;
-
-import com.zd.gen.domain.GenTable;
-
-/**
- * 业务 服务层
- *
- * @author zd
- */
-public interface IGenTableService {
-    /**
-     * 查询业务列表
-     *
-     * @param genTable 业务信息
-     * @return 业务集合
-     */
-    public List<GenTable> selectGenTableList(GenTable genTable);
-
-    /**
-     * 查询据库列表
-     *
-     * @param genTable 业务信息
-     * @return 数据库表集合
-     */
-    public List<GenTable> selectDbTableList(GenTable genTable);
-
-    /**
-     * 查询据库列表
-     *
-     * @param tableNames 表名称组
-     * @return 数据库表集合
-     */
-    public List<GenTable> selectDbTableListByNames(String[] tableNames);
-
-    /**
-     * 查询所有表信息
-     *
-     * @return 表信息集合
-     */
-    public List<GenTable> selectGenTableAll();
-
-    /**
-     * 查询业务信息
-     *
-     * @param id 业务ID
-     * @return 业务信息
-     */
-    public GenTable selectGenTableById(Long id);
-
-    /**
-     * 修改业务
-     *
-     * @param genTable 业务信息
-     * @return 结果
-     */
-    public void updateGenTable(GenTable genTable);
-
-    /**
-     * 删除业务信息
-     *
-     * @param tableIds 需要删除的表数据ID
-     * @return 结果
-     */
-    public void deleteGenTableByIds(Long[] tableIds);
-
-    /**
-     * 导入表结构
-     *
-     * @param tableList 导入表列表
-     */
-    public void importGenTable(List<GenTable> tableList);
-
-    /**
-     * 预览代码
-     *
-     * @param tableId 表编号
-     * @return 预览数据列表
-     */
-    public Map<String, String> previewCode(Long tableId);
-
-    /**
-     * 生成代码(下载方式)
-     *
-     * @param tableName 表名称
-     * @return 数据
-     */
-    public byte[] downloadCode(String tableName);
-
-    /**
-     * 生成代码(自定义路径)
-     *
-     * @param tableName 表名称
-     * @return 数据
-     */
-    public void generatorCode(String tableName);
-
-    /**
-     * 同步数据库
-     *
-     * @param tableName 表名称
-     */
-    public void synchDb(String tableName);
-
-    /**
-     * 批量生成代码(下载方式)
-     *
-     * @param tableNames 表数组
-     * @return 数据
-     */
-    public byte[] downloadCode(String[] tableNames);
-
-    /**
-     * 修改保存参数校验
-     *
-     * @param genTable 业务信息
-     */
-    public void validateEdit(GenTable genTable);
-}

+ 0 - 223
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/util/GenUtils.java

@@ -1,223 +0,0 @@
-package com.zd.gen.util;
-
-import java.util.Arrays;
-
-import org.apache.commons.lang3.RegExUtils;
-import com.zd.common.core.constant.GenConstants;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.gen.config.GenConfig;
-import com.zd.gen.domain.GenTable;
-import com.zd.gen.domain.GenTableColumn;
-
-/**
- * 代码生成器 工具类
- *
- * @author zd
- */
-public class GenUtils {
-    /**
-     * 初始化表信息
-     */
-    public static void initTable(GenTable genTable, String operName) {
-        genTable.setClassName(convertClassName(genTable.getTableName()));
-        genTable.setPackageName(GenConfig.getPackageName());
-        genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
-        genTable.setBusinessName(getBusinessName(genTable.getTableName()));
-        genTable.setFunctionName(replaceText(genTable.getTableComment()));
-        genTable.setFunctionAuthor(GenConfig.getAuthor());
-        genTable.setCreateBy(operName);
-    }
-
-    /**
-     * 初始化列属性字段
-     */
-    public static void initColumnField(GenTableColumn column, GenTable table) {
-        String dataType = getDbType(column.getColumnType());
-        String columnName = column.getColumnName();
-        column.setTableId(table.getTableId());
-        column.setCreateBy(table.getCreateBy());
-        // 设置java字段名
-        column.setJavaField(StringUtils.toCamelCase(columnName));
-        // 设置默认类型
-        column.setJavaType(GenConstants.TYPE_STRING);
-        column.setLength(-1);
-        if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
-            // 字符串长度超过500设置为文本域
-            Integer columnLength = getColumnLength(column.getColumnType());
-            String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
-            column.setHtmlType(htmlType);
-            column.setLength(columnLength);
-        } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
-            column.setJavaType(GenConstants.TYPE_DATE);
-            column.setHtmlType(GenConstants.HTML_DATETIME);
-        } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
-            column.setHtmlType(GenConstants.HTML_INPUT);
-
-            // 如果是浮点型 统一用BigDecimal
-            String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
-            if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
-                column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
-            }
-            // 如果是整形
-            else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
-                column.setJavaType(GenConstants.TYPE_INTEGER);
-            }
-            // 长整形
-            else {
-                column.setJavaType(GenConstants.TYPE_LONG);
-            }
-        }
-
-        // 插入字段(默认所有字段都需要插入)
-        column.setIsInsert(GenConstants.REQUIRE);
-
-        // 编辑字段
-        if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) {
-            column.setIsEdit(GenConstants.REQUIRE);
-        }
-        // 列表字段
-        if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) {
-            column.setIsList(GenConstants.REQUIRE);
-        }
-        // 查询字段
-        if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
-            column.setIsQuery(GenConstants.REQUIRE);
-        }
-
-        // 查询字段类型
-        if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
-            column.setQueryType(GenConstants.QUERY_LIKE);
-        }
-        // 状态字段设置单选框
-        if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
-            column.setHtmlType(GenConstants.HTML_RADIO);
-        }
-        // 类型&性别字段设置下拉框
-        else if (StringUtils.endsWithIgnoreCase(columnName, "type")
-                || StringUtils.endsWithIgnoreCase(columnName, "sex")) {
-            column.setHtmlType(GenConstants.HTML_SELECT);
-        }
-        // 图片字段设置图片上传控件
-        else if (StringUtils.endsWithIgnoreCase(columnName, "image")) {
-            column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
-        }
-        // 文件字段设置文件上传控件
-        else if (StringUtils.endsWithIgnoreCase(columnName, "file")) {
-            column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
-        }
-        // 内容字段设置富文本控件
-        else if (StringUtils.endsWithIgnoreCase(columnName, "content")) {
-            column.setHtmlType(GenConstants.HTML_EDITOR);
-        }
-    }
-
-    /**
-     * 校验数组是否包含指定值
-     *
-     * @param arr         数组
-     * @param targetValue 值
-     * @return 是否包含
-     */
-    public static boolean arraysContains(String[] arr, String targetValue) {
-        return Arrays.asList(arr).contains(targetValue);
-    }
-
-    /**
-     * 获取模块名
-     *
-     * @param packageName 包名
-     * @return 模块名
-     */
-    public static String getModuleName(String packageName) {
-        int lastIndex = packageName.lastIndexOf(".");
-        int nameLength = packageName.length();
-        String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
-        return moduleName;
-    }
-
-    /**
-     * 获取业务名
-     *
-     * @param tableName 表名
-     * @return 业务名
-     */
-    public static String getBusinessName(String tableName) {
-        int lastIndex = tableName.lastIndexOf("_");
-        int nameLength = tableName.length();
-        String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
-        return businessName;
-    }
-
-    /**
-     * 表名转换成Java类名
-     *
-     * @param tableName 表名称
-     * @return 类名
-     */
-    public static String convertClassName(String tableName) {
-        boolean autoRemovePre = GenConfig.getAutoRemovePre();
-        String tablePrefix = GenConfig.getTablePrefix();
-        if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
-            String[] searchList = StringUtils.split(tablePrefix, ",");
-            tableName = replaceFirst(tableName, searchList);
-        }
-        return StringUtils.convertToCamelCase(tableName);
-    }
-
-    /**
-     * 批量替换前缀
-     *
-     * @param replacementm 替换值
-     * @param searchList   替换列表
-     * @return
-     */
-    public static String replaceFirst(String replacementm, String[] searchList) {
-        String text = replacementm;
-        for (String searchString : searchList) {
-            if (replacementm.startsWith(searchString)) {
-                text = replacementm.replaceFirst(searchString, "");
-                break;
-            }
-        }
-        return text;
-    }
-
-    /**
-     * 关键字替换
-     *
-     * @param text 需要被替换的名字
-     * @return 替换后的名字
-     */
-    public static String replaceText(String text) {
-        return RegExUtils.replaceAll(text, "(?:表|云)", "");
-    }
-
-    /**
-     * 获取数据库类型字段
-     *
-     * @param columnType 列类型
-     * @return 截取后的列类型
-     */
-    public static String getDbType(String columnType) {
-        if (StringUtils.indexOf(columnType, "(") > 0) {
-            return StringUtils.substringBefore(columnType, "(");
-        } else {
-            return columnType;
-        }
-    }
-
-    /**
-     * 获取字段长度
-     *
-     * @param columnType 列类型
-     * @return 截取后的列类型
-     */
-    public static Integer getColumnLength(String columnType) {
-        if (StringUtils.indexOf(columnType, "(") > 0) {
-            String length = StringUtils.substringBetween(columnType, "(", ")");
-            return Integer.valueOf(length);
-        } else {
-            return 0;
-        }
-    }
-}

+ 0 - 31
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/util/VelocityInitializer.java

@@ -1,31 +0,0 @@
-package com.zd.gen.util;
-
-import java.util.Properties;
-
-import org.apache.velocity.app.Velocity;
-import com.zd.common.core.constant.Constants;
-
-/**
- * VelocityEngine工厂
- *
- * @author zd
- */
-public class VelocityInitializer {
-    /**
-     * 初始化vm方法
-     */
-    public static void initVelocity() {
-        Properties p = new Properties();
-        try {
-            // 加载classpath目录下的vm文件
-            p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
-            // 定义字符集
-            p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8);
-            p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
-            // 初始化Velocity引擎,指定配置Properties
-            Velocity.init(p);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-}

+ 0 - 328
zd-modules/zd-modules-gen/src/main/java/com/zd/gen/util/VelocityUtils.java

@@ -1,328 +0,0 @@
-package com.zd.gen.util;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.alibaba.fastjson.JSON;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.velocity.VelocityContext;
-import com.alibaba.fastjson.JSONObject;
-import com.zd.common.core.constant.GenConstants;
-import com.zd.common.core.utils.DateUtils;
-import com.zd.gen.domain.GenTable;
-import com.zd.gen.domain.GenTableColumn;
-
-/**
- * 模板工具类
- *
- * @author zd
- */
-public class VelocityUtils {
-
-    private VelocityUtils() {
-        throw new IllegalStateException("VelocityUtils class");
-    }
-    /**
-     * 项目空间路径
-     */
-    private static final String PROJECT_PATH = "main/java";
-
-    /**
-     * mybatis空间路径
-     */
-    private static final String MYBATIS_PATH = "main/resources/mapper";
-
-    /**
-     * 默认上级菜单,系统工具
-     */
-    private static final String DEFAULT_PARENT_MENU_ID = "3";
-
-    /**
-     * 设置模板变量信息
-     *
-     * @return 模板列表
-     */
-    public static VelocityContext prepareContext(GenTable genTable) {
-        String moduleName = genTable.getModuleName();
-        String businessName = genTable.getBusinessName();
-        String packageName = genTable.getPackageName();
-        String tplCategory = genTable.getTplCategory();
-        String functionName = genTable.getFunctionName();
-
-        VelocityContext velocityContext = new VelocityContext();
-        velocityContext.put("tplCategory", genTable.getTplCategory());
-        velocityContext.put("tableName", genTable.getTableName());
-        velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
-        velocityContext.put("ClassName", genTable.getClassName());
-        velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
-        velocityContext.put("moduleName", genTable.getModuleName());
-        velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
-        velocityContext.put("businessName", genTable.getBusinessName());
-        velocityContext.put("basePackage", getPackagePrefix(packageName));
-        velocityContext.put("packageName", packageName);
-        velocityContext.put("author", genTable.getFunctionAuthor());
-        velocityContext.put("datetime", DateUtils.getDate());
-        velocityContext.put("pkColumn", genTable.getPkColumn());
-        velocityContext.put("importList", getImportList(genTable));
-        velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
-        velocityContext.put("columns", genTable.getColumns());
-        velocityContext.put("table", genTable);
-        setMenuVelocityContext(velocityContext, genTable);
-        if (GenConstants.TPL_TREE.equals(tplCategory)) {
-            setTreeVelocityContext(velocityContext, genTable);
-        }
-        if (GenConstants.TPL_SUB.equals(tplCategory)) {
-            setSubVelocityContext(velocityContext, genTable);
-        }
-        return velocityContext;
-    }
-
-    public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
-        String options = genTable.getOptions();
-        JSONObject paramsObj = JSON.parseObject(options);
-        String parentMenuId = getParentMenuId(paramsObj);
-        context.put("parentMenuId", parentMenuId);
-    }
-
-    public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
-        String options = genTable.getOptions();
-        JSONObject paramsObj = JSON.parseObject(options);
-        String treeCode = getTreecode(paramsObj);
-        String treeParentCode = getTreeParentCode(paramsObj);
-        String treeName = getTreeName(paramsObj);
-
-        context.put("treeCode", treeCode);
-        context.put("treeParentCode", treeParentCode);
-        context.put("treeName", treeName);
-        context.put("expandColumn", getExpandColumn(genTable));
-        if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
-            context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
-        }
-        if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
-            context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
-        }
-    }
-
-    public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
-        GenTable subTable = genTable.getSubTable();
-        String subTableName = genTable.getSubTableName();
-        String subTableFkName = genTable.getSubTableFkName();
-        String subClassName = genTable.getSubTable().getClassName();
-        String subTableFkClassName = com.zd.common.core.utils.StringUtils.convertToCamelCase(subTableFkName);
-
-        context.put("subTable", subTable);
-        context.put("subTableName", subTableName);
-        context.put("subTableFkName", subTableFkName);
-        context.put("subTableFkClassName", subTableFkClassName);
-        context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
-        context.put("subClassName", subClassName);
-        context.put("subclassName", StringUtils.uncapitalize(subClassName));
-        context.put("subImportList", getImportList(genTable.getSubTable()));
-    }
-
-    /**
-     * 获取模板信息
-     *
-     * @return 模板列表
-     */
-    public static List<String> getTemplateList(String tplCategory) {
-        List<String> templates = new ArrayList<>();
-        templates.add("vm/java/domain.java.vm");
-        templates.add("vm/java/mapper.java.vm");
-        templates.add("vm/java/service.java.vm");
-        templates.add("vm/java/serviceImpl.java.vm");
-        templates.add("vm/java/controller.java.vm");
-        templates.add("vm/xml/mapper.xml.vm");
-        templates.add("vm/sql/sql.vm");
-        templates.add("vm/js/api.js.vm");
-        if (GenConstants.TPL_CRUD.equals(tplCategory)) {
-            templates.add("vm/vue/index.vue.vm");
-        } else if (GenConstants.TPL_TREE.equals(tplCategory)) {
-            templates.add("vm/vue/index-tree.vue.vm");
-        } else if (GenConstants.TPL_SUB.equals(tplCategory)) {
-            templates.add("vm/vue/index.vue.vm");
-            templates.add("vm/java/sub-domain.java.vm");
-        }
-        return templates;
-    }
-
-    /**
-     * 获取文件名
-     */
-    public static String getFileName(String template, GenTable genTable) {
-        // 文件名称
-        String fileName = "";
-        // 包路径
-        String packageName = genTable.getPackageName();
-        // 模块名
-        String moduleName = genTable.getModuleName();
-        // 大写类名
-        String className = genTable.getClassName();
-        // 业务名称
-        String businessName = genTable.getBusinessName();
-
-        String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
-        String mybatisPath = MYBATIS_PATH + "/" + moduleName;
-        String vuePath = "vue";
-
-        if (template.contains("domain.java.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/domain/{}.java", javaPath, className);
-        }
-        if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
-        } else if (template.contains("mapper.java.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
-        } else if (template.contains("service.java.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/service/I{}Service.java", javaPath, className);
-        } else if (template.contains("serviceImpl.java.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
-        } else if (template.contains("controller.java.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
-        } else if (template.contains("mapper.xml.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
-        } else if (template.contains("sql.vm")) {
-            fileName = businessName + "Menu.sql";
-        } else if (template.contains("api.js.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
-        } else if (template.contains("index.vue.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
-        } else if (template.contains("index-tree.vue.vm")) {
-            fileName = com.zd.common.core.utils.StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
-        }
-        return fileName;
-    }
-
-    /**
-     * 获取包前缀
-     *
-     * @param packageName 包名称
-     * @return 包前缀名称
-     */
-    public static String getPackagePrefix(String packageName) {
-        int lastIndex = packageName.lastIndexOf(".");
-        return StringUtils.substring(packageName, 0, lastIndex);
-    }
-
-    /**
-     * 根据列类型获取导入包
-     *
-     * @param genTable 业务表对象
-     * @return 返回需要导入的包列表
-     */
-    public static Set<String> getImportList(GenTable genTable) {
-        List<GenTableColumn> columns = genTable.getColumns();
-        GenTable subGenTable = genTable.getSubTable();
-        HashSet<String> importList = new HashSet<>();
-        if (com.zd.common.core.utils.StringUtils.isNotNull(subGenTable)) {
-            importList.add("java.util.List");
-        }
-        for (GenTableColumn column : columns) {
-            if (!genTable.isSuperColumn(column.getJavaField()) && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
-                importList.add("java.util.Date");
-                importList.add("com.fasterxml.jackson.annotation.JsonFormat");
-            } else if (!genTable.isSuperColumn(column.getJavaField()) && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
-                importList.add("java.math.BigDecimal");
-            }
-            //验证相关的包
-            //NotBlank
-            if (column.isRequired() && GenConstants.TYPE_STRING.equals(column.getJavaType())) {
-                importList.add("javax.validation.constraints.NotBlank");
-                importList.add("org.hibernate.validator.constraints.Length");
-            }
-            if (column.isRequired() && !GenConstants.TYPE_STRING.equals(column.getJavaType())) {
-                importList.add("javax.validation.constraints.NotNull");
-            }
-
-        }
-        return importList;
-    }
-
-    /**
-     * 获取权限前缀
-     *
-     * @param moduleName   模块名称
-     * @param businessName 业务名称
-     * @return 返回权限前缀
-     */
-    public static String getPermissionPrefix(String moduleName, String businessName) {
-        return com.zd.common.core.utils.StringUtils.format("{}:{}", moduleName, businessName);
-    }
-
-    /**
-     * 获取上级菜单ID字段
-     *
-     * @param paramsObj 生成其他选项
-     * @return 上级菜单ID字段
-     */
-    public static String getParentMenuId(JSONObject paramsObj) {
-        if (com.zd.common.core.utils.StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
-                && StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID))) {
-            return paramsObj.getString(GenConstants.PARENT_MENU_ID);
-        }
-        return DEFAULT_PARENT_MENU_ID;
-    }
-
-    /**
-     * 获取树编码
-     *
-     * @param paramsObj 生成其他选项
-     * @return 树编码
-     */
-    public static String getTreecode(JSONObject paramsObj) {
-        if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
-            return com.zd.common.core.utils.StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
-        }
-        return StringUtils.EMPTY;
-    }
-
-    /**
-     * 获取树父编码
-     *
-     * @param paramsObj 生成其他选项
-     * @return 树父编码
-     */
-    public static String getTreeParentCode(JSONObject paramsObj) {
-        if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
-            return com.zd.common.core.utils.StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
-        }
-        return StringUtils.EMPTY;
-    }
-
-    /**
-     * 获取树名称
-     *
-     * @param paramsObj 生成其他选项
-     * @return 树名称
-     */
-    public static String getTreeName(JSONObject paramsObj) {
-        if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
-            return com.zd.common.core.utils.StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
-        }
-        return StringUtils.EMPTY;
-    }
-
-    /**
-     * 获取需要在哪一列上面显示展开按钮
-     *
-     * @param genTable 业务表对象
-     * @return 展开按钮列序号
-     */
-    public static int getExpandColumn(GenTable genTable) {
-        String options = genTable.getOptions();
-        JSONObject paramsObj = JSON.parseObject(options);
-        String treeName = paramsObj.getString(GenConstants.TREE_NAME);
-        int num = 0;
-        for (GenTableColumn column : genTable.getColumns()) {
-            if (column.isList()) {
-                num++;
-                String columnName = column.getColumnName();
-                if (columnName.equals(treeName)) {
-                    break;
-                }
-            }
-        }
-        return num;
-    }
-}

+ 0 - 10
zd-modules/zd-modules-gen/src/main/resources/banner.txt

@@ -1,10 +0,0 @@
-Spring Boot Version: ${spring-boot.version}
-Spring Application Name: ${spring.application.name}
-                            _                             
-                           (_)                            
- _ __  _   _   ___   _   _  _  ______   __ _   ___  _ __  
-| '__|| | | | / _ \ | | | || ||______| / _` | / _ \| '_ \ 
-| |   | |_| || (_) || |_| || |        | (_| ||  __/| | | |
-|_|    \__,_| \___/  \__, ||_|         \__, | \___||_| |_|
-                      __/ |             __/ |             
-                     |___/             |___/              

+ 0 - 25
zd-modules/zd-modules-gen/src/main/resources/bootstrap.yml

@@ -1,25 +0,0 @@
-# Tomcat
-server:
-  port: 9202
-
-# Spring
-spring:
-  application:
-    # 应用名称
-    name: zd-gen
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-      config:
-        # 配置中心地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-        # 配置文件格式
-        file-extension: yml
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 0 - 74
zd-modules/zd-modules-gen/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-gen"/>
-    <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-    <logger name="com.zd" level="info"/>
-    <!-- Spring日志级别控制  -->
-    <logger name="org.springframework" level="info"/>
-
-    <root level="info">
-        <appender-ref ref="console"/>
-    </root>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info"/>
-        <appender-ref ref="file_error"/>
-    </root>
-</configuration>

+ 0 - 133
zd-modules/zd-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml

@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zd.gen.mapper.GenTableColumnMapper">
-
-    <resultMap type="com.zd.gen.domain.GenTableColumn" id="GenTableColumnResult">
-        <id property="columnId" column="column_id"/>
-        <result property="tableId" column="table_id"/>
-        <result property="columnName" column="column_name"/>
-        <result property="columnComment" column="column_comment"/>
-        <result property="columnType" column="column_type"/>
-        <result property="javaType" column="java_type"/>
-        <result property="javaField" column="java_field"/>
-        <result property="isPk" column="is_pk"/>
-        <result property="isIncrement" column="is_increment"/>
-        <result property="isRequired" column="is_required"/>
-        <result property="isInsert" column="is_insert"/>
-        <result property="isEdit" column="is_edit"/>
-        <result property="isList" column="is_list"/>
-        <result property="isQuery" column="is_query"/>
-        <result property="queryType" column="query_type"/>
-        <result property="htmlType" column="html_type"/>
-        <result property="dictType" column="dict_type"/>
-        <result property="sort" column="sort"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="length" column="length"/>
-    </resultMap>
-
-    <sql id="selectGenTableColumnVo">
-        select column_id, `length`  ,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
-    </sql>
-
-    <select id="selectGenTableColumnListByTableId" parameterType="com.zd.gen.domain.GenTableColumn"
-            resultMap="GenTableColumnResult">
-        <include refid="selectGenTableColumnVo"/>
-        where table_id = #{tableId}
-        order by sort
-    </select>
-
-    <select id="selectDbTableColumnsByName" resultMap="GenTableColumnResult">
-		select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> 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
-	</select>
-
-    <insert id="insertGenTableColumn" parameterType="com.zd.gen.domain.GenTableColumn" useGeneratedKeys="true"
-            keyProperty="columnId">
-        insert into gen_table_column (
-        <if test="tableId != null and tableId != ''">table_id,</if>
-        <if test="columnName != null and columnName != ''">column_name,</if>
-        <if test="columnComment != null and columnComment != ''">column_comment,</if>
-        <if test="columnType != null and columnType != ''">column_type,</if>
-        <if test="javaType != null and javaType != ''">java_type,</if>
-        <if test="javaField != null  and javaField != ''">java_field,</if>
-        <if test="isPk != null and isPk != ''">is_pk,</if>
-        <if test="isIncrement != null and isIncrement != ''">is_increment,</if>
-        <if test="isRequired != null and isRequired != ''">is_required,</if>
-        <if test="isInsert != null and isInsert != ''">is_insert,</if>
-        <if test="isEdit != null and isEdit != ''">is_edit,</if>
-        <if test="isList != null and isList != ''">is_list,</if>
-        <if test="isQuery != null and isQuery != ''">is_query,</if>
-        <if test="queryType != null and queryType != ''">query_type,</if>
-        <if test="htmlType != null and htmlType != ''">html_type,</if>
-        <if test="dictType != null and dictType != ''">dict_type,</if>
-        <if test="sort != null">sort,</if>
-        <if test="createBy != null and createBy != ''">create_by,</if>
-        <if test="length != null ">length,</if>
-        create_time
-        )values(
-        <if test="tableId != null and tableId != ''">#{tableId},</if>
-        <if test="columnName != null and columnName != ''">#{columnName},</if>
-        <if test="columnComment != null and columnComment != ''">#{columnComment},</if>
-        <if test="columnType != null and columnType != ''">#{columnType},</if>
-        <if test="javaType != null and javaType != ''">#{javaType},</if>
-        <if test="javaField != null and javaField != ''">#{javaField},</if>
-        <if test="isPk != null and isPk != ''">#{isPk},</if>
-        <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
-        <if test="isRequired != null and isRequired != ''">#{isRequired},</if>
-        <if test="isInsert != null and isInsert != ''">#{isInsert},</if>
-        <if test="isEdit != null and isEdit != ''">#{isEdit},</if>
-        <if test="isList != null and isList != ''">#{isList},</if>
-        <if test="isQuery != null and isQuery != ''">#{isQuery},</if>
-        <if test="queryType != null and queryType != ''">#{queryType},</if>
-        <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
-        <if test="dictType != null and dictType != ''">#{dictType},</if>
-        <if test="sort != null">#{sort},</if>
-        <if test="createBy != null and createBy != ''">#{createBy},</if>
-        <if test="length != null ">#{length},</if>
-        sysdate()
-        )
-    </insert>
-
-    <update id="updateGenTableColumn" parameterType="com.zd.gen.domain.GenTableColumn">
-        update gen_table_column
-        <set>
-            column_comment = #{columnComment},
-            java_type = #{javaType},
-            java_field = #{javaField},
-            is_insert = #{isInsert},
-            is_edit = #{isEdit},
-            is_list = #{isList},
-            is_query = #{isQuery},
-            is_required = #{isRequired},
-            query_type = #{queryType},
-            html_type = #{htmlType},
-            dict_type = #{dictType},
-            sort = #{sort},
-            update_by = #{updateBy},
-            `length` = #{length},
-            update_time = sysdate()
-        </set>
-        where column_id = #{columnId}
-    </update>
-
-    <delete id="deleteGenTableColumnByIds" >
-        delete from gen_table_column where table_id in
-        <foreach collection="array" item="tableId" open="(" separator="," close=")">
-            #{tableId}
-        </foreach>
-    </delete>
-
-    <delete id="deleteGenTableColumns">
-        delete from gen_table_column where column_id in
-        <foreach collection="list" item="item" open="(" separator="," close=")">
-            #{item.columnId}
-        </foreach>
-    </delete>
-
-</mapper>

+ 0 - 202
zd-modules/zd-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -1,202 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zd.gen.mapper.GenTableMapper">
-
-    <resultMap type="com.zd.gen.domain.GenTable" id="GenTableResult">
-        <id property="tableId" column="table_id"/>
-        <result property="tableName" column="table_name"/>
-        <result property="tableComment" column="table_comment"/>
-        <result property="subTableName" column="sub_table_name"/>
-        <result property="subTableFkName" column="sub_table_fk_name"/>
-        <result property="className" column="class_name"/>
-        <result property="tplCategory" column="tpl_category"/>
-        <result property="packageName" column="package_name"/>
-        <result property="moduleName" column="module_name"/>
-        <result property="businessName" column="business_name"/>
-        <result property="functionName" column="function_name"/>
-        <result property="functionAuthor" column="function_author"/>
-        <result property="genType" column="gen_type"/>
-        <result property="genPath" column="gen_path"/>
-        <result property="options" column="options"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="remark" column="remark"/>
-        <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult"/>
-    </resultMap>
-
-    <resultMap type="com.zd.gen.domain.GenTableColumn" id="GenTableColumnResult">
-        <id property="columnId" column="column_id"/>
-        <result property="tableId" column="table_id"/>
-        <result property="columnName" column="column_name"/>
-        <result property="columnComment" column="column_comment"/>
-        <result property="columnType" column="column_type"/>
-        <result property="javaType" column="java_type"/>
-        <result property="javaField" column="java_field"/>
-        <result property="isPk" column="is_pk"/>
-        <result property="isIncrement" column="is_increment"/>
-        <result property="isRequired" column="is_required"/>
-        <result property="isInsert" column="is_insert"/>
-        <result property="isEdit" column="is_edit"/>
-        <result property="isList" column="is_list"/>
-        <result property="isQuery" column="is_query"/>
-        <result property="queryType" column="query_type"/>
-        <result property="htmlType" column="html_type"/>
-        <result property="dictType" column="dict_type"/>
-        <result property="sort" column="sort"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="length" column="length"/>
-    </resultMap>
-
-    <sql id="selectGenTableVo">
-        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
-    </sql>
-
-    <select id="selectGenTableList" parameterType="com.zd.gen.domain.GenTable" resultMap="GenTableResult">
-        <include refid="selectGenTableVo"/>
-        <where>
-            <if test="tableName != null and tableName != ''">
-                AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
-            </if>
-            <if test="tableComment != null and tableComment != ''">
-                AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
-            </if>
-            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-            </if>
-            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
-            </if>
-        </where>
-    </select>
-
-    <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
-        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)
-        <if test="tableName != null and tableName != ''">
-            AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
-        </if>
-        <if test="tableComment != null and tableComment != ''">
-            AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
-        </if>
-        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-            AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-        </if>
-        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-            AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
-        </if>
-    </select>
-
-    <select id="selectDbTableListByNames" resultMap="GenTableResult">
-        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
-        <foreach collection="array" item="name" open="(" separator="," close=")">
-            #{name}
-        </foreach>
-    </select>
-
-    <select id="selectTableByName" resultMap="GenTableResult">
-		select table_name, table_comment, create_time, update_time from information_schema.tables
-		where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
-		and table_name = #{tableName}
-	</select>
-
-    <select id="selectGenTableById"  resultMap="GenTableResult">
-	    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.gen_type, t.gen_path, 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,c.length
-		FROM gen_table t
-			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
-		where t.table_id = #{tableId} order by c.sort
-	</select>
-
-    <select id="selectGenTableByName" resultMap="GenTableResult">
-	    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.gen_type, t.gen_path, 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,c.length
-		FROM gen_table t
-			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
-		where t.table_name = #{tableName} order by c.sort
-	</select>
-
-    <select id="selectGenTableAll" resultMap="GenTableResult">
-	    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,c.length
-		FROM gen_table t
-			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
-		order by c.sort
-	</select>
-
-    <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
-        insert into gen_table (
-        <if test="tableName != null">table_name,</if>
-        <if test="tableComment != null and tableComment != ''">table_comment,</if>
-        <if test="className != null and className != ''">class_name,</if>
-        <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
-        <if test="packageName != null and packageName != ''">package_name,</if>
-        <if test="moduleName != null and moduleName != ''">module_name,</if>
-        <if test="businessName != null and businessName != ''">business_name,</if>
-        <if test="functionName != null and functionName != ''">function_name,</if>
-        <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
-        <if test="genType != null and genType != ''">gen_type,</if>
-        <if test="genPath != null and genPath != ''">gen_path,</if>
-        <if test="remark != null and remark != ''">remark,</if>
-        <if test="createBy != null and createBy != ''">create_by,</if>
-        create_time
-        )values(
-        <if test="tableName != null">#{tableName},</if>
-        <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
-        <if test="className != null and className != ''">#{className},</if>
-        <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
-        <if test="packageName != null and packageName != ''">#{packageName},</if>
-        <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
-        <if test="businessName != null and businessName != ''">#{businessName},</if>
-        <if test="functionName != null and functionName != ''">#{functionName},</if>
-        <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
-        <if test="genType != null and genType != ''">#{genType},</if>
-        <if test="genPath != null and genPath != ''">#{genPath},</if>
-        <if test="remark != null and remark != ''">#{remark},</if>
-        <if test="createBy != null and createBy != ''">#{createBy},</if>
-        sysdate()
-        )
-    </insert>
-
-    <update id="updateGenTable" parameterType="GenTable">
-        update gen_table
-        <set>
-            <if test="tableName != null">table_name = #{tableName},</if>
-            <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
-            <if test="subTableName != null">sub_table_name = #{subTableName},</if>
-            <if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
-            <if test="className != null and className != ''">class_name = #{className},</if>
-            <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
-            <if test="genType != null and genType != ''">gen_type = #{genType},</if>
-            <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
-            <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
-            <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
-            <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
-            <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
-            <if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
-            <if test="options != null and options != ''">options = #{options},</if>
-            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
-            <if test="remark != null">remark = #{remark},</if>
-            update_time = sysdate()
-        </set>
-        where table_id = #{tableId}
-    </update>
-
-    <delete id="deleteGenTableByIds" >
-        delete from gen_table where table_id in
-        <foreach collection="array" item="tableId" open="(" separator="," close=")">
-            #{tableId}
-        </foreach>
-    </delete>
-
-</mapper>

+ 0 - 127
zd-modules/zd-modules-gen/src/main/resources/vm/java/controller.java.vm

@@ -1,127 +0,0 @@
-package ${packageName}.controller;
-
-import java.util.List;
-import java.io.IOException;
-import javax.servlet.http.HttpServletResponse;
-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.zd.common.response.ResultData;
-import com.zd.common.log.annotation.Log;
-import com.zd.common.log.enums.BusinessType;
-import com.zd.common.security.annotation.PreAuthorize;
-import ${packageName}.domain.${ClassName};
-import ${packageName}.service.I${ClassName}Service;
-import com.zd.common.core.web.controller.BaseController;
-import com.zd.common.core.web.domain.AjaxResult;
-import com.zd.common.core.utils.poi.ExcelUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-
-#if($table.crud || $table.sub)
-import com.zd.common.core.web.page.TableDataInfo;
-#elseif($table.tree)
-#end
-
-/**
- * ${functionName}Controller
- * 
- * @author ${author}
- * @date ${datetime}
- */
-@RestController
-@Api(tags = "【${functionName}】")
-@RequestMapping("/${businessName}")
-public class ${ClassName}Controller extends BaseController<${ClassName}>
-{
-    @Autowired
-    private I${ClassName}Service ${className}Service;
-
-    /**
-     * 查询${functionName}列表
-     */
-    @PreAuthorize(hasPermi = "${permissionPrefix}:list")
-    @GetMapping("/list")
-    @ApiOperation(value = "查询${functionName}列表")
-#if($table.crud || $table.sub)
-    public TableDataInfo<${ClassName}> list(${ClassName} ${className})
-    {
-        startPage();
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        return getDataTable(list);
-    }
-#elseif($table.tree)
-    public AjaxResult list(${ClassName} ${className})
-    {
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        return AjaxResult.success(list);
-    }
-#end
-
-    /**
-     * 导出${functionName}列表
-     */
-    @ApiOperation(value = "导出${functionName}列表")
-    @PreAuthorize(hasPermi = "${permissionPrefix}:export")
-    @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, ${ClassName} ${className}) throws IOException
-    {
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
-        util.exportExcel(response, list, "${functionName}数据");
-    }
-
-    /**
-     * 获取${functionName}详细信息
-     */
-    @ApiOperation(value = "获取${functionName}详细信息")
-    @PreAuthorize(hasPermi = "${permissionPrefix}:query")
-    @GetMapping(value = "/{${pkColumn.javaField}}")
-    public ResultData<${ClassName}> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
-    {
-        return ResultData.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
-    }
-
-    /**
-     * 新增${functionName}
-     */
-    @ApiOperation(value = "新增${functionName}")
-    @PreAuthorize(hasPermi = "${permissionPrefix}:add")
-    @Log(title = "${functionName}", businessType = BusinessType.INSERT)
-    @PostMapping
-    public ResultData add(@RequestBody ${ClassName} ${className})
-    {
-        return ResultData.result(${className}Service.insert${ClassName}(${className}));
-    }
-
-    /**
-     * 修改${functionName}
-     */
-    @ApiOperation(value = "修改${functionName}")
-    @PreAuthorize(hasPermi = "${permissionPrefix}:edit")
-    @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public ResultData edit(@RequestBody ${ClassName} ${className})
-    {
-        return  ResultData.result(${className}Service.update${ClassName}(${className}));
-    }
-
-    /**
-     * 删除${functionName}
-     */
-    @ApiOperation(value = "删除${functionName}")
-    @PreAuthorize(hasPermi = "${permissionPrefix}:remove")
-    @Log(title = "${functionName}", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{${pkColumn.javaField}s}")
-    public ResultData remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
-    {
-        return ResultData.result(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
-    }
-}

+ 0 - 115
zd-modules/zd-modules-gen/src/main/resources/vm/java/domain.java.vm

@@ -1,115 +0,0 @@
-package ${packageName}.domain;
-
-#foreach ($import in $importList)
-import ${import};
-#end
-import com.zd.common.core.annotation.Excel;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.ToString;
-import lombok.experimental.Accessors;
-import org.hibernate.validator.constraints.Length;
-#if($table.crud || $table.sub)
-import com.zd.common.core.web.domain.BaseEntity;
-#elseif($table.tree)
-import com.zd.common.core.web.domain.TreeEntity;
-#end
-
-/**
- * ${functionName}对象 ${tableName}
- * 
- * @author ${author}
- * @date ${datetime}
- */
-#if($table.crud || $table.sub)
-#set($Entity="BaseEntity")
-#elseif($table.tree)
-#set($Entity="TreeEntity")
-#end
-@ApiModel("${functionName}")
-@Data
-@Accessors(chain = true)
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = false)
-public class ${ClassName} extends ${Entity}
-{
-    private static final long serialVersionUID = 1L;
-
-#foreach ($column in $columns)
-#if(!$table.isSuperColumn($column.javaField))
-    /** $column.columnComment */
-#if($column.list)
-#set($parentheseIndex=$column.columnComment.indexOf("("))
-#if($parentheseIndex != -1)
-#set($comment=$column.columnComment.substring(0, $parentheseIndex))
-#else
-#set($comment=$column.columnComment)
-#end
-#if($parentheseIndex != -1)
-    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
-#elseif($column.javaType == 'Date')
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
-#else
-    @Excel(name = "${comment}")
-#end
-#if($column.javaType=="String")
-#set($comment1=-1)
-#else
-#set($comment1=0)
-#end
-#if($column.required)
-#if($comment1==-1)
-    @NotBlank(groups = ValidGroup.Crud.Create.class,message = "${comment}不能为空")
-#else
-    @NotNull(groups = ValidGroup.Crud.Create.class,message = "${comment}不能为空")
-#end
-#end
-#if($column.length!=0 &&$column.length!=-1 && $comment1== -1)
-    @Length(message = "${comment}长度不能超过$column.length")
-#end
-#end
-    @ApiModelProperty(value = "${comment}")
-    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()
-##    {
-##        return ${subclassName}List;
-##    }
-##
-##    public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
-##    {
-##        this.${subclassName}List = ${subclassName}List;
-##    }
-##
-###end
-
-}

+ 0 - 99
zd-modules/zd-modules-gen/src/main/resources/vm/java/mapper.java.vm

@@ -1,99 +0,0 @@
-package ${packageName}.mapper;
-
-import java.util.List;
-import ${packageName}.domain.${ClassName};
-#if($table.sub)
-import ${packageName}.domain.${subClassName};
-#end
-
-/**
- * ${functionName}Mapper接口
- * 
- * @author ${author}
- * @date ${datetime}
- */
-public interface ${ClassName}Mapper 
-{
-    /**
-     * 查询${functionName}
-     * 
-     * @param ${pkColumn.javaField} ${functionName}主键
-     * @return ${functionName}
-     */
-    ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
-
-    /**
-     * 查询${functionName}列表
-     * 
-     * @param ${className} ${functionName}
-     * @return ${functionName}集合
-     */
-    List<${ClassName}> select${ClassName}List(${ClassName} ${className});
-
-    /**
-     * 根据主键集合查询${functionName}列表
-     *
-     * @param ids 主键集合
-     * @return ${functionName}集合
-     */
-    List<${ClassName}> getListByIds(List<${pkColumn.javaType}> ids);
-
-    /**
-     * 新增${functionName}
-     * 
-     * @param ${className} ${functionName}
-     * @return 结果
-     */
-    int insert${ClassName}(${ClassName} ${className});
-
-    /**
-     * 修改${functionName}
-     * 
-     * @param ${className} ${functionName}
-     * @return 结果
-     */
-    int update${ClassName}(${ClassName} ${className});
-
-    /**
-     * 删除${functionName}
-     * 
-     * @param ${pkColumn.javaField} ${functionName}主键
-     * @return 结果
-     */
-    int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
-
-    /**
-     * 批量删除${functionName}
-     * 
-     * @param ${pkColumn.javaField}s 需要删除的数据主键集合
-     * @return 结果
-     */
-    int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
-#if($table.sub)
-
-    /**
-     * 批量删除${subTable.functionName}
-     * 
-     * @param ${pkColumn.javaField}s 需要删除的数据主键集合
-     * @return 结果
-     */
-    int delete${subClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
-    
-    /**
-     * 批量新增${subTable.functionName}
-     * 
-     * @param ${subclassName}List ${subTable.functionName}列表
-     * @return 结果
-     */
-    int batch${subClassName}(List<${subClassName}> ${subclassName}List);
-    
-
-    /**
-     * 通过${functionName}主键删除${subTable.functionName}信息
-     * 
-     * @param ${pkColumn.javaField} ${functionName}ID
-     * @return 结果
-     */
-    int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
-#end
-}

+ 0 - 0
zd-modules/zd-modules-gen/src/main/resources/vm/java/service.java.vm


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików