+ * 读取控制台内容 + *
+ */ + public static String scanner(String tip) { + Scanner scanner = new Scanner(System.in); + StringBuilder help = new StringBuilder(); + help.append("请输入" + tip + ":"); + System.out.println(help.toString()); + if (scanner.hasNext()) { + String ipt = scanner.next(); + if (StringUtils.isNotEmpty(ipt)) { + return ipt; + } + } + throw new MybatisPlusException("请输入正确的" + tip + "!"); + } + + public static void main(String[] args) { + // 代码生成器 + AutoGenerator mpg = new AutoGenerator(); + + // 全局配置 + GlobalConfig gc = new GlobalConfig(); + String projectPath = System.getProperty("user.dir"); + gc.setOutputDir(projectPath + PACKAGE_PATH+"/java"); + gc.setAuthor(AUTHOR); + gc.setOpen(false); + gc.setSwagger2(true); //实体属性 Swagger2 注解 + gc.setMapperName("%sDao"); + mpg.setGlobalConfig(gc); + + // 数据源配置 ORACLE +// DataSourceConfig dsc = new DataSourceConfig(); +// dsc.setUrl("jdbc:oracle:thin:@"+DB_IP); +// // dsc.setSchemaName("public"); +// dsc.setDriverName("oracle.jdbc.OracleDriver"); +// dsc.setUsername(DB_USER); +// dsc.setPassword(DB_PWD); +// mpg.setDataSource(dsc); + + // 数据源配置 MYSQL + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setUrl("jdbc:mysql://"+DB_IP+"?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false"); + //dsc.setSchemaName("public");//PostgreSQL schemaName + dsc.setDriverName("com.mysql.cj.jdbc.Driver"); + dsc.setUsername(DB_USER); + dsc.setPassword(DB_PWD); + mpg.setDataSource(dsc); + + // 包配置 + PackageConfig pc = new PackageConfig(); + pc.setModuleName(scanner("模块名")); + pc.setMapper("dao"); + pc.setParent("com.adc.da.slrs"); + mpg.setPackageInfo(pc); + + // 自定义配置 + InjectionConfig cfg = new InjectionConfig() { + @Override + public void initMap() { + // to do nothing + } + }; + + // 如果模板引擎是 freemarker + String templatePath = "/templates/mapper.xml.ftl"; + // 如果模板引擎是 velocity + // String templatePath = "/templates/mapper.xml.vm"; + + // 自定义输出配置 + List+ * ${table.comment!} + *
+ * + * @author ${author} + * @since ${date} + */ +<#if entityLombokModel> +@Data + <#if superEntityClass??> +@EqualsAndHashCode(callSuper = true) + <#else> +@EqualsAndHashCode(callSuper = false) + #if> +@Accessors(chain = true) +#if> +<#if table.convert> +@TableName("${table.name}") +#if> +<#if swagger2> +@ApiModel(value="${entity}对象", description="${table.comment!}") +#if> +<#if superEntityClass??> +public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}>#if> { +<#elseif activeRecord> +public class ${entity} extends Model<${entity}> { +<#else> +public class ${entity} implements Serializable { +#if> + +<#if entitySerialVersionUID> + private static final long serialVersionUID = 1L; +#if> +<#-- ---------- BEGIN 字段循环遍历 ----------> +<#list table.fields as field> + <#if field.keyFlag> + <#assign keyPropertyName="${field.propertyName}"/> + #if> + + <#if field.comment!?length gt 0> + <#if swagger2> + @ApiModelProperty(value = "${field.comment}") + <#else> + /** + * ${field.comment} + */ + #if> + #if> + <#if field.keyFlag> + <#-- 主键 --> + <#if field.keyIdentityFlag> + @TableId(value = "${field.name}", type = IdType.AUTO) + <#elseif idType??> + @TableId(value = "${field.name}", type = IdType.${idType}) + <#elseif field.convert> + @TableId("${field.name}") + #if> + <#-- 普通字段 --> + <#elseif field.fill??> + <#-- ----- 存在字段填充设置 -----> + <#if field.convert> + @TableField(value = "${field.name}", fill = FieldFill.${field.fill}) + <#else> + @TableField(fill = FieldFill.${field.fill}) + #if> + <#elseif field.convert> + @TableField("${field.name}") + #if> + <#-- 乐观锁注解 --> + <#if (versionFieldName!"") == field.name> + @Version + #if> + <#-- 逻辑删除注解 --> + <#if (logicDeleteFieldName!"") == field.name> + @TableLogic + #if> + private ${field.propertyType} ${field.propertyName}; +#list> +<#------------ END 字段循环遍历 ----------> + +<#if !entityLombokModel> + <#list table.fields as field> + <#if field.propertyType == "boolean"> + <#assign getprefix="is"/> + <#else> + <#assign getprefix="get"/> + #if> + public ${field.propertyType} ${getprefix}${field.capitalName}() { + return ${field.propertyName}; + } + + <#if entityBuilderModel> + public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + <#else> + public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + #if> + this.${field.propertyName} = ${field.propertyName}; + <#if entityBuilderModel> + return this; + #if> + } + #list> +#if> + +<#if entityColumnConstant> + <#list table.fields as field> + public static final String ${field.name?upper_case} = "${field.name}"; + + #list> +#if> +<#if activeRecord> + @Override + protected Serializable pkVal() { + <#if keyPropertyName??> + return this.${keyPropertyName}; + <#else> + return null; + #if> + } + +#if> +<#if !entityLombokModel> + @Override + public String toString() { + return "${entity}{" + + <#list table.fields as field> + <#if field_index==0> + "${field.propertyName}=" + ${field.propertyName} + + <#else> + ", ${field.propertyName}=" + ${field.propertyName} + + #if> + #list> + "}"; + } +#if> +} diff --git a/adc-da-main/src/main/resources/temp/mapper.java.ftl b/adc-da-main/src/main/resources/temp/mapper.java.ftl new file mode 100644 index 00000000..53da4ae3 --- /dev/null +++ b/adc-da-main/src/main/resources/temp/mapper.java.ftl @@ -0,0 +1,20 @@ +package ${package.Mapper}; + +import ${package.Entity}.${entity}; +import ${superMapperClassPackage}; + +/** + *+ * ${table.comment!} Mapper 接口 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.mapperName} : ${superMapperClass}<${entity}> +<#else> +public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { + +} +#if> diff --git a/adc-da-main/src/main/resources/temp/service.java.ftl b/adc-da-main/src/main/resources/temp/service.java.ftl new file mode 100644 index 00000000..e3232f3a --- /dev/null +++ b/adc-da-main/src/main/resources/temp/service.java.ftl @@ -0,0 +1,20 @@ +package ${package.Service}; + +import ${package.Entity}.${entity}; +import ${superServiceClassPackage}; + +/** + *+ * ${table.comment!} 服务类 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.serviceName} : ${superServiceClass}<${entity}> +<#else> +public interface ${table.serviceName} extends ${superServiceClass}<${entity}> { + +} +#if> diff --git a/adc-da-main/src/main/resources/templates/controller.java.ftl b/adc-da-main/src/main/resources/templates/controller.java.ftl new file mode 100644 index 00000000..df485cbe --- /dev/null +++ b/adc-da-main/src/main/resources/templates/controller.java.ftl @@ -0,0 +1,41 @@ +package ${package.Controller}; + + +import org.springframework.web.bind.annotation.RequestMapping; +import ${package.Entity}.${entity}; +import io.swagger.annotations.Api; +<#if restControllerStyle> +import org.springframework.web.bind.annotation.RestController; +<#else> +import org.springframework.stereotype.Controller; +#if> +<#if superControllerClassPackage??> +import ${superControllerClassPackage}; +#if> + +/** +*+ * ${table.comment!} 前端控制器 + *
+* +* @author ${author} +* @since ${date} +*/ +<#if restControllerStyle> +@RestController +<#else> +@Controller +#if> +@Api(description = "|${entity}|") +@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}#if>") +<#if kotlin> +class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()#if> +<#else> + <#if superControllerClass??> +public class ${table.controllerName} extends ${superControllerClass}<${entity}> { + <#else> +public class ${table.controllerName} extends ${superControllerClass}<${entity}>{ + #if> + +} +#if> diff --git a/adc-da-main/src/main/resources/templates/entity.java.ftl b/adc-da-main/src/main/resources/templates/entity.java.ftl new file mode 100644 index 00000000..c698d363 --- /dev/null +++ b/adc-da-main/src/main/resources/templates/entity.java.ftl @@ -0,0 +1,152 @@ +package ${package.Entity}; + +<#list table.importPackages as pkg> +import ${pkg}; +#list> +<#if swagger2> +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +#if> +<#if entityLombokModel> +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +#if> + +/** + *+ * ${table.comment!} + *
+ * + * @author ${author} + * @since ${date} + */ +<#if entityLombokModel> +@Data + <#if superEntityClass??> +@EqualsAndHashCode(callSuper = true) + <#else> +@EqualsAndHashCode(callSuper = false) + #if> +@Accessors(chain = true) +#if> +<#if table.convert> +@TableName("${table.name}") +#if> +<#if swagger2> +@ApiModel(value="${entity}对象", description="${table.comment!}") +#if> +<#if superEntityClass??> +public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}>#if> { +<#elseif activeRecord> +public class ${entity} extends Model<${entity}> { +<#else> +public class ${entity} implements Serializable { +#if> + +<#if entitySerialVersionUID> + private static final long serialVersionUID = 1L; +#if> +<#-- ---------- BEGIN 字段循环遍历 ----------> +<#list table.fields as field> + <#if field.keyFlag> + <#assign keyPropertyName="${field.propertyName}"/> + #if> + + <#if field.comment!?length gt 0> + <#if swagger2> + @ApiModelProperty(value = "${field.comment}") + <#else> + /** + * ${field.comment} + */ + #if> + #if> + <#if field.keyFlag> + <#-- 主键 --> + <#if field.keyIdentityFlag> + @TableId(value = "${field.name}", type = IdType.AUTO) + <#elseif idType??> + @TableId(value = "${field.name}", type = IdType.${idType}) + <#elseif field.convert> + @TableId("${field.name}") + #if> + <#-- 普通字段 --> + <#elseif field.fill??> + <#-- ----- 存在字段填充设置 -----> + <#if field.convert> + @TableField(value = "${field.name}", fill = FieldFill.${field.fill}) + <#else> + @TableField(fill = FieldFill.${field.fill}) + #if> + <#elseif field.convert> + @TableField("${field.name}") + #if> + <#-- 乐观锁注解 --> + <#if (versionFieldName!"") == field.name> + @Version + #if> + <#-- 逻辑删除注解 --> + <#if (logicDeleteFieldName!"") == field.name> + @TableLogic + #if> + private ${field.propertyType} ${field.propertyName}; +#list> +<#------------ END 字段循环遍历 ----------> + +<#if !entityLombokModel> + <#list table.fields as field> + <#if field.propertyType == "boolean"> + <#assign getprefix="is"/> + <#else> + <#assign getprefix="get"/> + #if> + public ${field.propertyType} ${getprefix}${field.capitalName}() { + return ${field.propertyName}; + } + + <#if entityBuilderModel> + public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + <#else> + public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + #if> + this.${field.propertyName} = ${field.propertyName}; + <#if entityBuilderModel> + return this; + #if> + } + #list> +#if> + +<#if entityColumnConstant> + <#list table.fields as field> + public static final String ${field.name?upper_case} = "${field.name}"; + + #list> +#if> +<#if activeRecord> + @Override + protected Serializable pkVal() { + <#if keyPropertyName??> + return this.${keyPropertyName}; + <#else> + return null; + #if> + } + +#if> +<#if !entityLombokModel> + @Override + public String toString() { + return "${entity}{" + + <#list table.fields as field> + <#if field_index==0> + "${field.propertyName}=" + ${field.propertyName} + + <#else> + ", ${field.propertyName}=" + ${field.propertyName} + + #if> + #list> + "}"; + } +#if> +} diff --git a/adc-da-main/src/main/resources/templates/mapper.java.ftl b/adc-da-main/src/main/resources/templates/mapper.java.ftl new file mode 100644 index 00000000..53da4ae3 --- /dev/null +++ b/adc-da-main/src/main/resources/templates/mapper.java.ftl @@ -0,0 +1,20 @@ +package ${package.Mapper}; + +import ${package.Entity}.${entity}; +import ${superMapperClassPackage}; + +/** + *+ * ${table.comment!} Mapper 接口 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.mapperName} : ${superMapperClass}<${entity}> +<#else> +public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { + +} +#if> diff --git a/adc-da-main/src/main/resources/templates/mapper.xml.ftl b/adc-da-main/src/main/resources/templates/mapper.xml.ftl new file mode 100644 index 00000000..d9ca71c4 --- /dev/null +++ b/adc-da-main/src/main/resources/templates/mapper.xml.ftl @@ -0,0 +1,39 @@ + + ++ * ${table.comment!} 服务类 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.serviceName} : ${superServiceClass}<${entity}> +<#else> +public interface ${table.serviceName} extends ${superServiceClass}<${entity}> { + +} +#if> diff --git a/adc-da-main/src/main/resources/templates/serviceImpl.java.ftl b/adc-da-main/src/main/resources/templates/serviceImpl.java.ftl new file mode 100644 index 00000000..aeebd14c --- /dev/null +++ b/adc-da-main/src/main/resources/templates/serviceImpl.java.ftl @@ -0,0 +1,26 @@ +package ${package.ServiceImpl}; + +import ${package.Entity}.${entity}; +import ${package.Mapper}.${table.mapperName}; +import ${package.Service}.${table.serviceName}; +import ${superServiceImplClassPackage}; +import org.springframework.stereotype.Service; + +/** + *+ * ${table.comment!} 服务实现类 + *
+ * + * @author ${author} + * @since ${date} + */ +@Service +<#if kotlin> +open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} { + +} +<#else> +public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} { + +} +#if> diff --git a/adc-da-main/src/main/resources/ueditor/config.json b/adc-da-main/src/main/resources/ueditor/config.json new file mode 100644 index 00000000..77a0a70f --- /dev/null +++ b/adc-da-main/src/main/resources/ueditor/config.json @@ -0,0 +1,97 @@ +/* 前后端通信相关的配置,注释只允许使用多行方式 */ +{ + /* 上传图片配置项 */ + "imageActionName": "/api/ueditor/uploadImageData", /* 执行上传图片的action名称 */ + "imageFieldName": "upfile", /* 提交的图片表单名称 */ + "imageMaxSize": 2048000, /* 上传大小限制,单位B */ + "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */ + "imageCompressEnable": true, /* 是否压缩图片,默认是true */ + "imageCompressBorder": 1600, /* 图片压缩最长边限制 */ + "imageInsertAlign": "none", /* 插入的图片浮动方式 */ + "imageUrlPrefix": "", /* 图片访问路径前缀 */ + "localSavePathPrefix":"upload/images/inform", + "imagePathFormat": "", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + /* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */ + /* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */ + /* {time} 会替换成时间戳 */ + /* {yyyy} 会替换成四位年份 */ + /* {yy} 会替换成两位年份 */ + /* {mm} 会替换成两位月份 */ + /* {dd} 会替换成两位日期 */ + /* {hh} 会替换成两位小时 */ + /* {ii} 会替换成两位分钟 */ + /* {ss} 会替换成两位秒 */ + /* 非法字符 \ : * ? " < > | */ + /* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */ + + /* 涂鸦图片上传配置项 */ + "scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */ + "scrawlFieldName": "upfile", /* 提交的图片表单名称 */ + "scrawlPathFormat": "", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "scrawlMaxSize": 2048000, /* 上传大小限制,单位B */ + "scrawlUrlPrefix": "", /* 图片访问路径前缀 */ + "scrawlInsertAlign": "none", + + /* 截图工具上传 */ + "snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */ + "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", /* 执行抓取远程图片的action名称 */ + "catcherFieldName": "source", /* 提交的图片列表表单名称 */ + "catcherPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "catcherUrlPrefix": "", /* 图片访问路径前缀 */ + "catcherMaxSize": 2048000, /* 上传大小限制,单位B */ + "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 抓取图片格式显示 */ + /*抓取远程图片是否开启,默认true*/ + "catchRemoteImageEnable": false, + + /* 上传视频配置 */ + "videoActionName": "uploadvideo", /* 执行上传视频的action名称 */ + "videoFieldName": "upfile", /* 提交的视频表单名称 */ + "videoPathFormat": "/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "videoUrlPrefix": "", /* 视频访问路径前缀 */ + "videoMaxSize": 102400000, /* 上传大小限制,单位B,默认100MB */ + "videoAllowFiles": [ + ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", + ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */ + + /* 上传文件配置 */ + "fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */ + "fileFieldName": "upfile", /* 提交的文件表单名称 */ + "filePathFormat": "/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "fileUrlPrefix": "", /* 文件访问路径前缀 */ + "fileMaxSize": 51200000, /* 上传大小限制,单位B,默认50MB */ + "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", /* 执行图片管理的action名称 */ + "imageManagerListPath": "/ueditor/jsp/upload/image/", /* 指定要列出图片的目录 */ + "imageManagerListSize": 20, /* 每次列出文件数量 */ + "imageManagerUrlPrefix": "", /* 图片访问路径前缀 */ + "imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */ + "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件类型 */ + + /* 列出指定目录下的文件 */ + "fileManagerActionName": "listfile", /* 执行文件管理的action名称 */ + "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" + ] /* 列出的文件类型 */ + +} \ No newline at end of file diff --git a/adc-da-main/src/main/resources/white/uploadWhite.txt b/adc-da-main/src/main/resources/white/uploadWhite.txt new file mode 100644 index 00000000..fd4a3ae3 --- /dev/null +++ b/adc-da-main/src/main/resources/white/uploadWhite.txt @@ -0,0 +1,12 @@ +pdf +doc +docx +xlsx +xls +zip +rar +jpg +jpge +png +gif +ppt \ No newline at end of file diff --git a/adc-da-main/src/main/resources/white/xssWhite.txt b/adc-da-main/src/main/resources/white/xssWhite.txt new file mode 100644 index 00000000..b724e4db --- /dev/null +++ b/adc-da-main/src/main/resources/white/xssWhite.txt @@ -0,0 +1 @@ +/upload/ \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandUnqualified/controller/SarStandUnqualifiedController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandUnqualified/controller/SarStandUnqualifiedController.java index 5bd7e17e..87b321e4 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandUnqualified/controller/SarStandUnqualifiedController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandUnqualified/controller/SarStandUnqualifiedController.java @@ -2,6 +2,7 @@ package com.adc.da.slrs.sarStandUnqualified.controller; import com.adc.da.slrs.sarStandUnqualified.service.ISarStandUnqualifiedService; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualified; @@ -23,4 +24,6 @@ import com.adc.da.base.web.BaseController; public class SarStandUnqualifiedController extends BaseController