diff --git a/springboot-log/README.md b/springboot-log/README.md new file mode 100644 index 0000000..e35eead --- /dev/null +++ b/springboot-log/README.md @@ -0,0 +1,43 @@ +## springBoot-demo + +springBoot-demo 是一个SpringBoot的基础框架项目,可以在此项目上进行扩展。 + +## 开发环境 + +- Java 8+ +- Maven 3.5.4+ +- SpringBoot 2.3.12.RELEASE +- mysql5.7+ +- ant1.9+ (非必须,打包可用) + + +## 快速开始 + +**使用** + +- git clone https://github.com/xuwujing/springBoot-study/springBoot-demo.git + +**使用** + +秉着开箱即用的原则,更改相应的配置(MySql、Es、Redis等地址配置),运行main方法,即可启动! + +**注意** + + EasyCode模板生成的xml若是没有逗号,则需要将全局模版velocityHasNext修改为foreach.hasNext。 + +## 项目结构 + +``` +springBoot-demo +├── pom.xml +├── README.md +├── build-dev.bat ant打包脚本启动命令 +├── build-dev.xml ant打包脚本 +├── git-info.bat git信息获取 +├── start.sh linux启动脚本 +├── stop.sh linux停止动脚本 +└── src + ├── main + │   ├── java + │   │   └── com + │   │   └── pancm \ No newline at end of file diff --git a/springboot-log/build-dev.bat b/springboot-log/build-dev.bat new file mode 100644 index 0000000..3178c7c --- /dev/null +++ b/springboot-log/build-dev.bat @@ -0,0 +1 @@ +ant -f build-dev.xml \ No newline at end of file diff --git a/springboot-log/build-dev.xml b/springboot-log/build-dev.xml new file mode 100644 index 0000000..abf9d50 --- /dev/null +++ b/springboot-log/build-dev.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/springboot-log/db/pcm.sql b/springboot-log/db/pcm.sql new file mode 100644 index 0000000..83bc610 --- /dev/null +++ b/springboot-log/db/pcm.sql @@ -0,0 +1,42 @@ +/* + Navicat Premium Data Transfer + + Source Server : 本地-mysql + Source Server Type : MySQL + Source Server Version : 50744 + Source Host : localhost:3306 + Source Schema : pcm + + Target Server Type : MySQL + Target Server Version : 50744 + File Encoding : 65001 + + Date: 15/01/2024 15:40:52 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名', + `sex` tinyint(1) NULL DEFAULT 1 COMMENT '性别', + `age` int(4) NULL DEFAULT NULL COMMENT '年龄', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人', + `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES (1, '张三', 1, 18, '2020-02-15 14:35:46', 'admin', '2021-01-15 14:36:28', 'admin'); +INSERT INTO `user` VALUES (2, '小红', 2, 26, '2022-02-16 14:36:10', 'admin', '2021-01-15 14:36:39', 'admin'); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/springboot-log/easycode/EasyCodeConfig.json b/springboot-log/easycode/EasyCodeConfig.json new file mode 100644 index 0000000..8f4740b --- /dev/null +++ b/springboot-log/easycode/EasyCodeConfig.json @@ -0,0 +1,155 @@ +{ + "author" : "pancm", + "version" : "1.2.8", + "userSecure" : "", + "currTypeMapperGroupName" : "Default", + "currTemplateGroupName" : "pancm_mybatis_plus", + "currColumnConfigGroupName" : "Default", + "currGlobalConfigGroupName" : "Default", + "typeMapper" : { + "Default" : { + "name" : "Default", + "elementList" : [ { + "matchType" : "REGEX", + "columnType" : "varchar(\\(\\d+\\))?", + "javaType" : "java.lang.String" + }, { + "matchType" : "REGEX", + "columnType" : "char(\\(\\d+\\))?", + "javaType" : "java.lang.String" + }, { + "matchType" : "REGEX", + "columnType" : "(tiny|medium|long)*text", + "javaType" : "java.lang.String" + }, { + "matchType" : "REGEX", + "columnType" : "decimal(\\(\\d+,\\d+\\))?", + "javaType" : "java.lang.Double" + }, { + "matchType" : "ORDINARY", + "columnType" : "integer", + "javaType" : "java.lang.Integer" + }, { + "matchType" : "REGEX", + "columnType" : "(tiny|small|medium)*int(\\(\\d+\\))?", + "javaType" : "java.lang.Integer" + }, { + "matchType" : "ORDINARY", + "columnType" : "int4", + "javaType" : "java.lang.Integer" + }, { + "matchType" : "ORDINARY", + "columnType" : "int8", + "javaType" : "java.lang.Long" + }, { + "matchType" : "REGEX", + "columnType" : "bigint(\\(\\d+\\))?", + "javaType" : "java.lang.Long" + }, { + "matchType" : "ORDINARY", + "columnType" : "date", + "javaType" : "java.util.Date" + }, { + "matchType" : "ORDINARY", + "columnType" : "datetime", + "javaType" : "java.util.Date" + }, { + "matchType" : "ORDINARY", + "columnType" : "timestamp", + "javaType" : "java.util.Date" + }, { + "matchType" : "ORDINARY", + "columnType" : "time", + "javaType" : "java.time.LocalTime" + }, { + "matchType" : "ORDINARY", + "columnType" : "boolean", + "javaType" : "java.lang.Boolean" + } ] + } + }, + "template" : { + "pancm" : { + "name" : "pancm", + "elementList" : [ { + "name" : "controller.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Controller\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/controller\"))\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;\n\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport $!{tableInfo.savePackageName}.service.I$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\n\nimport com.pancm.vo.ApiResult;\nimport io.swagger.annotations.Api;\nimport io.swagger.annotations.ApiOperation;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.RequestBody;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\n\nimport javax.servlet.http.HttpServletRequest;\n\n\n\n/**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表控制层\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Api(tags = \"$!{tableInfo.comment}($!{tableInfo.name})\")\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($tableInfo.name)\")\npublic class $!{tableName} {\n /**\n * 服务对象\n */\n @Autowired\n private I$!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;\n\n\n /**\n * 新增一条数据\n *\n * @param $!tool.firstLowerCase($tableInfo.name)VO 实体类\n * @return Response对象\n */\n @ApiOperation(value = \"$!{tableInfo.comment}新增\",notes = \"$!{tableInfo.comment}新增\")\n @RequestMapping(value = \"save\", method = RequestMethod.POST)\n public ApiResult insert(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO, HttpServletRequest httpRequest) {\n int result = $!{tool.firstLowerCase($tableInfo.name)}Service.insert($!tool.firstLowerCase($tableInfo.name)VO);\n if (result > 0) {\n return ApiResult.success();\n }\n return ApiResult.error(\"新增失败\");\n }\n\n /**\n * 修改一条数据\n *\n * @param $!tool.firstLowerCase($tableInfo.name)VO 实体类\n * @return Response对象\n */\n @ApiOperation(value = \"$!{tableInfo.comment}修改\",notes = \"$!{tableInfo.comment}修改\")\n @RequestMapping(value = \"edit\", method = RequestMethod.POST)\n public ApiResult update(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO, HttpServletRequest httpRequest) {\n $!{tool.firstLowerCase($tableInfo.name)}Service.update($!tool.firstLowerCase($tableInfo.name)VO); \n return ApiResult.success();\n }\n\n /**\n * 删除一条数据\n *\n * @param $!tool.firstLowerCase($tableInfo.name)VO 参数对象\n * @return Response对象\n */\n @ApiOperation(value = \"$!{tableInfo.comment}删除\",notes = \"$!{tableInfo.comment}删除\") \n @RequestMapping(value = \"del\", method = RequestMethod.POST)\n public ApiResult delete(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO, HttpServletRequest httpRequest) {\n $!{tool.firstLowerCase($tableInfo.name)}Service.deleteById($!{tool.firstLowerCase($tableInfo.name)}VO.getId());\n return ApiResult.success(); \n }\n\n \n\n /**\n * 分页查询\n *\n */\n @ApiOperation(value = \"$!{tableInfo.comment}查询\",notes = \"$!{tableInfo.comment}查询\")\n @RequestMapping(value = \"list\", method = RequestMethod.POST)\n public ApiResult list(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO) {\n return $!{tool.firstLowerCase($tableInfo.name)}Service.list($!tool.firstLowerCase($tableInfo.name)VO);\n }\n\n /**\n * 详情查询\n *\n */ \n @ApiOperation(value = \"$!{tableInfo.comment}详情\",notes = \"$!{tableInfo.comment}详情\") \n @RequestMapping(value = \"view\", method = RequestMethod.GET)\n public ApiResult view( @RequestParam(\"id\") Long id) {\n return ApiResult.success($!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id)); \n }\n}" + }, { + "name" : "service.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append(\"I\",$tableInfo.name, \"Service\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;\n$!autoImport\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport com.pancm.vo.ApiResult;\nimport java.util.List;\n\n\n /**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表服务接口\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\npublic interface $!{tableName} {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name}VO queryById($!pk.shortType $!pk.name);\n\n \n /**\n * 通过实体作为筛选条件查询\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 对象列表\n */\n ApiResult list($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n \n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n int insert($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n int update($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n boolean deleteById($!pk.shortType $!pk.name);\n\n}" + }, { + "name" : "serviceImpl.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"ServiceImpl\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service/impl\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;\n$!autoImport\n\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport $!{tableInfo.savePackageName}.model.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.service.I$!{tableInfo.name}Service;\n\nimport com.github.pagehelper.Page;\nimport com.github.pagehelper.PageHelper;\nimport com.pancm.vo.ApiResult;\nimport com.pancm.vo.PageResult;\nimport org.springframework.stereotype.Service;\nimport org.springframework.beans.BeanUtils;\nimport javax.annotation.Resource;\nimport java.util.List;\n\n\n\n/**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表服务实现类\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Service(\"$!tool.firstLowerCase($!{tableInfo.name})Service\")\npublic class $!{tableName} implements I$!{tableInfo.name}Service {\n @Resource\n private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name}VO queryById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);\n }\n\n \n /**\n * 根据条件查询\n *\n * @return 实例对象的集合\n */\n @Override\n public ApiResult list($!{tableInfo.name}VO $!{tool.firstLowerCase($!{tableInfo.name})}) {\n int pageNum = $!{tool.firstLowerCase($!{tableInfo.name})}.getPageNum();\n int pageSize = $!{tool.firstLowerCase($!{tableInfo.name})}.getPageSize();\n Page page = PageHelper.startPage(pageNum, pageSize);\n List<$!{tableInfo.name}VO> result = $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAll($!{tool.firstLowerCase($!{tableInfo.name})});\n return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum));\n \n }\n \n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n @Override\n public int insert($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO) {\n $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}) = new $!{tableInfo.name}();\n BeanUtils.copyProperties($!tool.firstLowerCase($!{tableInfo.name})VO,$!tool.firstLowerCase($!{tableInfo.name}));\n return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name}));\n }\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n @Override\n public int update($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO) {\n $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}) = new $!{tableInfo.name}();\n BeanUtils.copyProperties($!tool.firstLowerCase($!{tableInfo.name})VO,$!tool.firstLowerCase($!{tableInfo.name}));\n return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.update($!tool.firstLowerCase($!{tableInfo.name}));\n }\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n @Override\n public boolean deleteById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name) > 0;\n }\n}" + }, { + "name" : "dao.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Dao\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/dao\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;\n\nimport $!{tableInfo.savePackageName}.model.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport org.apache.ibatis.annotations.Param;\nimport org.apache.ibatis.annotations.Mapper;\nimport java.util.List;\n\n /**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Mapper\npublic interface $!{tableName} {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name}VO queryById($!pk.shortType $!pk.name);\n\n \n /**\n * 通过实体查询一条数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 对象列表\n */\n $!{tableInfo.name}VO findOne($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 通过实体作为筛选条件查询\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 对象列表\n */\n List<$!{tableInfo.name}VO> queryAll($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 批量新增数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n */\n int insertBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 批量新增或按主键更新数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n */\n int insertOrUpdateBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 影响行数\n */\n int deleteById($!pk.shortType $!pk.name);\n\n}\n" + }, { + "name" : "vo.java", + "code" : "##引入宏定义\n$!define\n#set($tableName = $tool.append($tableInfo.name, \"VO\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/vo\"))\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}vo;\n##使用全局变量实现默认包导入\n$!autoImport\nimport java.io.Serializable;\nimport com.alibaba.fastjson.JSONObject;\nimport io.swagger.annotations.ApiModel;\nimport io.swagger.annotations.ApiModelProperty;\nimport lombok.Data;\nimport java.sql.Date;\nimport com.pancm.vo.BasePage;\n\n/**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})请求响应对象\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@ApiModel(value = \"$!{tableInfo.name}\", description = \"$!{tableInfo.comment}\")\n@Data\npublic class $!{tableInfo.name}VO extends BasePage implements Serializable {\n private static final long serialVersionUID = $!tool.serial();\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})\n /**\n * ${column.comment}\n */\n #end\n @ApiModelProperty(value = \"${column.comment}\")\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n #end\n\n\n\n @Override\n public String toString(){\n return JSONObject.toJSONString(this);\n }\n\n}" + }, { + "name" : "model.java", + "code" : "\n##导入宏定义\n$!{define.vm}\n\n##保存文件(宏定义)\n#save(\"/model\", \".java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"model\")\n\n\nimport com.alibaba.fastjson.JSONObject;\nimport lombok.Data;\n\nimport javax.persistence.Column;\nimport javax.persistence.Table;\nimport java.io.Serializable;\nimport java.sql.Date;\n\n /**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})实体类\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Data\n@Table(name = \"$tableInfo.obj.name\")\npublic class $!{tableInfo.name} implements Serializable {\n private static final long serialVersionUID = $!tool.serial();\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})\n /**\n * ${column.comment}\n */\n #end\n @Column(name = \"$column.obj.name\")\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n\n @Override\n public String toString(){\n return JSONObject.toJSONString(this);\n }\n\n}" + }, { + "name" : "mapper.xml.vm", + "code" : "##引入mybatis支持\n$!{mybatisSupport.vm}\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \"Mapper.xml\"))\n$!callback.setSavePath($tool.append($modulePath, \"/src/main/resources/pancm/mapper\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n\n\n\n\n \n#foreach($column in $tableInfo.fullColumn)\n \n#end\n \n\n \n \n \n \n \n\n \n \n\n \n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($foreach.hasNext), #end#end)\n values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($foreach.hasNext), #end#end)\n \n\n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($foreach.hasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($foreach.hasNext), #end#end)\n \n \n\n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($foreach.hasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($foreach.hasNext), #end#end)\n \n on duplicate key update\n #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($foreach.hasNext), #end#end\n \n\n \n \n update $!{tableInfo.obj.name}\n \n#foreach($column in $tableInfo.otherColumn)\n \n $!column.obj.name = #{$!column.name},\n \n#end\n \n where $!pk.obj.name = #{$!pk.name}\n \n\n \n \n delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}\n \n\n\n" + } ] + }, + "pancm_mybatis_plus" : { + "name" : "pancm_mybatis_plus", + "elementList" : [ { + "name" : "controller.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Controller\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/controller\"))\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;\n\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport $!{tableInfo.savePackageName}.service.I$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\n\nimport com.pancm.vo.ApiResult;\nimport io.swagger.annotations.Api;\nimport io.swagger.annotations.ApiOperation;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.RequestBody;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\n\nimport javax.servlet.http.HttpServletRequest;\n\n\n\n/**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表控制层\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Api(tags = \"$!{tableInfo.comment}($!{tableInfo.name})\")\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($tableInfo.name)\")\npublic class $!{tableName} {\n /**\n * 服务对象\n */\n @Autowired\n private I$!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;\n\n\n /**\n * 新增一条数据\n *\n * @param $!tool.firstLowerCase($tableInfo.name)VO 实体类\n * @return Response对象\n */\n @ApiOperation(value = \"$!{tableInfo.comment}新增\",notes = \"$!{tableInfo.comment}新增\")\n @RequestMapping(value = \"save\", method = RequestMethod.POST)\n public ApiResult insert(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO, HttpServletRequest httpRequest) {\n int result = $!{tool.firstLowerCase($tableInfo.name)}Service.insert($!tool.firstLowerCase($tableInfo.name)VO);\n if (result > 0) {\n return ApiResult.success();\n }\n return ApiResult.error(\"新增失败\");\n }\n\n /**\n * 修改一条数据\n *\n * @param $!tool.firstLowerCase($tableInfo.name)VO 实体类\n * @return Response对象\n */\n @ApiOperation(value = \"$!{tableInfo.comment}修改\",notes = \"$!{tableInfo.comment}修改\")\n @RequestMapping(value = \"edit\", method = RequestMethod.POST)\n public ApiResult update(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO, HttpServletRequest httpRequest) {\n $!{tool.firstLowerCase($tableInfo.name)}Service.update($!tool.firstLowerCase($tableInfo.name)VO); \n return ApiResult.success();\n }\n\n /**\n * 删除一条数据\n *\n * @param $!tool.firstLowerCase($tableInfo.name)VO 参数对象\n * @return Response对象\n */\n @ApiOperation(value = \"$!{tableInfo.comment}删除\",notes = \"$!{tableInfo.comment}删除\") \n @RequestMapping(value = \"del\", method = RequestMethod.POST)\n public ApiResult delete(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO, HttpServletRequest httpRequest) {\n $!{tool.firstLowerCase($tableInfo.name)}Service.deleteById($!{tool.firstLowerCase($tableInfo.name)}VO.getId());\n return ApiResult.success(); \n }\n\n \n\n /**\n * 分页查询\n *\n */\n @ApiOperation(value = \"$!{tableInfo.comment}查询\",notes = \"$!{tableInfo.comment}查询\")\n @RequestMapping(value = \"list\", method = RequestMethod.POST)\n public ApiResult list(@RequestBody $!{tableInfo.name}VO $!tool.firstLowerCase($tableInfo.name)VO) {\n return $!{tool.firstLowerCase($tableInfo.name)}Service.list($!tool.firstLowerCase($tableInfo.name)VO);\n }\n\n /**\n * 详情查询\n *\n */ \n @ApiOperation(value = \"$!{tableInfo.comment}详情\",notes = \"$!{tableInfo.comment}详情\") \n @RequestMapping(value = \"view\", method = RequestMethod.GET)\n public ApiResult view( @RequestParam(\"id\") Long id) {\n return ApiResult.success($!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id)); \n }\n}" + }, { + "name" : "service.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append(\"I\",$tableInfo.name, \"Service\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;\n$!autoImport\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport $!{tableInfo.savePackageName}.model.$!{tableInfo.name};\nimport com.pancm.vo.ApiResult;\nimport java.util.List;\nimport com.baomidou.mybatisplus.extension.service.IService;\n\n\n /**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表服务接口\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\npublic interface $!{tableName} extends IService<$!tableInfo.name>{\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name}VO queryById($!pk.shortType $!pk.name);\n\n \n /**\n * 通过实体作为筛选条件查询\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 对象列表\n */\n ApiResult list($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n \n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n int insert($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n int update($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n boolean deleteById($!pk.shortType $!pk.name);\n\n}" + }, { + "name" : "serviceImpl.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"ServiceImpl\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service/impl\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;\n$!autoImport\n\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport $!{tableInfo.savePackageName}.model.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.service.I$!{tableInfo.name}Service;\n\nimport com.github.pagehelper.Page;\nimport com.github.pagehelper.PageHelper;\nimport com.pancm.vo.ApiResult;\nimport com.pancm.vo.PageResult;\nimport org.springframework.stereotype.Service;\nimport org.springframework.beans.BeanUtils;\nimport javax.annotation.Resource;\nimport java.util.List;\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\n\n\n\n/**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表服务实现类\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Service(\"$!tool.firstLowerCase($!{tableInfo.name})Service\")\npublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements I$!{tableInfo.name}Service {\n @Resource\n private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name}VO queryById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);\n }\n\n \n /**\n * 根据条件查询\n *\n * @return 实例对象的集合\n */\n @Override\n public ApiResult list($!{tableInfo.name}VO $!{tool.firstLowerCase($!{tableInfo.name})}) {\n int pageNum = $!{tool.firstLowerCase($!{tableInfo.name})}.getPageNum();\n int pageSize = $!{tool.firstLowerCase($!{tableInfo.name})}.getPageSize();\n Page page = PageHelper.startPage(pageNum, pageSize);\n List<$!{tableInfo.name}VO> result = $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAll($!{tool.firstLowerCase($!{tableInfo.name})});\n return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum));\n \n }\n \n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n @Override\n public int insert($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO) {\n $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}) = new $!{tableInfo.name}();\n BeanUtils.copyProperties($!tool.firstLowerCase($!{tableInfo.name})VO,$!tool.firstLowerCase($!{tableInfo.name}));\n return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name}));\n }\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 实例对象\n */\n @Override\n public int update($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO) {\n $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}) = new $!{tableInfo.name}();\n BeanUtils.copyProperties($!tool.firstLowerCase($!{tableInfo.name})VO,$!tool.firstLowerCase($!{tableInfo.name}));\n return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.update($!tool.firstLowerCase($!{tableInfo.name}));\n }\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n @Override\n public boolean deleteById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name) > 0;\n }\n}" + }, { + "name" : "dao.java", + "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Dao\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/dao\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;\n\nimport $!{tableInfo.savePackageName}.model.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.vo.$!{tableInfo.name}VO;\nimport org.apache.ibatis.annotations.Param;\nimport org.apache.ibatis.annotations.Mapper;\nimport java.util.List;\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\n\n /**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Mapper\npublic interface $!{tableName} extends BaseMapper<$!tableInfo.name> {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name}VO queryById($!pk.shortType $!pk.name);\n\n \n /**\n * 通过实体查询一条数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 对象列表\n */\n $!{tableInfo.name}VO findOne($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 通过实体作为筛选条件查询\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name})VO 实例对象\n * @return 对象列表\n */\n List<$!{tableInfo.name}VO> queryAll($!{tableInfo.name}VO $!tool.firstLowerCase($!{tableInfo.name})VO);\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 批量新增数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n */\n int insertBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 批量新增或按主键更新数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n */\n int insertOrUpdateBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 影响行数\n */\n int deleteById($!pk.shortType $!pk.name);\n\n}\n" + }, { + "name" : "vo.java", + "code" : "##引入宏定义\n$!define\n#set($tableName = $tool.append($tableInfo.name, \"VO\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/vo\"))\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}vo;\n##使用全局变量实现默认包导入\n$!autoImport\nimport java.io.Serializable;\nimport com.alibaba.fastjson.JSONObject;\nimport io.swagger.annotations.ApiModel;\nimport io.swagger.annotations.ApiModelProperty;\nimport lombok.Data;\nimport java.sql.Date;\nimport com.pancm.vo.BasePage;\n\n/**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})请求响应对象\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@ApiModel(value = \"$!{tableInfo.name}\", description = \"$!{tableInfo.comment}\")\n@Data\npublic class $!{tableInfo.name}VO extends BasePage implements Serializable {\n private static final long serialVersionUID = $!tool.serial();\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})\n /**\n * ${column.comment}\n */\n #end\n @ApiModelProperty(value = \"${column.comment}\")\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n #end\n\n\n\n @Override\n public String toString(){\n return JSONObject.toJSONString(this);\n }\n\n}" + }, { + "name" : "model.java", + "code" : "\n##导入宏定义\n$!{define.vm}\n\n##保存文件(宏定义)\n#save(\"/model\", \".java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"model\")\n\n\nimport com.alibaba.fastjson.JSONObject;\nimport lombok.Data;\n\nimport javax.persistence.Column;\nimport javax.persistence.Table;\nimport java.io.Serializable;\nimport java.sql.Date;\n\n /**\n* @Title: $!{tableInfo.comment}($!{tableInfo.name})实体类\n* @Description: \n* @Version:1.0.0 \n* @Since:jdk1.8 \n* @author $author\n* @date $!time.currTime()\n*/\n@Data\n@Table(name = \"$tableInfo.obj.name\")\npublic class $!{tableInfo.name} implements Serializable {\n private static final long serialVersionUID = $!tool.serial();\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})\n /**\n * ${column.comment}\n */\n #end\n @Column(name = \"$column.obj.name\")\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n\n @Override\n public String toString(){\n return JSONObject.toJSONString(this);\n }\n\n}" + }, { + "name" : "mapper.xml.vm", + "code" : "##引入mybatis支持\n$!{mybatisSupport.vm}\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \"Mapper.xml\"))\n$!callback.setSavePath($tool.append($modulePath, \"/src/main/resources/pancm/mapper\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n\n\n\n\n \n#foreach($column in $tableInfo.fullColumn)\n \n#end\n \n\n \n \n \n \n \n\n \n \n\n \n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($foreach.hasNext), #end#end)\n values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($foreach.hasNext), #end#end)\n \n\n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($foreach.hasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($foreach.hasNext), #end#end)\n \n \n\n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($foreach.hasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($foreach.hasNext), #end#end)\n \n on duplicate key update\n #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($foreach.hasNext), #end#end\n \n\n \n \n update $!{tableInfo.obj.name}\n \n#foreach($column in $tableInfo.otherColumn)\n \n $!column.obj.name = #{$!column.name},\n \n#end\n \n where $!pk.obj.name = #{$!pk.name}\n \n\n \n \n delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}\n \n\n\n" + } ] + } + }, + "columnConfig" : { + "Default" : { + "name" : "Default", + "elementList" : [ { + "title" : "disable", + "type" : "BOOLEAN", + "selectValue" : "" + }, { + "title" : "support", + "type" : "SELECT", + "selectValue" : "add,edit,query,del,ui" + } ] + } + }, + "globalConfig" : { + "Default" : { + "name" : "Default", + "elementList" : [ { + "name" : "autoImport.vm", + "value" : "##自动导入包(仅导入实体属性需要的包,通常用于实体类)\n#foreach($import in $importList)\nimport $!import;\n#end" + }, { + "name" : "define.vm", + "value" : "##(Velocity宏定义)\n\n##定义设置表名后缀的宏定义,调用方式:#setTableSuffix(\"Test\")\n#macro(setTableSuffix $suffix)\n #set($tableName = $!tool.append($tableInfo.name, $suffix))\n#end\n\n##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix(\"Test\")\n#macro(setPackageSuffix $suffix)\n#if($suffix!=\"\")package #end#if($tableInfo.savePackageName!=\"\")$!{tableInfo.savePackageName}.#{end}$!suffix;\n#end\n\n##定义直接保存路径与文件名简化的宏定义,调用方式:#save(\"/entity\", \".java\")\n#macro(save $path $fileName)\n $!callback.setSavePath($tool.append($tableInfo.savePath, $path))\n $!callback.setFileName($tool.append($tableInfo.name, $fileName))\n#end\n\n##定义表注释的宏定义,调用方式:#tableComment(\"注释信息\")\n#macro(tableComment $desc)\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})$desc\n *\n * @author $!author\n * @since $!time.currTime()\n */\n#end\n\n##定义GET,SET方法的宏定义,调用方式:#getSetMethod($column)\n#macro(getSetMethod $column)\n\n public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.name)}() {\n return $!{column.name};\n }\n\n public void set$!{tool.firstUpperCase($column.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.name}) {\n this.$!{column.name} = $!{column.name};\n }\n#end" + }, { + "name" : "init.vm", + "value" : "##初始化区域\n\n##去掉表的t_前缀\n$!tableInfo.setName($tool.getClassName($tableInfo.obj.name.replaceFirst(\"book_\",\"\")))\n\n##参考阿里巴巴开发手册,POJO 类中布尔类型的变量,都不要加 is 前缀,否则部分框架解析会引起序列化错误\n#foreach($column in $tableInfo.fullColumn)\n#if($column.name.startsWith(\"is\") && $column.type.equals(\"java.lang.Boolean\"))\n $!column.setName($tool.firstLowerCase($column.name.substring(2)))\n#end\n#end\n\n##实现动态排除列\n#set($temp = $tool.newHashSet(\"testCreateTime\", \"otherColumn\"))\n#foreach($item in $temp)\n #set($newList = $tool.newArrayList())\n #foreach($column in $tableInfo.fullColumn)\n #if($column.name!=$item)\n ##带有反回值的方法调用时使用$tool.call来消除返回值\n $tool.call($newList.add($column))\n #end\n #end\n ##重新保存\n $tableInfo.setFullColumn($newList)\n#end\n\n##对importList进行篡改\n#set($temp = $tool.newHashSet())\n#foreach($column in $tableInfo.fullColumn)\n #if(!$column.type.startsWith(\"java.lang.\"))\n ##带有反回值的方法调用时使用$tool.call来消除返回值\n $tool.call($temp.add($column.type))\n #end\n#end\n##覆盖\n#set($importList = $temp)" + }, { + "name" : "mybatisSupport.vm", + "value" : "##针对Mybatis 进行支持,主要用于生成xml文件\n#foreach($column in $tableInfo.fullColumn)\n ##储存列类型\n $tool.call($column.ext.put(\"sqlType\", $tool.getField($column.obj.dataType, \"typeName\")))\n #if($tool.newHashSet(\"java.lang.String\").contains($column.type))\n #set($jdbcType=\"VARCHAR\")\n #elseif($tool.newHashSet(\"java.lang.Boolean\", \"boolean\").contains($column.type))\n #set($jdbcType=\"BOOLEAN\")\n #elseif($tool.newHashSet(\"java.lang.Byte\", \"byte\").contains($column.type))\n #set($jdbcType=\"BYTE\")\n #elseif($tool.newHashSet(\"java.lang.Integer\", \"int\", \"java.lang.Short\", \"short\").contains($column.type))\n #set($jdbcType=\"INTEGER\")\n #elseif($tool.newHashSet(\"java.lang.Long\", \"long\").contains($column.type))\n #set($jdbcType=\"INTEGER\")\n #elseif($tool.newHashSet(\"java.lang.Float\", \"float\", \"java.lang.Double\", \"double\").contains($column.type))\n #set($jdbcType=\"NUMERIC\")\n #elseif($tool.newHashSet(\"java.util.Date\", \"java.sql.Timestamp\", \"java.time.Instant\", \"java.time.LocalDateTime\", \"java.time.OffsetDateTime\", \"\tjava.time.ZonedDateTime\").contains($column.type))\n #set($jdbcType=\"TIMESTAMP\")\n #elseif($tool.newHashSet(\"java.sql.Date\", \"java.time.LocalDate\").contains($column.type))\n #set($jdbcType=\"TIMESTAMP\")\n #else\n ##其他类型\n #set($jdbcType=\"VARCHAR\")\n #end\n $tool.call($column.ext.put(\"jdbcType\", $jdbcType))\n#end\n\n##定义宏,查询所有列\n#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($foreach.hasNext), #end#end#end\n" + } ] + } + } +} \ No newline at end of file diff --git a/springboot-log/git-info.bat b/springboot-log/git-info.bat new file mode 100644 index 0000000..abc88de --- /dev/null +++ b/springboot-log/git-info.bat @@ -0,0 +1,13 @@ +@echo off +set time=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%:%time:~6,2% +set app=springboot-demo +for /F %%i in ('git rev-parse --short HEAD') do ( set commit_id=%%i) +for /F %%i in ('git rev-parse --abbrev-ref HEAD') do ( set branch_id=%%i) +echo build_app = %app% > ./src/main/resources/build.properties +echo build_time = %time% >> ./src/main/resources/build.properties +echo git_commit = %commit_id% >> ./src/main/resources/build.properties +echo git_branch = %branch_id% >> ./src/main/resources/build.properties +echo start %app% at %date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%:%time:~6,2% +::echo "build_version = '${version}'" > ./src/main/resources/build.properties +::echo "upload %app%" +::echo "done %app% %time% at $(date "+%Y-%m-%d %H:%M:%S")" diff --git a/springboot-log/pom.xml b/springboot-log/pom.xml new file mode 100644 index 0000000..be8f940 --- /dev/null +++ b/springboot-log/pom.xml @@ -0,0 +1,237 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.13.RELEASE + + + com.pancm + springboot-log + 0.0.1-SNAPSHOT + springboot-log + Demo project for Spring Boot + + + 1.8 + 1.7.25 + 1.2.3 + 3.5.0 + 2.6.2 + 2.9.2 + 1.5.21 + 1.9.6 + 1.2.62 + 5.1.41 + 1.1.12 + 4.0.3 + 1.3.1 + 1.1.4 + 2.9.2 + 1.5.21 + 1.9.6 + + + + + + local + + local + + + + true + + + + + dev + + dev + + + + + prod + + prod + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.apache.tomcat + tomcat-jdbc + + + org.springframework.boot + spring-boot-starter-logging + + + + + mysql + mysql-connector-java + ${mysql.connector.version} + + + com.alibaba + druid + ${alibaba.druid.version} + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${mybatis.spring.boot.version} + + + tk.mybatis + mapper-spring-boot-starter + ${tk.mybatis.boot.version} + + + com.baomidou + mybatis-plus-boot-starter + 3.0.5 + + + + org.mybatis.generator + mybatis-generator-core + 1.3.5 + + + com.github.pagehelper + pagehelper + ${pagehelper.version} + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + ch.qos.logback + logback-core + ${logback.version} + + + + org.springframework.boot + spring-boot-starter-websocket + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + + + com.alibaba + fastjson + ${alibaba.fastjson} + + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + io.swagger + swagger-models + + + + + + io.swagger + swagger-models + ${swagger.model.version} + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + + com.github.xiaoymin + swagger-bootstrap-ui + ${swagger.bootstrap.ui.version} + + + + + com.idea-aedi + logback-defender + 1.0.0 + + + + + + + + springboot-log + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/springboot-log/src/main/java/com/pancm/Application.java b/springboot-log/src/main/java/com/pancm/Application.java new file mode 100644 index 0000000..413880d --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/Application.java @@ -0,0 +1,40 @@ +package com.pancm; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.Environment; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** +* @Title: Application +* @Description: main +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @Date 2021/10/15 +**/ +@ServletComponentScan +@SpringBootApplication +@Slf4j +public class Application { + + public static void main(String[] args) throws UnknownHostException { + ConfigurableApplicationContext application = SpringApplication.run(Application.class, args); + Environment env = application.getEnvironment(); + String ip = InetAddress.getLocalHost().getHostAddress(); + String port = env.getProperty("server.port"); + String path = env.getProperty("server.servlet.context-path"); + log.info("\n----------------------------------------------------------\n\t" + + "Application springboot-demo is running! Access URLs:\n\t" + + "Local: \t\thttp://localhost:" + port + path + "/\n\t" + + "External: \thttp://" + ip + ":" + port + path + "/\n\t" + + "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" + + "----------------------------------------------------------"); + } + +} diff --git a/springboot-log/src/main/java/com/pancm/config/CorsFilter.java b/springboot-log/src/main/java/com/pancm/config/CorsFilter.java new file mode 100644 index 0000000..05e8191 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/config/CorsFilter.java @@ -0,0 +1,49 @@ +package com.pancm.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.util.StringUtils; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +@Configuration +public class CorsFilter implements Filter { + + @Override + public void init(FilterConfig filterConfig) { + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; + String origin = ((HttpServletRequest) servletRequest).getHeader("Origin"); + if (StringUtils.isEmpty(origin)) { + origin = "*"; + } + String rh = ((HttpServletRequest) servletRequest).getHeader("Access-Control-Request-Headers"); + if (StringUtils.isEmpty(origin)) { + rh = "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control," + + "Content-Type,Authorization,SessionToken,Content-Disposition"; + } + httpServletResponse.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + httpServletResponse.setHeader("Access-Control-Allow-Origin", origin); + httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true"); + httpServletResponse.setHeader("Access-Control-Allow-Headers", rh); + filterChain.doFilter(servletRequest, servletResponse); + } + + @Override + public void destroy() { + + } +} diff --git a/springboot-log/src/main/java/com/pancm/config/DemoDefenderStrategy.java b/springboot-log/src/main/java/com/pancm/config/DemoDefenderStrategy.java new file mode 100644 index 0000000..f8dc36b --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/config/DemoDefenderStrategy.java @@ -0,0 +1,24 @@ +package com.pancm.config; + +@Component("demoDefenderStrategy") +public class DemoDefenderStrategy implements DefenderStrategy{ + @Override + public String category() { + return "name"; + } + + @Override + public int retainPrefixCount() { + return 1; + } + + @Override + public int retainSuffixCount() { + return 1; + } + + @Override + public char replaceChar() { + return '$'; + } +} \ No newline at end of file diff --git a/springboot-log/src/main/java/com/pancm/config/PancmConfiguration.java b/springboot-log/src/main/java/com/pancm/config/PancmConfiguration.java new file mode 100644 index 0000000..9b7e58f --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/config/PancmConfiguration.java @@ -0,0 +1,120 @@ +package com.pancm.config; + +import com.alibaba.druid.pool.DruidDataSource; +import com.github.pagehelper.PageHelper; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; + +import javax.sql.DataSource; +import java.util.Objects; +import java.util.Properties; + +import static com.pancm.config.PancmConfiguration.PACKAGE; + +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +@Configuration +@MapperScan(basePackages = {PACKAGE}, sqlSessionFactoryRef = "pancmSqlSessionFactory") +public class PancmConfiguration { + + static final String PACKAGE = "com.pancm.dao"; + static final String MAPPER_LOCATION = "classpath:pancm/mapper/*.xml"; + static final String CONFIG_LOCATION = "classpath:pancm/mybatis-config.xml"; + + + + @Value("${spring.datasource.pancm.driver-class-name}") + private String driverClassName; + + @Value("${spring.datasource.pancm.url}") + private String url; + + @Value("${spring.datasource.pancm.username}") + private String username; + + @Value("${spring.datasource.pancm.password}") + private String password; + + + @Bean(name = "pancmDataSource") + @ConfigurationProperties(prefix = "spring.datasource.pancm") + @Primary + public DataSource pancmDataSource() { + DruidDataSource dataSource = new DruidDataSource(); + dataSource.setDriverClassName(driverClassName); + dataSource.setUrl(url); + dataSource.setUsername(username); + dataSource.setPassword(password); + dataSource.setInitialSize(10); + dataSource.setMinIdle(10); + dataSource.setMaxActive(30); + dataSource.setMaxWait(30000); + dataSource.setRemoveAbandoned(true); + dataSource.setRemoveAbandonedTimeout(1800); + dataSource.setLogAbandoned(false); + dataSource.setTimeBetweenEvictionRunsMillis(60000); + dataSource.setMinEvictableIdleTimeMillis(300000); + dataSource.setValidationQuery("SELECT 1"); + dataSource.setTestWhileIdle(true); + dataSource.setTestOnBorrow(false); + dataSource.setTestOnReturn(false); + dataSource.setPoolPreparedStatements(true); + dataSource.setMaxPoolPreparedStatementPerConnectionSize(500); + dataSource.setKeepAlive(true); + dataSource.setDbType("mysql"); + return dataSource; + } + + @Bean(name = "pancmSqlSessionFactory") + @Primary + public SqlSessionFactory pancmSqlSessionFactory(@Qualifier("pancmDataSource") DataSource dataSource) throws Exception { + SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); + bean.setDataSource(dataSource); + + //分页插件 + PageHelper pageHelper = new PageHelper(); + Properties properties = new Properties(); + properties.setProperty("reasonable", "true"); + properties.setProperty("supportMethodsArguments", "true"); + properties.setProperty("returnPageInfo", "check"); + properties.setProperty("params", "count=countSql"); + pageHelper.setProperties(properties); + + //添加插件 + bean.setPlugins(new Interceptor[]{pageHelper}); + + bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION)); + bean.setConfigLocation(new PathMatchingResourcePatternResolver().getResource(CONFIG_LOCATION)); + Objects.requireNonNull(bean.getObject()).getConfiguration().setMapUnderscoreToCamelCase(true); + return bean.getObject(); + } + + @Bean(name = "pancmTransactionManager") + @Primary + public DataSourceTransactionManager testTransactionManager(@Qualifier("pancmDataSource") DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); + } + + @Bean(name = "pancmSqlSessionTemplate") + @Primary + public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("pancmSqlSessionFactory") SqlSessionFactory sqlSessionFactory) + throws Exception { + return new SqlSessionTemplate(sqlSessionFactory); + } +} diff --git a/springboot-log/src/main/java/com/pancm/config/PluginOne.java b/springboot-log/src/main/java/com/pancm/config/PluginOne.java new file mode 100644 index 0000000..2530c79 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/config/PluginOne.java @@ -0,0 +1,17 @@ +package com.pancm.config; + +@Component + public class PluginOne implements LogbackMessageDefender { + + public static final String HANDLE_BY_PLUGIN = "PluginOneAbc"; + + @Override + public boolean support(ILoggingEvent event) { + return event.getMDCPropertyMap().containsKey(HANDLE_BY_PLUGIN); + } + + @Override + public void desensitize(ILoggingEvent event, String message, StringBuilder buffer) { + buffer.append("[O_O] ").append(event.getFormattedMessage()).append(" [O_O]"); + } + } \ No newline at end of file diff --git a/springboot-log/src/main/java/com/pancm/config/SpringBeanFactory.java b/springboot-log/src/main/java/com/pancm/config/SpringBeanFactory.java new file mode 100644 index 0000000..9a6ed7a --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/config/SpringBeanFactory.java @@ -0,0 +1,50 @@ +package com.pancm.config; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * @Title: SpringBeanFactory + * @Description: + * @Version:1.0.0 + * @Since:jdk1.8 + * @author pancm + * @Date 2021/7/2 + **/ +@Component +public class SpringBeanFactory implements ApplicationContextAware { + + // Spring应用上下文环境 + private static ApplicationContext applicationContext; + + /** + * 实现ApplicationContextAware接口的回调方法,设置上下文环境 + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + SpringBeanFactory.applicationContext = applicationContext; + } + + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * 获取对象 这里重写了bean方法,起主要作用 + */ + public static Object getBean(String beanId) throws BeansException { + if (applicationContext == null) return null; + return applicationContext.getBean(beanId); + } + + /** + * 获取当前环境 + */ + public static String getActiveProfile() { + return applicationContext.getEnvironment().getActiveProfiles()[0]; + } + +} diff --git a/springboot-log/src/main/java/com/pancm/config/SwaggerConfig.java b/springboot-log/src/main/java/com/pancm/config/SwaggerConfig.java new file mode 100644 index 0000000..1a93d99 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/config/SwaggerConfig.java @@ -0,0 +1,64 @@ +package com.pancm.config; + +import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.RequestMethod; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +@Configuration +@EnableSwagger2 +@EnableSwaggerBootstrapUI +public class SwaggerConfig { + + @Bean + public Docket createRestApi() { + //添加head参数start + ParameterBuilder tokenPar = new ParameterBuilder(); + List pars = new ArrayList(); + tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); + pars.add(tokenPar.build()); + //添加head参数end + + + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("com.pancm.controller")) + .paths(PathSelectors.any()) + .build() + .globalOperationParameters(pars) + ; + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("pancm-swagger2") + .description("Restful-API-Doc") + .termsOfServiceUrl("https://www.cnblogs.com/xuwujing") + .contact(new Contact("虚无境的博客", "https://www.cnblogs.com/xuwujing", "xxx@qq.com")) + .version("1.0") + .build(); + } +} diff --git a/springboot-log/src/main/java/com/pancm/controller/HomeController.java b/springboot-log/src/main/java/com/pancm/controller/HomeController.java new file mode 100644 index 0000000..527f9a6 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/controller/HomeController.java @@ -0,0 +1,53 @@ +package com.pancm.controller; + +import com.alibaba.fastjson.JSONObject; +import com.pancm.util.FileHelper; +import com.pancm.util.GetProperties; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +@RestController +@RequestMapping("/home") +@Slf4j +@Api(tags = "首页相关接口") +public class HomeController { + + + @Value("${spring.profiles.active}") + String active; + + private final static String VERSION_NAME = "version.txt"; + + @ApiOperation(value = "/version", notes = "版本信息") + @RequestMapping(value = "/version", method = {RequestMethod.GET}) + public JSONObject version(HttpServletRequest request){ + Map map = GetProperties.getAppSettings(); + JSONObject result = new JSONObject(); + result.put("git_branch", map.get("git_branch")); + result.put("build_time", map.get("build_time")); + result.put("git_commit", map.get("git_commit")); + result.put("app_name", map.get("build_app")); + result.put("profile", active); + result.put("version", FileHelper.readResourcesFile(VERSION_NAME)); + return result; + } + + + + +} diff --git a/springboot-log/src/main/java/com/pancm/controller/TSysUserController.java b/springboot-log/src/main/java/com/pancm/controller/TSysUserController.java new file mode 100644 index 0000000..8483569 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/controller/TSysUserController.java @@ -0,0 +1,103 @@ +package com.pancm.controller; + +import com.pancm.vo.TSysUserVO; +import com.pancm.service.ITSysUserService; +import org.springframework.web.bind.annotation.*; + + +import com.pancm.vo.ApiResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + + + +/** +* @Title: 用户表(TSysUser)表控制层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-04-01 09:30:51 +*/ +@Api(tags = "用户表(TSysUser)") +@RestController +@RequestMapping("tSysUser") +public class TSysUserController { + /** + * 服务对象 + */ + @Autowired + private ITSysUserService tSysUserService; + + + /** + * 新增一条数据 + * + * @param tSysUserVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户表新增",notes = "用户表新增") + @RequestMapping(value = "save", method = RequestMethod.POST) + public ApiResult insert(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest httpRequest) { + int result = tSysUserService.insert(tSysUserVO); + if (result > 0) { + return ApiResult.success(); + } + return ApiResult.error("新增失败"); + } + + /** + * 修改一条数据 + * + * @param tSysUserVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户表修改",notes = "用户表修改") + @RequestMapping(value = "edit", method = RequestMethod.POST) + public ApiResult update(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest httpRequest) { + tSysUserService.update(tSysUserVO); + return ApiResult.success(); + } + + /** + * 删除一条数据 + * + * @param tSysUserVO 参数对象 + * @return Response对象 + */ + @ApiOperation(value = "用户表删除",notes = "用户表删除") + @RequestMapping(value = "del", method = RequestMethod.POST) + public ApiResult delete(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest httpRequest) { + tSysUserService.deleteById(tSysUserVO.getId()); + return ApiResult.success(); + } + + + + /** + * 分页查询 + * + */ + @ApiOperation(value = "用户表查询",notes = "用户表查询") + @RequestMapping(value = "list", method = RequestMethod.POST) + public ApiResult list(@RequestBody TSysUserVO tSysUserVO) { + return tSysUserService.list(tSysUserVO); + } + + /** + * 详情查询 + * + */ + @ApiOperation(value = "用户表详情",notes = "用户表详情") + @RequestMapping(value = "view", method = RequestMethod.GET) + public ApiResult view( @RequestParam("id") String id) { + return ApiResult.success(tSysUserService.queryById(id)); + } +} diff --git a/springboot-log/src/main/java/com/pancm/controller/UserController.java b/springboot-log/src/main/java/com/pancm/controller/UserController.java new file mode 100644 index 0000000..94fa064 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/controller/UserController.java @@ -0,0 +1,103 @@ +package com.pancm.controller; + +import com.pancm.vo.UserVO; +import com.pancm.service.IUserService; +import org.springframework.web.bind.annotation.*; + + +import com.pancm.vo.ApiResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + + + +/** +* @Title: 用户表(User)表控制层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-01-15 15:27:02 +*/ +@Api(tags = "用户表(User)") +@RestController +@RequestMapping("user") +public class UserController { + /** + * 服务对象 + */ + @Autowired + private IUserService userService; + + + /** + * 新增一条数据 + * + * @param userVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户表新增",notes = "用户表新增") + @RequestMapping(value = "save", method = RequestMethod.POST) + public ApiResult insert(@RequestBody UserVO userVO, HttpServletRequest httpRequest) { + int result = userService.insert(userVO); + if (result > 0) { + return ApiResult.success(); + } + return ApiResult.error("新增失败"); + } + + /** + * 修改一条数据 + * + * @param userVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户表修改",notes = "用户表修改") + @RequestMapping(value = "edit", method = RequestMethod.POST) + public ApiResult update(@RequestBody UserVO userVO, HttpServletRequest httpRequest) { + userService.update(userVO); + return ApiResult.success(); + } + + /** + * 删除一条数据 + * + * @param userVO 参数对象 + * @return Response对象 + */ + @ApiOperation(value = "用户表删除",notes = "用户表删除") + @RequestMapping(value = "del", method = RequestMethod.POST) + public ApiResult delete(@RequestBody UserVO userVO, HttpServletRequest httpRequest) { + userService.deleteById(userVO.getId()); + return ApiResult.success(); + } + + + + /** + * 分页查询 + * + */ + @ApiOperation(value = "用户表查询",notes = "用户表查询") + @RequestMapping(value = "list", method = RequestMethod.POST) + public ApiResult list(@RequestBody UserVO userVO) { + return userService.list(userVO); + } + + /** + * 详情查询 + * + */ + @ApiOperation(value = "用户表详情",notes = "用户表详情") + @RequestMapping(value = "view", method = RequestMethod.GET) + public ApiResult view( @RequestParam("id") Long id) { + return ApiResult.success(userService.queryById(id)); + } +} diff --git a/springboot-log/src/main/java/com/pancm/dao/TSysUserDao.java b/springboot-log/src/main/java/com/pancm/dao/TSysUserDao.java new file mode 100644 index 0000000..c067c6f --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/dao/TSysUserDao.java @@ -0,0 +1,87 @@ +package com.pancm.dao; + +import com.pancm.model.TSysUser; +import com.pancm.vo.TSysUserVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + + /** +* @Title: 用户表(TSysUser)表数据库访问层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-04-01 09:30:54 +*/ +@Mapper +public interface TSysUserDao extends BaseMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TSysUserVO queryById(String id); + + + /** + * 通过实体查询一条数据 + * + * @param tSysUserVO 实例对象 + * @return 对象列表 + */ + TSysUserVO findOne(TSysUserVO tSysUserVO); + + /** + * 通过实体作为筛选条件查询 + * + * @param tSysUserVO 实例对象 + * @return 对象列表 + */ + List queryAll(TSysUserVO tSysUserVO); + + /** + * 新增数据 + * + * @param tSysUser 实例对象 + * @return 影响行数 + */ + int insert(TSysUser tSysUser); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tSysUser 实例对象 + * @return 影响行数 + */ + int update(TSysUser tSysUser); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(String id); + +} + diff --git a/springboot-log/src/main/java/com/pancm/dao/UserDao.java b/springboot-log/src/main/java/com/pancm/dao/UserDao.java new file mode 100644 index 0000000..4992e68 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/dao/UserDao.java @@ -0,0 +1,88 @@ +package com.pancm.dao; + +import com.pancm.model.User; +import com.pancm.vo.UserVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; +import tk.mybatis.mapper.common.BaseMapper; + +import java.util.List; + + /** +* @Title: 用户表(User)表数据库访问层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-01-15 15:27:04 +*/ +@Mapper +public interface UserDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + UserVO queryById(Long id); + + + /** + * 通过实体查询一条数据 + * + * @param userVO 实例对象 + * @return 对象列表 + */ + UserVO findOne(UserVO userVO); + + /** + * 通过实体作为筛选条件查询 + * + * @param userVO 实例对象 + * @return 对象列表 + */ + List queryAll(UserVO userVO); + + /** + * 新增数据 + * + * @param user 实例对象 + * @return 影响行数 + */ + int insert(User user); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param user 实例对象 + * @return 影响行数 + */ + int update(User user); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + +} + diff --git a/springboot-log/src/main/java/com/pancm/enums/SimpleDefenderStrategy.java b/springboot-log/src/main/java/com/pancm/enums/SimpleDefenderStrategy.java new file mode 100644 index 0000000..a92ad22 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/enums/SimpleDefenderStrategy.java @@ -0,0 +1,24 @@ +package com.pancm.enums; + +public enum SimpleDefenderStrategy implements DefenderStrategy { + + /** 姓名类脱敏策略 */ + NAME("name", 1, 1, '*'), + + /** 账号类脱敏策略 */ + ACCOUNT_NO("accountNo", 2, 2, '*'), + + /** 邮箱类脱敏策略 */ + EMAIL("email", 2, 7, '*'), + + /** 身份证号类脱敏策略 */ + ID_CARD("idCard", 6, 4, '*'), + + /** 手机号码类脱敏策略 */ + PHONE_NUMBER("phoneNumber", 3, 4, '*'), + + /** 住址类脱敏策略 */ + ADDRESS("address", 3, 4, '*'); + + // 省略... +} \ No newline at end of file diff --git a/springboot-log/src/main/java/com/pancm/model/TSysUser.java b/springboot-log/src/main/java/com/pancm/model/TSysUser.java new file mode 100644 index 0000000..5ded285 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/model/TSysUser.java @@ -0,0 +1,61 @@ +package com.pancm.model; + + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Table; +import java.io.Serializable; +import java.sql.Date; + + /** +* @Title: 用户表(TSysUser)实体类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-04-01 09:30:55 +*/ +@Data +@Table(name = "t_sys_user") +public class TSysUser implements Serializable { + private static final long serialVersionUID = -56958960669065369L; + /** + * 主键 + */ + @Column(name = "id") + private String id; + /** + * 用户账号 + */ + @Column(name = "username") + private String username; + /** + * 用户密码 + */ + @Column(name = "password") + private String password; + /** + * 昵称 + */ + @Column(name = "nickname") + private String nickname; + /** + * 部门id + */ + @Column(name = "dep_id") + private Integer depId; + /** + * 岗位id + */ + @Column(name = "pos_id") + private String posId; + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-log/src/main/java/com/pancm/model/User.java b/springboot-log/src/main/java/com/pancm/model/User.java new file mode 100644 index 0000000..d440a6c --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/model/User.java @@ -0,0 +1,71 @@ +package com.pancm.model; + + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Table; +import java.io.Serializable; +import java.sql.Date; + + /** +* @Title: 用户表(User)实体类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-01-15 15:27:05 +*/ +@Data +@Table(name = "user") +public class User implements Serializable { + private static final long serialVersionUID = -59671741667391987L; + /** + * ID + */ + @Column(name = "id") + private Long id; + /** + * 姓名 + */ + @Column(name = "name") + private String name; + /** + * 性别 + */ + @Column(name = "sex") + private Integer sex; + /** + * 年龄 + */ + @Column(name = "age") + private Integer age; + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + /** + * 创建人 + */ + @Column(name = "create_by") + private String createBy; + /** + * 更新时间 + */ + @Column(name = "update_time") + private Date updateTime; + /** + * 更新人 + */ + @Column(name = "update_by") + private String updateBy; + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-log/src/main/java/com/pancm/service/ITSysUserService.java b/springboot-log/src/main/java/com/pancm/service/ITSysUserService.java new file mode 100644 index 0000000..77d97b4 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/service/ITSysUserService.java @@ -0,0 +1,62 @@ +package com.pancm.service; + +import com.pancm.vo.TSysUserVO; +import com.pancm.model.TSysUser; +import com.pancm.vo.ApiResult; +import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; + + + /** +* @Title: 用户表(TSysUser)表服务接口 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-04-01 09:30:53 +*/ +public interface ITSysUserService extends IService{ + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TSysUserVO queryById(String id); + + + /** + * 通过实体作为筛选条件查询 + * + * @param tSysUserVO 实例对象 + * @return 对象列表 + */ + ApiResult list(TSysUserVO tSysUserVO); + + + /** + * 新增数据 + * + * @param tSysUserVO 实例对象 + * @return 实例对象 + */ + int insert(TSysUserVO tSysUserVO); + + /** + * 修改数据 + * + * @param tSysUserVO 实例对象 + * @return 实例对象 + */ + int update(TSysUserVO tSysUserVO); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(String id); + +} diff --git a/springboot-log/src/main/java/com/pancm/service/IUserService.java b/springboot-log/src/main/java/com/pancm/service/IUserService.java new file mode 100644 index 0000000..f87a804 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/service/IUserService.java @@ -0,0 +1,60 @@ +package com.pancm.service; + +import com.pancm.vo.UserVO; +import com.pancm.vo.ApiResult; +import java.util.List; + + + /** +* @Title: 用户表(User)表服务接口 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-01-15 15:27:03 +*/ +public interface IUserService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + UserVO queryById(Long id); + + + /** + * 通过实体作为筛选条件查询 + * + * @param userVO 实例对象 + * @return 对象列表 + */ + ApiResult list(UserVO userVO); + + + /** + * 新增数据 + * + * @param userVO 实例对象 + * @return 实例对象 + */ + int insert(UserVO userVO); + + /** + * 修改数据 + * + * @param userVO 实例对象 + * @return 实例对象 + */ + int update(UserVO userVO); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Long id); + +} diff --git a/springboot-log/src/main/java/com/pancm/service/impl/TSysUserServiceImpl.java b/springboot-log/src/main/java/com/pancm/service/impl/TSysUserServiceImpl.java new file mode 100644 index 0000000..da98bb8 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/service/impl/TSysUserServiceImpl.java @@ -0,0 +1,97 @@ +package com.pancm.service.impl; + + +import com.pancm.vo.TSysUserVO; +import com.pancm.model.TSysUser; +import com.pancm.dao.TSysUserDao; +import com.pancm.service.ITSysUserService; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.pancm.vo.ApiResult; +import com.pancm.vo.PageResult; +import org.springframework.stereotype.Service; +import org.springframework.beans.BeanUtils; +import javax.annotation.Resource; +import java.util.List; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + + + +/** +* @Title: 用户表(TSysUser)表服务实现类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-04-01 09:30:54 +*/ +@Service("tSysUserService") +public class TSysUserServiceImpl extends ServiceImpl implements ITSysUserService { + @Resource + private TSysUserDao tSysUserDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TSysUserVO queryById(String id) { + return this.tSysUserDao.queryById(id); + } + + + /** + * 根据条件查询 + * + * @return 实例对象的集合 + */ + @Override + public ApiResult list(TSysUserVO tSysUser) { + int pageNum = tSysUser.getPageNum(); + int pageSize = tSysUser.getPageSize(); + Page page = PageHelper.startPage(pageNum, pageSize); + List result = tSysUserDao.queryAll(tSysUser); + return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum)); + + } + + /** + * 新增数据 + * + * @param tSysUserVO 实例对象 + * @return 实例对象 + */ + @Override + public int insert(TSysUserVO tSysUserVO) { + TSysUser tSysUser = new TSysUser(); + BeanUtils.copyProperties(tSysUserVO,tSysUser); + return tSysUserDao.insert(tSysUser); + } + + /** + * 修改数据 + * + * @param tSysUserVO 实例对象 + * @return 实例对象 + */ + @Override + public int update(TSysUserVO tSysUserVO) { + TSysUser tSysUser = new TSysUser(); + BeanUtils.copyProperties(tSysUserVO,tSysUser); + return tSysUserDao.update(tSysUser); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(String id) { + return this.tSysUserDao.deleteById(id) > 0; + } +} diff --git a/springboot-log/src/main/java/com/pancm/service/impl/UserServiceImpl.java b/springboot-log/src/main/java/com/pancm/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..a7a5268 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/service/impl/UserServiceImpl.java @@ -0,0 +1,96 @@ +package com.pancm.service.impl; + + +import com.pancm.vo.UserVO; +import com.pancm.model.User; +import com.pancm.dao.UserDao; +import com.pancm.service.IUserService; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.pancm.vo.ApiResult; +import com.pancm.vo.PageResult; +import org.springframework.stereotype.Service; +import org.springframework.beans.BeanUtils; +import javax.annotation.Resource; +import java.util.List; + + + +/** +* @Title: 用户表(User)表服务实现类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-01-15 15:27:04 +*/ +@Service("userService") +public class UserServiceImpl implements IUserService { + @Resource + private UserDao userDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public UserVO queryById(Long id) { + return this.userDao.queryById(id); + } + + + /** + * 根据条件查询 + * + * @return 实例对象的集合 + */ + @Override + public ApiResult list(UserVO user) { + int pageNum = user.getPageNum(); + int pageSize = user.getPageSize(); + Page page = PageHelper.startPage(pageNum, pageSize); + List result = userDao.queryAll(user); + return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum)); + + } + + /** + * 新增数据 + * + * @param userVO 实例对象 + * @return 实例对象 + */ + @Override + public int insert(UserVO userVO) { + User user = new User(); + BeanUtils.copyProperties(userVO,user); + return userDao.insert(user); + } + + /** + * 修改数据 + * + * @param userVO 实例对象 + * @return 实例对象 + */ + @Override + public int update(UserVO userVO) { + User user = new User(); + BeanUtils.copyProperties(userVO,user); + return userDao.update(user); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Long id) { + return this.userDao.deleteById(id) > 0; + } +} diff --git a/springboot-log/src/main/java/com/pancm/util/FileHelper.java b/springboot-log/src/main/java/com/pancm/util/FileHelper.java new file mode 100644 index 0000000..b5fa52c --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/util/FileHelper.java @@ -0,0 +1,321 @@ +package com.pancm.util; + +import com.alibaba.fastjson.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.nio.charset.StandardCharsets; + + +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +public class FileHelper { + + private final static Logger log = LoggerFactory.getLogger(FileHelper.class); + + /** + * 行为单位读取文件,常用于读面向行的格式化文件 + * + * @param folder 文件目录 + * @param fileName 文件名 + * @return 文件内容,字符串格式 + */ + public static String readFileToString(String folder, String fileName) { + return readFileToString(folder + "/" + fileName); + } + + /** + * 以行为单位读取文件,常用于读面向行的格式化文件 + * + * @param filePath 文件路径 + * @return 文件内容,字符串 + */ + public static String readFileToString(String filePath) { + File file = new File(filePath); + BufferedReader reader = null; + StringBuilder builder = new StringBuilder(); + try { + reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); + String tempString = null; + int line = 1; + // 一次读入一行,直到读入null为文件结束 + while ((tempString = reader.readLine()) != null) { + // 显示行号 + builder.append(tempString); + } + reader.close(); + } catch (IOException e) { + throw new RuntimeException("file error#" + filePath, e); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + } + } + } + return builder.toString(); + } + + /** + * 读取文件,处理成 JSON格式 + * + * @param filePath 文件绝对路径 + * @return json格式 + */ + public static Object readFileToJson(String filePath) { + String content = FileHelper.readFileToString(filePath); + return JSONObject.parse(content); + } + + /** + * 相对路径转换为绝对路径 + * + * @param folderInput 相对路径,如./ + * @return 文件目录的绝对路径 + */ + public static String convertFolder(String folderInput) { + String folder = folderInput; + if (folderInput.startsWith("./")) { + String relativeFolder = folderInput.replace("./", ""); + String dir = System.getProperty("user.dir"); + folder = dir + "/" + relativeFolder; + } + return folder; + } + + + /** + * @return boolean + * @Author pancm + * @Description 创建文件夹--多层 + * @Date 2021/2/24 + * @Param [dir] + **/ + public static boolean createMultilayerFile(String dir) { + try { + File dirPath = new File(dir); + if (!dirPath.exists()) { + dirPath.mkdirs(); + } + } catch (Exception e) { + log.error("创建多层目录操作出错: " + e.getMessage()); + return false; + } + return true; + } + + + /** + * 文件本地存储 + * + * @param file 上传文件格式 + * @param destFolder 目标目录 + * @param destFileName 目标文件名 + * @return + */ + public static boolean saveFile(MultipartFile file, String destFolder, String destFileName) { + File dest = new File(destFolder + "/" + destFileName); +// if(!dest.getParentFile().exists()){ +// dest.getParentFile().mkdir(); +// } + createMultilayerFile(destFolder); + try { + file.transferTo(dest); + return true; + } catch (Exception e) { + log.error("file save error", e); + } + return false; + } + + + public static boolean saveFile(byte[] buf, String filePath, String fileName) { + BufferedOutputStream bos = null; + FileOutputStream fos = null; + File file = null; + try { + createMultilayerFile(filePath); + file = new File(filePath + File.separator + fileName); + fos = new FileOutputStream(file); + bos = new BufferedOutputStream(fos); + bos.write(buf); + } catch (Exception e) { + log.error("file save error", e); + return false; + } finally { + if (bos != null) { + try { + bos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return true; + } + + + /** + * 文件大小,单位 MB + * + * @param size 文件大小,单位byte + * @return 文件大小,MB + */ + public static long getSizeInMb(long size) { + return size / 1024 / 1024; + } + + /** + * 文件大小,单位 GB + * + * @param size 文件大小,单位byte + * @return 文件大小,GB + */ + public static long getSizeInGb(long size) { + return size / 1024 / 1024 / 1024; + } + + /** + * 获得文件扩展名 + * + * @param fileName 文件名 + * @return 扩展名,dot 后面的,如xls + */ + public static String getFileExtension(String fileName) { + if (fileName == null) { + return null; + } + int index = fileName.lastIndexOf("."); + if (index == -1) { + return null; + } + return fileName.substring(index + 1); + } + + /** + * 删除文件 + * + * @param folder 目录 + * @param fileName 文件名 + * @return 删除是否成功 + */ + public static boolean deleteFile(String folder, String fileName) { + return deleteFile(folder + "/" + fileName); + } + + /** + * 删除文件 + * + * @param filePath 文件的绝对路径 + * @return 删除是否成功 + */ + public static boolean deleteFile(String filePath) { + if (filePath == null) { + return false; + } + try { + File f = new File(filePath); + if (f.exists()) { + return f.delete(); + } + } catch (Exception ex) { + log.error("delete file error#" + filePath, ex); + } + return false; + } + + + public static String readResourcesFile(String path) { + StringBuilder sb = new StringBuilder(); + try (InputStream in = FileHelper.class.getClassLoader().getResourceAsStream(path)) { + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String msg = null; + while ((msg = reader.readLine()) != null) { + sb.append(msg); +// .append("\n") + } + + } catch (IOException e) { + log.error("read file error#", e); + } + return sb.toString(); + } + + + /** + * @Author beixing + * @Description 文件夹复制 + * @Date 2021/4/27 + * @Param + * @return + **/ + public static void copyFolder(String src, String des) { + //初始化文件复制 + File file1 = new File(src); + //把文件里面内容放进数组 + File[] fs = file1.listFiles(); + //初始化文件粘贴 + File file2 = new File(des); + //判断是否有这个文件有不管没有创建 + if (!file2.exists()) { + file2.mkdirs(); + } + //遍历文件及文件夹 + for (File f : fs) { + if (f.isFile()) { + ///调用文件拷贝的方法 + fileCopy(f.getPath(), des + File.separator + f.getName()); + } else if (f.isDirectory()) { + //文件夹 + copyFolder(f.getPath(), des + File.separator + f.getName()); + } + } + + } + + /** + * 文件复制的具体方法 + */ + public static void fileCopy(String src, String des) { + //io流固定格式 + try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(src)); + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(des))) { + int i = -1;//记录获取长度 + byte[] bt = new byte[2014];//缓冲区 + while ((i = bis.read(bt)) != -1) { + bos.write(bt, 0, i); + } + } catch (IOException e) { + log.error("read file error#", e); + } + } + + + public static void main(String[] args) { + String source = "D:\\video\\ceshi\\2021\\4\\26\\18\\34020000001310000001"; + String target = "D:\\video\\diagnosis\\2021\\4\\26\\18\\34020000001310000001"; +// copyFolder(source,target); + + String srcFile = "D:\\video\\ceshi\\2021\\5\\7\\10\\34020000001310000001\\34020000001310000001_20210507105454_00001.jpg"; + String desFile = "D:\\video\\34020000001310000001_20210507105454_测试.jpg"; + fileCopy(srcFile,desFile); + + } + + +} diff --git a/springboot-log/src/main/java/com/pancm/util/GetProperties.java b/springboot-log/src/main/java/com/pancm/util/GetProperties.java new file mode 100644 index 0000000..7c580e8 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/util/GetProperties.java @@ -0,0 +1,94 @@ +package com.pancm.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.util.*; +import java.util.Map.Entry; + +/** + * Title: getProperties + * Description: 获取配置文件 + * Version:1.0.0 + * + * @author pancm + * @date 2018年1月4日 + */ +public class GetProperties { + private static Map appSettings = new HashMap(); + private static final Logger LOG = LoggerFactory.getLogger(GetProperties.class); + private String pathName="build.properties"; + /** + * 初始化系统默认参数 + */ + private GetProperties(){ + init(); + } + + private void init(){ + InputStream in = null; + try{ + //获取resource中的配置 + in=this.getClass().getClassLoader().getResourceAsStream(pathName); + //获取项目同级的配置 +// in=new FileInputStream(new File(pathName)); + Properties prop = new Properties(); + prop.load(in); + Set> buf = prop.entrySet(); + Iterator> it = buf.iterator(); + while(it.hasNext()){ + Entry t = it.next(); + appSettings.put((String)t.getKey(), (String)t.getValue()); + } + }catch(IOException e){ + LOG.error("加载系统参数失败!",e); + }finally{ + if(null != in){ + try { + in.close(); + } catch (IOException e) { + LOG.error("加载系统参数失败!",e); + } + } + } + } + + /** + * 获取配置文件 + * + * @param + * @return app settings + */ + public synchronized static Map getAppSettings() { + if(null == appSettings || appSettings.isEmpty()){ + new GetProperties(); + } + return appSettings; + } + + /** + * Sets app settings. + * + * @param appSettings the app settings + * @param name the name + */ + public synchronized static void setAppSettings(Map appSettings,String name) { + if(null == appSettings || appSettings.isEmpty()){ + new GetProperties(); + } + GetProperties.appSettings = appSettings; + } + + /** + * 方法测试 + * + * @param args the input arguments + */ + public static void main(String[] args) { + Map conf = GetProperties.getAppSettings(); + System.out.println(conf); + } + +} diff --git a/springboot-log/src/main/java/com/pancm/vo/ApiResult.java b/springboot-log/src/main/java/com/pancm/vo/ApiResult.java new file mode 100644 index 0000000..cbd77fe --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/vo/ApiResult.java @@ -0,0 +1,92 @@ +package com.pancm.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +import static com.pancm.vo.BaseConstants.CODE_ERROR_UNKNOWN; +import static com.pancm.vo.BaseConstants.CODE_SUCCESS; +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +@Data +@ApiModel(value = "返回值", description="通用返回值") +public class ApiResult implements Serializable { + + private static final long serialVersionUID = 10000000L; + + @ApiModelProperty(value = "返回状态码;0:成功;其它,失败") + private int code; + + @ApiModelProperty(value = "补充信息,显示给前端用户") + private String message; + + @ApiModelProperty(value = "接口请求结果") + private T data; + + @ApiModelProperty(value = "异常的堆栈信息") + private Object stackTrace; + + public ApiResult message(String input) { + this.setMessage(input); + return this; + } + + public ApiResult appendMessage(String input) { + this.message += " " + input; + return this; + } + + public ApiResult data(T input) { + this.setData(input); + return this; + } + + public static ApiResult success() { + ApiResult resultMsg = new ApiResult(); + resultMsg.setCode(CODE_SUCCESS); + resultMsg.setMessage(""); + return resultMsg; + } + + public static ApiResult success(Object data) { + ApiResult resultMsg = new ApiResult(); + resultMsg.setCode(CODE_SUCCESS); + resultMsg.setData(data); + resultMsg.setMessage(""); + return resultMsg; + } + + public static ApiResult error(String message) { + return error(CODE_ERROR_UNKNOWN, message); + } + + public static ApiResult error(int code, String message) { + ApiResult resultMsg = new ApiResult(); + resultMsg.setCode(code); + resultMsg.setMessage(message); + return resultMsg; + } + + + public static ApiResult error(int code, String message, Object... data) { + ApiResult resultMsg = new ApiResult(); + resultMsg.setCode(code); + resultMsg.setMessage(message); + if (data != null) { + if (data.length >= 1) { + resultMsg.setData(data[0]); + } + if (data.length >= 2) { + resultMsg.setStackTrace(data[1]); + } + } + return resultMsg; + } +} diff --git a/springboot-log/src/main/java/com/pancm/vo/BaseConstants.java b/springboot-log/src/main/java/com/pancm/vo/BaseConstants.java new file mode 100644 index 0000000..9a467e5 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/vo/BaseConstants.java @@ -0,0 +1,42 @@ +package com.pancm.vo; + +/** + * @Author pancm + * @Description + * @Date 2019/2/17 + * @Param + * @return + **/ +public class BaseConstants { + + public static String CONSTANT_MODULE_TYPE_STRING = "string"; + public static String CONSTANT_MODULE_TYPE_INT = "int"; + + public static String SEPARATOR_SPACE = " "; + public static String SEPARATOR_COMMA = ", "; + public static String SEPARATOR_DOT = "."; + public static String SEPARATOR_LINE = "\n"; + + public static int DATE_RANGE_ARRAY_SIZE = 2; + + /** + * excel 相关 + */ + public static final int EXCEL_MAX_EMPTY_HEADER_COUNT = 50; + public static final int EXCEL_ROW_TYPE_SKIP = 1; + public static final int EXCEL_ROW_TYPE_NORMAL = 0; + + public static final String IP_SPLIT_SEPARATOR = "\\."; + + /** + * 校验类,合法的mac地址长度 + */ + public static int VALID_MAC_LENGTH = 17; + public static int VALID_MIN_MAC_LENGTH = 12; + public static int VALID_IP_MAX_LENGTH = 15; + + public static int IP_ASSIGN_LAST = 254; + + public static int CODE_ERROR_UNKNOWN = 5000; + public static int CODE_SUCCESS = 0; +} diff --git a/springboot-log/src/main/java/com/pancm/vo/BasePage.java b/springboot-log/src/main/java/com/pancm/vo/BasePage.java new file mode 100644 index 0000000..ae705bd --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/vo/BasePage.java @@ -0,0 +1,74 @@ +package com.pancm.vo; + +import com.alibaba.fastjson.annotation.JSONField; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.util.StringUtils; + + +import java.util.List; + +@ApiModel +@Data +public class BasePage { + + /** + * 页码 + * 必须定义为 protected or public,否则子类不可见 + */ + @ApiModelProperty(name = "page_num",value = "分页 - 第几页") + protected Integer pageNum=1; + + /** + * 页大小 + */ + @ApiModelProperty(name = "page_num",value = "分页 - 每页记录数") + protected Integer pageSize=10; + + /** + * 排序字段名称 + */ + @ApiModelProperty(name = "sort_name",value = "分页 - 排序列名") + protected String sortName; + + /** + * 排序方式 + */ + @ApiModelProperty(name = "sort_order",value = "分页 - 排序方式,asc/desc") + protected String sortOrder; + + @ApiModelProperty(name = "date", value = "起止日期") + @JSONField(name = "date") + protected List dateRange; + + protected String startDate; + + protected String endDate; + + /** + * 默认排序 + */ + protected String defaultOrder; + + /** + * 排序字符串 + */ + protected String orderString; + + public String getOrderBy() { + if (!StringUtils.isEmpty(this.sortName) && !StringUtils.isEmpty(this.sortOrder)) { + String orderBy = this.sortName + " " + this.sortOrder; + if (!StringUtils.isEmpty(this.defaultOrder) && !orderBy.equals(defaultOrder)) { + orderBy += ", " + defaultOrder; + } + return orderBy.replaceAll(".*([';]+|(--)+).*", " "); + } + if (!StringUtils.isEmpty(this.defaultOrder)) { + return defaultOrder.replaceAll(".*([';]+|(--)+).*", " "); + } + return null; + } + +} diff --git a/springboot-log/src/main/java/com/pancm/vo/PageResult.java b/springboot-log/src/main/java/com/pancm/vo/PageResult.java new file mode 100644 index 0000000..63b76f6 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/vo/PageResult.java @@ -0,0 +1,30 @@ +package com.pancm.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class PageResult implements Serializable { + + private static final long serialVersionUID = 10000001L; + + @JSONField(name = "total") + private long totalNum; + + private List list; + + private int pageSize; + + @JSONField(name = "currentPage") + private int pageNum; + + public PageResult(long totalNum, List list, int pageSize, int pageNum) { + this.totalNum = totalNum; + this.list = list; + this.pageSize = pageSize; + this.pageNum = pageNum; + } +} diff --git a/springboot-log/src/main/java/com/pancm/vo/TSysUserVO.java b/springboot-log/src/main/java/com/pancm/vo/TSysUserVO.java new file mode 100644 index 0000000..5bcfc34 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/vo/TSysUserVO.java @@ -0,0 +1,61 @@ +package com.pancm.vo; + +import java.io.Serializable; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.sql.Date; +import com.pancm.vo.BasePage; + +/** +* @Title: 用户表(TSysUser)请求响应对象 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-04-01 09:30:54 +*/ +@ApiModel(value = "TSysUser", description = "用户表") +@Data +public class TSysUserVO extends BasePage implements Serializable { + private static final long serialVersionUID = 855666123415935768L; + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + /** + * 用户账号 + */ + @ApiModelProperty(value = "用户账号") + private String username; + /** + * 用户密码 + */ + @ApiModelProperty(value = "用户密码") + private String password; + /** + * 昵称 + */ + @ApiModelProperty(value = "昵称") + private String nickname; + /** + * 部门id + */ + @ApiModelProperty(value = "部门id") + private Integer depId; + /** + * 岗位id + */ + @ApiModelProperty(value = "岗位id") + private String posId; + + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-log/src/main/java/com/pancm/vo/UserVO.java b/springboot-log/src/main/java/com/pancm/vo/UserVO.java new file mode 100644 index 0000000..3a3e035 --- /dev/null +++ b/springboot-log/src/main/java/com/pancm/vo/UserVO.java @@ -0,0 +1,71 @@ +package com.pancm.vo; + +import java.io.Serializable; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.sql.Date; +import com.pancm.vo.BasePage; + +/** +* @Title: 用户表(User)请求响应对象 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-01-15 15:27:05 +*/ +@ApiModel(value = "User", description = "用户表") +@Data +public class UserVO extends BasePage implements Serializable { + private static final long serialVersionUID = 887744157417771761L; + /** + * ID + */ + @ApiModelProperty(value = "ID") + private Long id; + /** + * 姓名 + */ + @ApiModelProperty(value = "姓名") + private String name; + /** + * 性别 + */ + @ApiModelProperty(value = "性别") + private Integer sex; + /** + * 年龄 + */ + @ApiModelProperty(value = "年龄") + private Integer age; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String createBy; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date updateTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String updateBy; + + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-log/src/main/resources/application-dev.yml b/springboot-log/src/main/resources/application-dev.yml new file mode 100644 index 0000000..e1f3514 --- /dev/null +++ b/springboot-log/src/main/resources/application-dev.yml @@ -0,0 +1,14 @@ +server: + port: 9876 + servlet: + context-path: /api + + +spring: + datasource: + pancm: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/pcm?autoReconnect=true&failOverReadOnly=false&characterEncoding=utf-8&useUnicode=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 123456 + diff --git a/springboot-log/src/main/resources/application-local.yml b/springboot-log/src/main/resources/application-local.yml new file mode 100644 index 0000000..e1f3514 --- /dev/null +++ b/springboot-log/src/main/resources/application-local.yml @@ -0,0 +1,14 @@ +server: + port: 9876 + servlet: + context-path: /api + + +spring: + datasource: + pancm: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/pcm?autoReconnect=true&failOverReadOnly=false&characterEncoding=utf-8&useUnicode=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 123456 + diff --git a/springboot-log/src/main/resources/application.yml b/springboot-log/src/main/resources/application.yml new file mode 100644 index 0000000..e19fcd9 --- /dev/null +++ b/springboot-log/src/main/resources/application.yml @@ -0,0 +1,15 @@ +spring: + profiles: + active: local + application: + name: springboot-log +log: + defender: + enable: true # 启用logback-defender + include-logger-prefix: com.ideaaedi.logback # 通过logger所属类的全类名前缀,指定脱敏范围(,多个实用逗号分割) + opt: default_json # 指定脱敏器 + config-json: + strategies: # 指定脱敏策略 + com.ideaaedi.logback.defender.strategy.SimpleDefenderStrategy__ACCOUNT_NO: account,accountNo + com.ideaaedi.logback.defender.strategy.SimpleDefenderStrategy__EMAIL: email,mail,emailList + com.ideaaedi.logback.defender.strategy.SimpleDefenderStrategy__PHONE_NUMBER: phone,mobile,telphone diff --git a/springboot-log/src/main/resources/build.properties b/springboot-log/src/main/resources/build.properties new file mode 100644 index 0000000..0ab57c4 --- /dev/null +++ b/springboot-log/src/main/resources/build.properties @@ -0,0 +1,4 @@ +build_app = springboot-demo +build_time = 2024-01-15 15:48:50 +git_commit = +git_branch = diff --git a/springboot-log/src/main/resources/logback.xml b/springboot-log/src/main/resources/logback.xml new file mode 100644 index 0000000..a17046c --- /dev/null +++ b/springboot-log/src/main/resources/logback.xml @@ -0,0 +1,85 @@ + + + + + + + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''}|-%msg%n| + + + + + + + ${LOG_HOME}/msgInfo-%d{yyyy-MM-dd}.%i.log + + 10MB + 15 + 10GB + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%logger{50}|-%msg%n + + + + + + + + + ${LOG_HOME}/msgDebug-%d{yyyy-MM-dd}.%i.log + + 10MB + 7 + 10GB + + + DEBUG + ACCEPT + DENY + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%logger{50}|-%msg%n + + + + + + + + + ${LOG_HOME}/msgError-%d{yyyy-MM-dd}.%i.log + + 10MB + 7 + 10GB + + + ERROR + ACCEPT + DENY + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%logger{50}|-%msg%n + + + + + + + + + + + + + diff --git a/springboot-log/src/main/resources/pancm/mapper/DbVersionMapper.xml b/springboot-log/src/main/resources/pancm/mapper/DbVersionMapper.xml new file mode 100644 index 0000000..6302933 --- /dev/null +++ b/springboot-log/src/main/resources/pancm/mapper/DbVersionMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/springboot-log/src/main/resources/pancm/mapper/TSysUserMapper.xml b/springboot-log/src/main/resources/pancm/mapper/TSysUserMapper.xml new file mode 100644 index 0000000..5682b64 --- /dev/null +++ b/springboot-log/src/main/resources/pancm/mapper/TSysUserMapper.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + insert into t_sys_user(username, password, nickname, dep_id, pos_id) + values (#{username}, #{password}, #{nickname}, #{depId}, #{posId}) + + + + insert into t_sys_user(username, password, nickname, dep_id, pos_id) + values + + (#{entity.username}, #{entity.password}, #{entity.nickname}, #{entity.depId}, #{entity.posId}) + + + + + insert into t_sys_user(username, password, nickname, dep_id, pos_id) + values + + (#{entity.username}, #{entity.password}, #{entity.nickname}, #{entity.depId}, #{entity.posId}) + + on duplicate key update +username = values(username) , password = values(password) , nickname = values(nickname) , dep_id = values(dep_id) , pos_id = values(pos_id) + + + + update t_sys_user + + + username = #{username}, + + + password = #{password}, + + + nickname = #{nickname}, + + + dep_id = #{depId}, + + + pos_id = #{posId}, + + + where id = #{id} + + + + + delete from t_sys_user where id = #{id} + + + + diff --git a/springboot-log/src/main/resources/pancm/mapper/UserMapper.xml b/springboot-log/src/main/resources/pancm/mapper/UserMapper.xml new file mode 100644 index 0000000..7a9342f --- /dev/null +++ b/springboot-log/src/main/resources/pancm/mapper/UserMapper.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into user(name, sex, age, create_time, create_by, update_time, update_by) + values (#{name}, #{sex}, #{age}, #{createTime}, #{createBy}, #{updateTime}, #{updateBy}) + + + + insert into user(name, sex, age, create_time, create_by, update_time, update_by) + values + + (#{entity.name}, #{entity.sex}, #{entity.age}, #{entity.createTime}, #{entity.createBy}, #{entity.updateTime}, #{entity.updateBy}) + + + + + insert into user(name, sex, age, create_time, create_by, update_time, update_by) + values + + (#{entity.name}, #{entity.sex}, #{entity.age}, #{entity.createTime}, #{entity.createBy}, #{entity.updateTime}, #{entity.updateBy}) + + on duplicate key update +name = values(name) , sex = values(sex) , age = values(age) , create_time = values(create_time) , create_by = values(create_by) , update_time = values(update_time) , update_by = values(update_by) + + + + update user + + + name = #{name}, + + + sex = #{sex}, + + + age = #{age}, + + + create_time = #{createTime}, + + + create_by = #{createBy}, + + + update_time = #{updateTime}, + + + update_by = #{updateBy}, + + + where id = #{id} + + + + + delete from user where id = #{id} + + + + diff --git a/springboot-log/src/main/resources/pancm/mybatis-config.xml b/springboot-log/src/main/resources/pancm/mybatis-config.xml new file mode 100644 index 0000000..bd2d7b7 --- /dev/null +++ b/springboot-log/src/main/resources/pancm/mybatis-config.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/springboot-log/src/main/resources/version.txt b/springboot-log/src/main/resources/version.txt new file mode 100644 index 0000000..621cb01 --- /dev/null +++ b/springboot-log/src/main/resources/version.txt @@ -0,0 +1 @@ +V1.0.1 diff --git a/springboot-log/start.sh b/springboot-log/start.sh new file mode 100644 index 0000000..a9c873b --- /dev/null +++ b/springboot-log/start.sh @@ -0,0 +1,11 @@ +APPDIR=`pwd` +PIDFILE=$APPDIR/springboot-demo.pid +if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then +echo "springboot-demo is already running..." +exit 1 +fi +nohup java -jar $APPDIR/springboot-demo.jar >/dev/null 2>&1 & +echo $! > $PIDFILE +echo "start springboot-demo..." + + diff --git a/springboot-log/stop.sh b/springboot-log/stop.sh new file mode 100644 index 0000000..69dbc4c --- /dev/null +++ b/springboot-log/stop.sh @@ -0,0 +1,13 @@ +APPDIR=`pwd` +PIDFILE=$APPDIR/springboot-demo.pid +if [ ! -f "$PIDFILE" ] || ! kill -0 "$(cat "$PIDFILE")"; then +echo "springboot-demo not running..." +else +echo "stopping springboot-demo..." +PID="$(cat "$PIDFILE")" +kill -9 $PID +rm "$PIDFILE" +echo "...springboot-demo stopped" +fi + + diff --git a/springboot-log/target/classes/META-INF/spring-configuration-metadata.json b/springboot-log/target/classes/META-INF/spring-configuration-metadata.json new file mode 100644 index 0000000..11229f9 --- /dev/null +++ b/springboot-log/target/classes/META-INF/spring-configuration-metadata.json @@ -0,0 +1,12 @@ +{ + "groups": [ + { + "name": "spring.datasource.pancm", + "type": "javax.sql.DataSource", + "sourceType": "com.pancm.config.PancmConfiguration", + "sourceMethod": "pancmDataSource()" + } + ], + "properties": [], + "hints": [] +} \ No newline at end of file diff --git a/springboot-log/target/classes/application-dev.yml b/springboot-log/target/classes/application-dev.yml new file mode 100644 index 0000000..e1f3514 --- /dev/null +++ b/springboot-log/target/classes/application-dev.yml @@ -0,0 +1,14 @@ +server: + port: 9876 + servlet: + context-path: /api + + +spring: + datasource: + pancm: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/pcm?autoReconnect=true&failOverReadOnly=false&characterEncoding=utf-8&useUnicode=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 123456 + diff --git a/springboot-log/target/classes/application-local.yml b/springboot-log/target/classes/application-local.yml new file mode 100644 index 0000000..e1f3514 --- /dev/null +++ b/springboot-log/target/classes/application-local.yml @@ -0,0 +1,14 @@ +server: + port: 9876 + servlet: + context-path: /api + + +spring: + datasource: + pancm: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/pcm?autoReconnect=true&failOverReadOnly=false&characterEncoding=utf-8&useUnicode=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 123456 + diff --git a/springboot-log/target/classes/application.yml b/springboot-log/target/classes/application.yml new file mode 100644 index 0000000..e19fcd9 --- /dev/null +++ b/springboot-log/target/classes/application.yml @@ -0,0 +1,15 @@ +spring: + profiles: + active: local + application: + name: springboot-log +log: + defender: + enable: true # 启用logback-defender + include-logger-prefix: com.ideaaedi.logback # 通过logger所属类的全类名前缀,指定脱敏范围(,多个实用逗号分割) + opt: default_json # 指定脱敏器 + config-json: + strategies: # 指定脱敏策略 + com.ideaaedi.logback.defender.strategy.SimpleDefenderStrategy__ACCOUNT_NO: account,accountNo + com.ideaaedi.logback.defender.strategy.SimpleDefenderStrategy__EMAIL: email,mail,emailList + com.ideaaedi.logback.defender.strategy.SimpleDefenderStrategy__PHONE_NUMBER: phone,mobile,telphone diff --git a/springboot-log/target/classes/build.properties b/springboot-log/target/classes/build.properties new file mode 100644 index 0000000..0ab57c4 --- /dev/null +++ b/springboot-log/target/classes/build.properties @@ -0,0 +1,4 @@ +build_app = springboot-demo +build_time = 2024-01-15 15:48:50 +git_commit = +git_branch = diff --git a/springboot-log/target/classes/logback.xml b/springboot-log/target/classes/logback.xml new file mode 100644 index 0000000..a17046c --- /dev/null +++ b/springboot-log/target/classes/logback.xml @@ -0,0 +1,85 @@ + + + + + + + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''}|-%msg%n| + + + + + + + ${LOG_HOME}/msgInfo-%d{yyyy-MM-dd}.%i.log + + 10MB + 15 + 10GB + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%logger{50}|-%msg%n + + + + + + + + + ${LOG_HOME}/msgDebug-%d{yyyy-MM-dd}.%i.log + + 10MB + 7 + 10GB + + + DEBUG + ACCEPT + DENY + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%logger{50}|-%msg%n + + + + + + + + + ${LOG_HOME}/msgError-%d{yyyy-MM-dd}.%i.log + + 10MB + 7 + 10GB + + + ERROR + ACCEPT + DENY + + + + |%d{yyyy-MM-dd HH:mm:ss.SSS}|[%thread]|%-5level|%logger{50}|-%msg%n + + + + + + + + + + + + + diff --git a/springboot-log/target/classes/pancm/mapper/DbVersionMapper.xml b/springboot-log/target/classes/pancm/mapper/DbVersionMapper.xml new file mode 100644 index 0000000..6302933 --- /dev/null +++ b/springboot-log/target/classes/pancm/mapper/DbVersionMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/springboot-log/target/classes/pancm/mapper/TSysUserMapper.xml b/springboot-log/target/classes/pancm/mapper/TSysUserMapper.xml new file mode 100644 index 0000000..5682b64 --- /dev/null +++ b/springboot-log/target/classes/pancm/mapper/TSysUserMapper.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + insert into t_sys_user(username, password, nickname, dep_id, pos_id) + values (#{username}, #{password}, #{nickname}, #{depId}, #{posId}) + + + + insert into t_sys_user(username, password, nickname, dep_id, pos_id) + values + + (#{entity.username}, #{entity.password}, #{entity.nickname}, #{entity.depId}, #{entity.posId}) + + + + + insert into t_sys_user(username, password, nickname, dep_id, pos_id) + values + + (#{entity.username}, #{entity.password}, #{entity.nickname}, #{entity.depId}, #{entity.posId}) + + on duplicate key update +username = values(username) , password = values(password) , nickname = values(nickname) , dep_id = values(dep_id) , pos_id = values(pos_id) + + + + update t_sys_user + + + username = #{username}, + + + password = #{password}, + + + nickname = #{nickname}, + + + dep_id = #{depId}, + + + pos_id = #{posId}, + + + where id = #{id} + + + + + delete from t_sys_user where id = #{id} + + + + diff --git a/springboot-log/target/classes/pancm/mapper/UserMapper.xml b/springboot-log/target/classes/pancm/mapper/UserMapper.xml new file mode 100644 index 0000000..7a9342f --- /dev/null +++ b/springboot-log/target/classes/pancm/mapper/UserMapper.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into user(name, sex, age, create_time, create_by, update_time, update_by) + values (#{name}, #{sex}, #{age}, #{createTime}, #{createBy}, #{updateTime}, #{updateBy}) + + + + insert into user(name, sex, age, create_time, create_by, update_time, update_by) + values + + (#{entity.name}, #{entity.sex}, #{entity.age}, #{entity.createTime}, #{entity.createBy}, #{entity.updateTime}, #{entity.updateBy}) + + + + + insert into user(name, sex, age, create_time, create_by, update_time, update_by) + values + + (#{entity.name}, #{entity.sex}, #{entity.age}, #{entity.createTime}, #{entity.createBy}, #{entity.updateTime}, #{entity.updateBy}) + + on duplicate key update +name = values(name) , sex = values(sex) , age = values(age) , create_time = values(create_time) , create_by = values(create_by) , update_time = values(update_time) , update_by = values(update_by) + + + + update user + + + name = #{name}, + + + sex = #{sex}, + + + age = #{age}, + + + create_time = #{createTime}, + + + create_by = #{createBy}, + + + update_time = #{updateTime}, + + + update_by = #{updateBy}, + + + where id = #{id} + + + + + delete from user where id = #{id} + + + + diff --git a/springboot-log/target/classes/pancm/mybatis-config.xml b/springboot-log/target/classes/pancm/mybatis-config.xml new file mode 100644 index 0000000..bd2d7b7 --- /dev/null +++ b/springboot-log/target/classes/pancm/mybatis-config.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/springboot-log/target/classes/version.txt b/springboot-log/target/classes/version.txt new file mode 100644 index 0000000..621cb01 --- /dev/null +++ b/springboot-log/target/classes/version.txt @@ -0,0 +1 @@ +V1.0.1 diff --git a/springboot-log/target/maven-archiver/pom.properties b/springboot-log/target/maven-archiver/pom.properties new file mode 100644 index 0000000..78e5456 --- /dev/null +++ b/springboot-log/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +version=0.0.1-SNAPSHOT +groupId=com.pancm +artifactId=springboot-log diff --git a/springboot-log/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/springboot-log/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e7bb86b --- /dev/null +++ b/springboot-log/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +META-INF\spring-configuration-metadata.json diff --git a/springboot-log/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/springboot-log/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..2ec449d --- /dev/null +++ b/springboot-log/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,24 @@ +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\controller\UserController.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\model\User.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\vo\BaseConstants.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\config\SwaggerConfig.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\config\CorsFilter.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\service\impl\TSysUserServiceImpl.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\Application.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\controller\HomeController.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\vo\UserVO.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\util\FileHelper.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\model\TSysUser.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\vo\BasePage.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\vo\ApiResult.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\service\ITSysUserService.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\vo\TSysUserVO.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\controller\TSysUserController.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\config\SpringBeanFactory.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\service\IUserService.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\service\impl\UserServiceImpl.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\config\PancmConfiguration.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\vo\PageResult.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\dao\TSysUserDao.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\dao\UserDao.java +D:\pcm\MyProject\springBoot-study\springboot-log\src\main\java\com\pancm\util\GetProperties.java diff --git a/springboot-log/target/springboot-log.jar.original b/springboot-log/target/springboot-log.jar.original new file mode 100644 index 0000000..8c2e5a4 Binary files /dev/null and b/springboot-log/target/springboot-log.jar.original differ