diff --git a/pom.xml b/pom.xml index d67b73eb863ebeae974b32b6101d909b968344c3..3e0dd69d278e5364957794fd5e83bdd4b9e4f896 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ v2 0.0.1-SNAPSHOT v2 - war + jar springboot-v2-pear @@ -55,6 +55,17 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + org.springframework.boot + spring-boot-starter-undertow @@ -273,27 +284,6 @@ true - - - org.mybatis.generator - mybatis-generator-maven-plugin - ${mybatis-generator-maven-plugin.version} - - - false - - false - - src/main/resources/mybatis-generator.xml - - - - mysql - mysql-connector-java - ${mysql.version} - - - org.springframework.boot diff --git a/src/main/java/com/fc/v2/controller/admin/PermissionController.java b/src/main/java/com/fc/v2/controller/admin/PermissionController.java index f11ddc7232bb69e98b489eb12d253434a4fccf5f..475f45cb2007805a3a0797ffb8264afdbf300e3a 100644 --- a/src/main/java/com/fc/v2/controller/admin/PermissionController.java +++ b/src/main/java/com/fc/v2/controller/admin/PermissionController.java @@ -9,8 +9,6 @@ import com.fc.v2.model.auto.TSysPermission; import com.fc.v2.model.custom.Tablepar; import com.fc.v2.shiro.util.ShiroUtils; import com.fc.v2.util.StringUtils; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -24,7 +22,7 @@ import java.util.List; /** * 权限Controller - * + * * @author fuce * @date: 2018年9月2日 下午8:08:21 */ @@ -68,9 +66,7 @@ public class PermissionController extends BaseController { queryWrapper.orderByAsc("order_num"); queryWrapper.like(StringUtils.isNotEmpty(searchText), "order_num", searchText); - //PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); - List list= sysPermissionService.selectTSysPermissionList(queryWrapper); - //PageInfo page = new PageInfo(list); + List list = sysPermissionService.selectTSysPermissionList(queryWrapper); return treeTable(list); } diff --git a/src/main/java/com/fc/v2/controller/admin/SysDepartmentController.java b/src/main/java/com/fc/v2/controller/admin/SysDepartmentController.java index beb33ba4e9dd3cca66d1f08111767c38bac12476..bec4aef038e0cb10d2a515c88ef7d52ea8287714 100644 --- a/src/main/java/com/fc/v2/controller/admin/SysDepartmentController.java +++ b/src/main/java/com/fc/v2/controller/admin/SysDepartmentController.java @@ -10,8 +10,6 @@ import com.fc.v2.model.custom.Tablepar; import com.fc.v2.common.domain.ResuTree; import com.fc.v2.service.ITSysDepartmentService; import com.fc.v2.util.StringUtils; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -69,14 +67,13 @@ public class SysDepartmentController extends BaseController { queryWrapper.orderByAsc(tablepar.getOrderByColumn()); } - PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); - PageInfo page = new PageInfo(sysDepartmentService.selectTSysDepartmentList(queryWrapper)); - return treeTable(page.getList()); + List list = sysDepartmentService.selectTSysDepartmentList(queryWrapper); + return treeTable(list); } /** * 新增 - * + * * @param modelMap * @return */ @@ -166,7 +163,7 @@ public class SysDepartmentController extends BaseController { /** * 修改保存 - * + * * @param record * @return */ @@ -181,7 +178,6 @@ public class SysDepartmentController extends BaseController { /** - * * @return */ @GetMapping("/selectParent") @@ -207,7 +203,7 @@ public class SysDepartmentController extends BaseController { /** * 获取部门树状数据结构 - * + * * @return */ @GetMapping("tree") diff --git a/src/main/java/com/fc/v2/model/auto/TSysDepartment.java b/src/main/java/com/fc/v2/model/auto/TSysDepartment.java index 81bf017a90aec9e7372768a1b305ca847c8d8bd0..fc19aa869b7b69162822879e9f9a43adced3ee01 100644 --- a/src/main/java/com/fc/v2/model/auto/TSysDepartment.java +++ b/src/main/java/com/fc/v2/model/auto/TSysDepartment.java @@ -30,6 +30,7 @@ public class TSysDepartment extends BaseEntity /** 父id */ @ApiModelProperty(value = "父id") + @JsonSerialize(using = ToStringSerializer.class) private Long parentId; /** 部门名称 */ diff --git a/src/main/java/com/fc/v2/model/auto/TSysPermission.java b/src/main/java/com/fc/v2/model/auto/TSysPermission.java index 50ca670689126e18dbfe1d4bb155fd60929f9bc1..d1b89f8cec649c7cb7e8b4007f5e8badb8cae86e 100644 --- a/src/main/java/com/fc/v2/model/auto/TSysPermission.java +++ b/src/main/java/com/fc/v2/model/auto/TSysPermission.java @@ -37,6 +37,7 @@ public class TSysPermission extends BaseEntity private Integer isBlank; /** 父节点id */ + @JsonSerialize(using = ToStringSerializer.class) private Long pid; /** 权限标识 */ diff --git a/src/main/java/com/fc/v2/model/auto/TSysPermissionRole.java b/src/main/java/com/fc/v2/model/auto/TSysPermissionRole.java index 7ed7253881f5e4df6a66893195400b83e9ecbc38..99a7d7197ee3c2e97b3a0967c9483af395d9022e 100644 --- a/src/main/java/com/fc/v2/model/auto/TSysPermissionRole.java +++ b/src/main/java/com/fc/v2/model/auto/TSysPermissionRole.java @@ -25,9 +25,11 @@ public class TSysPermissionRole extends BaseEntity private Long id; /** 角色id */ + @JsonSerialize(using = ToStringSerializer.class) private Long roleId; /** 权限id */ + @JsonSerialize(using = ToStringSerializer.class) private Long permissionId; public void setId(Long id) diff --git a/src/main/java/com/fc/v2/model/auto/TSysRoleUser.java b/src/main/java/com/fc/v2/model/auto/TSysRoleUser.java index f3455119ffc2f4f0bedd6553ab9f992de444b069..c51f1b18fc63efdc9d27466f06413767a8705f6a 100644 --- a/src/main/java/com/fc/v2/model/auto/TSysRoleUser.java +++ b/src/main/java/com/fc/v2/model/auto/TSysRoleUser.java @@ -25,9 +25,11 @@ public class TSysRoleUser extends BaseEntity private Long id; /** 用户id */ + @JsonSerialize(using = ToStringSerializer.class) private Long sysUserId; /** 角色id */ + @JsonSerialize(using = ToStringSerializer.class) private Long sysRoleId; public void setId(Long id) diff --git a/src/main/java/com/fc/v2/model/custom/SysPower.java b/src/main/java/com/fc/v2/model/custom/SysPower.java index 441d7aad7a2b90ebcbe177e7ef35198377f28837..74622145c07507a77da759d82d3e192a61a36079 100644 --- a/src/main/java/com/fc/v2/model/custom/SysPower.java +++ b/src/main/java/com/fc/v2/model/custom/SysPower.java @@ -1,5 +1,8 @@ package com.fc.v2.model.custom; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + /** * Describe: 权限领域模型 * Author: 就 眠 仪 式 @@ -10,7 +13,8 @@ public class SysPower{ /** * 编号 - * */ + */ + @JsonSerialize(using = ToStringSerializer.class) private Long powerId; /** @@ -41,6 +45,7 @@ public class SysPower{ /** * 父级编号 * */ + @JsonSerialize(using = ToStringSerializer.class) private Long parentId; /** diff --git a/src/main/java/com/fc/v2/model/custom/autocode/TableInfo.java b/src/main/java/com/fc/v2/model/custom/autocode/TableInfo.java index 8d59eea7fd6c464cfa06e84ff4f8b057b95a8e09..bb4305b3a673585edd360d4092908397b926d720 100644 --- a/src/main/java/com/fc/v2/model/custom/autocode/TableInfo.java +++ b/src/main/java/com/fc/v2/model/custom/autocode/TableInfo.java @@ -1,98 +1,141 @@ package com.fc.v2.model.custom.autocode; import java.util.List; +import java.util.Objects; + import org.apache.commons.lang.WordUtils; import com.fc.v2.util.StringUtils; +/** + * 数据库表对象 + */ public class TableInfo { - //数据库表名字 t_fifle - private String tableName; - //java表名字例如 SysOperLog - private String javaTableName; - //数据表注释 例如文件管理系统 - private String tableComment; - //java表名字例如 sysOperLog - private String javaTableName_a; - - //字段集合 - List beanColumns; - + + /** + * 数据库表名字 t_fifle + */ + private String tableName; + + /** + * java表名字例如 SysOperLog + */ + private String javaTableName; + + /** + * 数据表注释 例如文件管理系统 + */ + private String tableComment; + + /** + * java表名字例如 sysOperLog + */ + private String javaTableName_a; + + /** + * 字段集合 + */ + List beanColumns; + + /** + * Entity基类字段 + */ + public static final String[] BASE_ENTITY = {"createBy" , "createTime" , "updateBy" , "updateTime" , "remark"}; + public String getTableName() { - return tableName; - } - public void setTableName(String tableName) { - this.tableName = tableName; - } - public String getJavaTableName() { - return javaTableName; - } - public void setJavaTableName(String javaTableName) { - this.javaTableName = javaTableName; - } - public List getBeanColumns() { - return beanColumns; - } - public void setBeanColumns(List beanColumns) { - this.beanColumns = beanColumns; - } - public String getTableComment() { - return tableComment; - } - public void setTableComment(String tableComment) { - this.tableComment = tableComment; - } - public String getJavaTableName_a() { - return javaTableName_a; - } - public void setJavaTableName_a(String javaTableName_a) { - this.javaTableName_a = javaTableName_a; - } - - public TableInfo(String tableName,List beanColumns,String tableComment) { - super(); - this.tableName = tableName; - this.javaTableName = tableToJava(tableName); - this.beanColumns = beanColumns; - this.tableComment=tableComment; - this.javaTableName_a=tableToJava_a(tableName); - } - - public TableInfo() { - super(); - } - /** + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getJavaTableName() { + return javaTableName; + } + + public void setJavaTableName(String javaTableName) { + this.javaTableName = javaTableName; + } + + public List getBeanColumns() { + return beanColumns; + } + + public void setBeanColumns(List beanColumns) { + this.beanColumns = beanColumns; + } + + public String getTableComment() { + return tableComment; + } + + public void setTableComment(String tableComment) { + this.tableComment = tableComment; + } + + public String getJavaTableName_a() { + return javaTableName_a; + } + + public void setJavaTableName_a(String javaTableName_a) { + this.javaTableName_a = javaTableName_a; + } + + public TableInfo(String tableName, List beanColumns, String tableComment) { + super(); + this.tableName = tableName; + this.javaTableName = tableToJava(tableName); + this.beanColumns = beanColumns; + this.tableComment = tableComment; + this.javaTableName_a = tableToJava_a(tableName); + } + + public TableInfo() { + super(); + } + + /** * 列名转换成Java属性名 - * 例如 xxx_xx_aa > XxxXxAa + * + * @param columnName + * @return */ - public String columnToJava(String columnName) { - return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", "" ); + public String columnToJava(String columnName) { + return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_" , ""); } - /** + + /** * 表名转换成Java类名 - * 例如t_user > User + * + * @param tableName + * @return */ public String tableToJava(String tableName) { - String tablePrefix=AutoCodeConfig.getConfig().getString("tablePrefix"); + String tablePrefix = Objects.requireNonNull(AutoCodeConfig.getConfig()).getString("tablePrefix"); if (StringUtils.isNotBlank(tablePrefix)) { - tableName=tableName.replaceFirst(tablePrefix, "" ); + tableName = tableName.replaceFirst(tablePrefix, ""); } return columnToJava(tableName); } - + /** * 首字母小写 + * * @param tableName * @return - * @author fuce - * @Date 2021年1月15日 下午6:22:58 */ public String tableToJava_a(String tableName) { - String str=tableToJava(tableName); - return StringUtils.firstLowerCase(str); - } - - - - - + String str = tableToJava(tableName); + return StringUtils.firstLowerCase(str); + } + + /** + * + * + * @param javaField + * @return + */ + public static boolean isSuperColumn(String javaField) { + return StringUtils.equalsAnyIgnoreCase(javaField, BASE_ENTITY); + } } diff --git a/src/main/java/com/fc/v2/util/AutoCode/AutoCodeUtil.java b/src/main/java/com/fc/v2/util/AutoCode/AutoCodeUtil.java index c49cf457e2fd1af1f385c7728d1899fe8b5eb603..bcff202b4b55240ebfdb17ca8e30a4f3bfbf12b4 100644 --- a/src/main/java/com/fc/v2/util/AutoCode/AutoCodeUtil.java +++ b/src/main/java/com/fc/v2/util/AutoCode/AutoCodeUtil.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Properties; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; + import org.apache.commons.io.IOUtils; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; @@ -26,19 +27,21 @@ import cn.hutool.core.date.DateTime; /** * 自动生成 通用类 -* @ClassName: AutoCodeUtil -* @author fuce -* @date 2019-11-20 22:05 + * + * @author fuce + * @ClassName: AutoCodeUtil + * @date 2019-11-20 22:05 */ public class AutoCodeUtil { - public static List getTemplates(){ + public static List getTemplates() { List templates = new ArrayList(); //java代码模板 templates.add("auto_code/model/Entity.java.vm"); - templates.add("auto_code/model/EntityExample.java.vm"); + //templates.add("auto_code/model/EntityExample.java.vm"); templates.add("auto_code/mapperxml/EntityMapper.xml.vm"); templates.add("auto_code/service/EntityService.java.vm"); + templates.add("auto_code/service/impl/EntityServiceImpl.java.vm"); templates.add("auto_code/mapper/EntityMapper.java.vm"); templates.add("auto_code/controller/EntityController.java.vm"); //前端模板 @@ -50,248 +53,254 @@ public class AutoCodeUtil { //templates.add("auto_code/说明.txt.vm"); return templates; } - - - /** - * 创建单表 - * @param tableName 表名 - * @param conditionQueryField 条件查询字段 - * @param pid 父id - * @param sqlcheck 是否录入数据 - * @param vhtml 生成html - * @param vController 生成controller - * @param vservice 生成service - * @param vMapperORdao 生成mapper or dao - * @author fuce - * @Date 2019年8月24日 下午11:44:54 - */ - public static void autoCodeOneModel(TableInfo tableInfo,AutoConfigModel autoConfigModel){ - AutoCodeConfig autoCodeConfig=new AutoCodeConfig(); - //设置velocity资源加载器 + + + /** + * 创建单表 + * + * @param tableName 表名 + * @param conditionQueryField 条件查询字段 + * @param pid 父id + * @param sqlcheck 是否录入数据 + * @param vhtml 生成html + * @param vController 生成controller + * @param vservice 生成service + * @param vMapperORdao 生成mapper or dao + * @author fuce + * @Date 2019年8月24日 下午11:44:54 + */ + public static void autoCodeOneModel(TableInfo tableInfo, AutoConfigModel autoConfigModel) { + AutoCodeConfig autoCodeConfig = new AutoCodeConfig(); + //设置velocity资源加载器 Properties prop = new Properties(); - prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" ); + prop.put("file.resource.loader.class" , "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(prop); - Map map = new HashMap<>(); + Map map = new HashMap<>(); //数据库表数据 - map.put("tableInfo",tableInfo); + map.put("tableInfo" , tableInfo); //字段集合 - map.put("beanColumns",tableInfo.getBeanColumns()); + map.put("beanColumns" , tableInfo.getBeanColumns()); //配置文件 - map.put("SnowflakeIdWorker", SnowflakeIdWorker.class); + map.put("SnowflakeIdWorker" , SnowflakeIdWorker.class); //class类路径 - map.put("parentPack", autoCodeConfig.getConfigkey("parentPack")); + map.put("parentPack" , autoCodeConfig.getConfigkey("parentPack")); //作者 - map.put("author", autoConfigModel.getAuthor()); + map.put("author" , autoConfigModel.getAuthor()); //时间 - map.put("datetime",new DateTime()); + map.put("datetime" , new DateTime()); //sql需要的权限父级pid - map.put("pid",autoConfigModel.getPid()); - + map.put("pid" , autoConfigModel.getPid()); + VelocityContext context = new VelocityContext(map); - + //获取模板列表 List templates = getTemplates(); - /* - * if(vhtml!=true) { templates.remove("auto_code/html/list.html.vm"); - * templates.remove("auto_code/html/add.html.vm"); - * templates.remove("auto_code/html/edit.html.vm"); } if (vController!=true) { - * templates.remove("auto_code/controller/EntityController.java.vm"); } if - * (vService!=true) { - * templates.remove("auto_code/service/EntityService.java.vm"); } if - * (vMapperORdao!=true) { templates.remove("auto_code/model/Entity.java.vm"); - * templates.remove("auto_code/model/EntityExample.java.vm"); - * templates.remove("auto_code/mapperxml/EntityMapper.xml.vm"); - * templates.remove("auto_code/mapper/EntityMapper.java.vm"); } - */ + /* + * if(vhtml!=true) { templates.remove("auto_code/html/list.html.vm"); + * templates.remove("auto_code/html/add.html.vm"); + * templates.remove("auto_code/html/edit.html.vm"); } if (vController!=true) { + * templates.remove("auto_code/controller/EntityController.java.vm"); } if + * (vService!=true) { + * templates.remove("auto_code/service/EntityService.java.vm"); } if + * (vMapperORdao!=true) { templates.remove("auto_code/model/Entity.java.vm"); + * templates.remove("auto_code/model/EntityExample.java.vm"); + * templates.remove("auto_code/mapperxml/EntityMapper.xml.vm"); + * templates.remove("auto_code/mapper/EntityMapper.java.vm"); } + */ for (String template : templates) { - try { - String targetPath = autoConfigModel.getParentPath(); - String filepath=getCoverFileName(template,tableInfo ,autoCodeConfig.getConfigkey("parentPack"),targetPath); - Template tpl = Velocity.getTemplate(template, "UTF-8" ); - File file = new File(filepath); - if (!file.getParentFile().exists()) - file.getParentFile().mkdirs(); - if (!file.exists()) - file.createNewFile(); - try (FileOutputStream outStream = new FileOutputStream(file); - OutputStreamWriter writer = new OutputStreamWriter(outStream, "UTF-8"); - BufferedWriter sw = new BufferedWriter(writer)) { - tpl.merge(context, sw); - sw.flush(); - System.out.println("成功生成Java文件:" + filepath); - } - } catch (IOException e) { + try { + String targetPath = autoConfigModel.getParentPath(); + String filepath = getCoverFileName(template, tableInfo, autoCodeConfig.getConfigkey("parentPack"), targetPath); + Template tpl = Velocity.getTemplate(template, "UTF-8"); + File file = new File(filepath); + if (!file.getParentFile().exists()) + file.getParentFile().mkdirs(); + if (!file.exists()) + file.createNewFile(); + try (FileOutputStream outStream = new FileOutputStream(file); + OutputStreamWriter writer = new OutputStreamWriter(outStream, "UTF-8"); + BufferedWriter sw = new BufferedWriter(writer)) { + tpl.merge(context, sw); + sw.flush(); + System.out.println("成功生成Java文件:" + filepath); + } + } catch (IOException e) { try { - throw new Exception("渲染模板失败,表名:" +"c"+"\n"+e.getMessage()); - } catch (Exception e1) { - e1.printStackTrace(); - } + throw new Exception("渲染模板失败,表名:" + "c" + "\n" + e.getMessage()); + } catch (Exception e1) { + e1.printStackTrace(); + } } } - } - - + } - - /** - * 预览方法 - * @param tableInfo 数据库表 - * @return - * @author fuce - * @Date 2021年1月18日 上午2:10:55 - */ - public static Map viewAuto(TableInfo tableInfo,AutoConfigModel autoConfigModel){ - Map velocityMap=new HashMap(); - - AutoCodeConfig autoCodeConfig=new AutoCodeConfig(); - //设置velocity资源加载器 + /** + * 预览方法 + * + * @param tableInfo 数据库表 + * @return + * @author fuce + * @Date 2021年1月18日 上午2:10:55 + */ + public static Map viewAuto(TableInfo tableInfo, AutoConfigModel autoConfigModel) { + Map velocityMap = new HashMap(); + + AutoCodeConfig autoCodeConfig = new AutoCodeConfig(); + //设置velocity资源加载器 Properties prop = new Properties(); - prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + prop.put("file.resource.loader.class" , "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(prop); - Map map = new HashMap<>(); - //数据库表数据 - map.put("tableInfo",tableInfo); + Map map = new HashMap<>(); + //数据库表数据 + map.put("tableInfo" , tableInfo); //字段集合 - map.put("beanColumns",tableInfo.getBeanColumns()); + map.put("beanColumns" , tableInfo.getBeanColumns()); //配置文件 - map.put("SnowflakeIdWorker", SnowflakeIdWorker.class); + map.put("SnowflakeIdWorker" , SnowflakeIdWorker.class); //class类路径 - map.put("parentPack", autoCodeConfig.getConfigkey("parentPack")); + map.put("parentPack" , autoCodeConfig.getConfigkey("parentPack")); //作者 - map.put("author", autoConfigModel.getAuthor()); + map.put("author" , autoConfigModel.getAuthor()); //时间 - map.put("datetime",new DateTime()); + map.put("datetime" , new DateTime()); //sql需要的权限父级pid - map.put("pid",autoConfigModel.getPid()); - + map.put("pid" , autoConfigModel.getPid()); + VelocityContext velocityContext = new VelocityContext(map); //获取模板列表 List templates = getTemplates(); for (String template : templates) { - Template tpl = Velocity.getTemplate(template, "UTF-8" ); - StringWriter sw = new StringWriter(); - tpl.merge(velocityContext, sw); - System.out.println("输出模板"); - System.out.println(sw); - System.out.println("输出模板 end"); - velocityMap.put(template.substring(template.lastIndexOf("/")+1, template.lastIndexOf(".vm")), sw.toString()); + Template tpl = Velocity.getTemplate(template, "UTF-8"); + StringWriter sw = new StringWriter(); + tpl.merge(velocityContext, sw); + System.out.println("输出模板"); + System.out.println(sw); + System.out.println("输出模板 end"); + velocityMap.put(template.substring(template.lastIndexOf("/") + 1, template.lastIndexOf(".vm")), sw.toString()); } return velocityMap; - } - - - - - + } - /** - * 自动生成压缩文件方法 - * @param tableInfo - * @param zip - * @author fuce - * @Date 2021年1月17日 下午7:37:50 - */ - public static void autoCodeOneModel(TableInfo tableInfo,AutoConfigModel autoConfigModel,ZipOutputStream zip){ - AutoCodeConfig autoCodeConfig=new AutoCodeConfig(); - //设置velocity资源加载器 + /** + * 自动生成压缩文件方法 + * + * @param tableInfo + * @param zip + * @author fuce + * @Date 2021年1月17日 下午7:37:50 + */ + public static void autoCodeOneModel(TableInfo tableInfo, AutoConfigModel autoConfigModel, ZipOutputStream zip) { + AutoCodeConfig autoCodeConfig = new AutoCodeConfig(); + //设置velocity资源加载器 Properties prop = new Properties(); - prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" ); + prop.put("file.resource.loader.class" , "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(prop); - Map map = new HashMap<>(); + Map map = new HashMap<>(); //数据库表数据 - map.put("tableInfo",tableInfo); + map.put("tableInfo" , tableInfo); //字段集合 - map.put("beanColumns",tableInfo.getBeanColumns()); + map.put("beanColumns" , tableInfo.getBeanColumns()); //配置文件 - map.put("SnowflakeIdWorker", SnowflakeIdWorker.class); + map.put("SnowflakeIdWorker" , SnowflakeIdWorker.class); //class类路径 - map.put("parentPack", autoCodeConfig.getConfigkey("parentPack")); + map.put("parentPack" , autoCodeConfig.getConfigkey("parentPack")); //作者 - map.put("author", autoConfigModel.getAuthor()); + map.put("author" , autoConfigModel.getAuthor()); //时间 - map.put("datetime",new DateTime()); + map.put("datetime" , new DateTime()); //sql需要的权限父级pid - map.put("pid",autoConfigModel.getPid()); + map.put("pid" , autoConfigModel.getPid()); VelocityContext velocityContext = new VelocityContext(map); //获取模板列表 List templates = getTemplates(); for (String template : templates) { - try { - String filepath=getCoverFileName(template,tableInfo ,autoCodeConfig.getConfigkey("parentPack"),""); - Template tpl = Velocity.getTemplate(template, "UTF-8" ); - StringWriter sw = new StringWriter(); - tpl.merge(velocityContext, sw); - zip.putNextEntry(new ZipEntry(filepath)); - IOUtils.write(sw.toString(), zip, "UTF-8"); - IOUtils.closeQuietly(sw); - zip.closeEntry(); - } catch (IOException e) { + try { + String filepath = getCoverFileName(template, tableInfo, autoCodeConfig.getConfigkey("parentPack"), ""); + Template tpl = Velocity.getTemplate(template, "UTF-8"); + StringWriter sw = new StringWriter(); + tpl.merge(velocityContext, sw); + zip.putNextEntry(new ZipEntry(filepath)); + IOUtils.write(sw.toString(), zip, "UTF-8"); + IOUtils.closeQuietly(sw); + zip.closeEntry(); + } catch (IOException e) { try { - throw new Exception("渲染模板失败,表名:" +"c"+"\n"+e.getMessage()); - } catch (Exception e1) { - e1.printStackTrace(); - } + throw new Exception("渲染模板失败,表名:" + "c" + "\n" + e.getMessage()); + } catch (Exception e1) { + e1.printStackTrace(); + } } } - } - - + } + - /** - * - * @param template - * @param classname - * @param className - * @param packageName - * @param moduleName - * @param controller - * @return - * @author fuce - * @Date 2021年1月17日 下午6:40:57 - */ - public static String getCoverFileName(String template,TableInfo tableInfo, String packageName,String targetPath) { - - String separator=File.separator; - String packagePath =targetPath+separator+"src"+separator + "main" + separator + "java" + separator; - String resourcesPath=targetPath+separator+"src"+separator + "main" + separator+"resources"+ separator;; + /** + * @param template + * @param classname + * @param className + * @param packageName + * @param moduleName + * @param controller + * @return + * @author fuce + * @Date 2021年1月17日 下午6:40:57 + */ + public static String getCoverFileName(String template, TableInfo tableInfo, String packageName, String targetPath) { + + String separator = File.separator; + String packagePath = targetPath + separator + "src" + separator + "main" + separator + "java" + separator; + String resourcesPath = targetPath + separator + "src" + separator + "main" + separator + "resources" + separator; + ; if (StringUtils.isNotBlank(packageName)) { - packagePath += packageName.replace(".", separator) + separator; + packagePath += packageName.replace("." , separator) + separator; } - if (template.contains("Entity.java.vm")) {//model.java - return packagePath+"model" +separator+ "auto" + separator + tableInfo.getJavaTableName() + ".java"; - } - if(template.contains("EntityExample.java.vm")) {//modelExample.java - return packagePath+"model" +separator+ "auto" + separator + tableInfo.getJavaTableName() + "Example.java"; + //model.java + if (template.contains("Entity.java.vm")) { + return packagePath + "model" + separator + "auto" + separator + tableInfo.getJavaTableName() + ".java"; } - - if (template.contains("EntityMapper.java.vm")) {//daomapper.java +// if(template.contains("EntityExample.java.vm")) {//modelExample.java +// return packagePath+"model" +separator+ "auto" + separator + tableInfo.getJavaTableName() + "Example.java"; +// } + + //daomapper.java + if (template.contains("EntityMapper.java.vm")) { return packagePath + "mapper" + separator + "auto" + separator + tableInfo.getJavaTableName() + "Mapper.java"; } - if (template.contains("EntityMapper.xml.vm")) {//daomapper.xml - return resourcesPath+"mybatis" + separator+"auto"+ separator + tableInfo.getJavaTableName() + "Mapper.xml"; + + //daomapper.xml + if (template.contains("EntityMapper.xml.vm")) { + return resourcesPath + "mybatis" + separator + "auto" + separator + tableInfo.getJavaTableName() + "Mapper.xml"; } - + if (template.contains("EntityService.java.vm")) { - return packagePath + "service" + separator + tableInfo.getJavaTableName() + "Service.java"; + return packagePath + "service" + separator + "I" + tableInfo.getJavaTableName() + "Service.java"; + } + + if (template.contains("EntityServiceImpl.java.vm")) { + return packagePath + "service" + separator + "impl" + separator + tableInfo.getJavaTableName() + "ServiceImpl.java"; } - if(template.contains("EntityController.java.vm")) { - return packagePath + "controller" + separator + "gen" + separator + tableInfo.getJavaTableName() + "Controller.java"; + + if (template.contains("EntityController.java.vm")) { + return packagePath + "controller" + separator + "admin" + separator + tableInfo.getJavaTableName() + "Controller.java"; } - if(template.contains("list.html.vm")) { - return resourcesPath+"templates"+separator + "gen"+separator + tableInfo.getJavaTableName_a()+separator +"list.html"; + + if (template.contains("list.html.vm")) { + return resourcesPath + "templates" + separator + "admin" + separator + tableInfo.getJavaTableName_a() + separator + "list.html"; } - if(template.contains("add.html.vm")) { - System.err.println(resourcesPath+"templates"+separator + "gen"+separator + tableInfo.getJavaTableName_a()+separator ); - return resourcesPath+"templates"+separator + "gen"+separator + tableInfo.getJavaTableName_a()+separator +"add.html"; + + if (template.contains("add.html.vm")) { + return resourcesPath + "templates" + separator + "admin" + separator + tableInfo.getJavaTableName_a() + separator + "add.html"; } - if(template.contains("edit.html.vm")) { - return resourcesPath+"templates"+separator + "gen"+separator + tableInfo.getJavaTableName_a()+separator +"edit.html"; + + if (template.contains("edit.html.vm")) { + return resourcesPath + "templates" + separator + "admin" + separator + tableInfo.getJavaTableName_a() + separator + "edit.html"; } - if(template.contains("menu.sql.vm")) { - return resourcesPath+"sql"+separator +"menu.sql"; + + if (template.contains("menu.sql.vm")) { + return resourcesPath + "sql" + separator + "menu.sql"; } return ""; } diff --git a/src/main/resources/auto_code/auto_code_config.properties b/src/main/resources/auto_code/auto_code_config.properties index 84d10e594c6796eab4b19daaafb29d8be6342615..1568710d2f11c8fb52a615d03b60f32ac5d66b6e 100644 --- a/src/main/resources/auto_code/auto_code_config.properties +++ b/src/main/resources/auto_code/auto_code_config.properties @@ -23,4 +23,4 @@ globalConfig: #resource位置 resources: src/main/resources #表前缀 - tablePrefix: t_ \ No newline at end of file + tablePrefix: \ No newline at end of file diff --git a/src/main/resources/auto_code/controller/EntityController.java.vm b/src/main/resources/auto_code/controller/EntityController.java.vm index 7cb86889f9f02880a1f4027103b9bf0c6b59645c..7af7a77ce97bf8750cc4a29bc0d98363703336f0 100644 --- a/src/main/resources/auto_code/controller/EntityController.java.vm +++ b/src/main/resources/auto_code/controller/EntityController.java.vm @@ -1,11 +1,14 @@ -package ${parentPack}.controller.gen; +package ${parentPack}.controller.admin; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import ${parentPack}.common.base.BaseController; import ${parentPack}.common.domain.AjaxResult; import ${parentPack}.common.domain.ResultTable; import ${parentPack}.model.custom.Tablepar; import ${parentPack}.model.auto.${tableInfo.javaTableName}; -import ${parentPack}.service.${tableInfo.javaTableName}Service; +import ${parentPack}.service.I${tableInfo.javaTableName}Service; +import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -30,153 +33,155 @@ import com.fc.v2.common.conf.oss.OssConfig; #end /** - * ${tableInfo.tableComment}Controller - * @ClassName: ${tableInfo.javaTableName}Controller + * ${tableInfo.tableComment} Controller + * * @author ${author} * @date ${datetime} */ @Api(value = "${tableInfo.tableComment}") @Controller @RequestMapping("/${tableInfo.javaTableName}Controller") -public class ${tableInfo.javaTableName}Controller extends BaseController{ - - private String prefix = "gen/${tableInfo.javaTableName_a}"; - - @Autowired - private ${tableInfo.javaTableName}Service ${tableInfo.javaTableName_a}Service; - - - /** - * ${tableInfo.tableComment}页面展示 - * @param model - * @return String - * @author ${author} - */ - @ApiOperation(value = "分页跳转", notes = "分页跳转") - @GetMapping("/view") - @RequiresPermissions("gen:${tableInfo.javaTableName_a}:view") +public class ${tableInfo.javaTableName}Controller extends BaseController { + + private String prefix = "admin/${tableInfo.javaTableName_a}"; + + @Autowired + private I${tableInfo.javaTableName}Service ${tableInfo.javaTableName_a}Service; + + + /** + * ${tableInfo.tableComment}页面展示 + * + * @param model + * @return String + */ + @ApiOperation(value = "分页跳转", notes = "分页跳转") + @GetMapping("/view") + @RequiresPermissions("system:${tableInfo.javaTableName_a}:view") #if($isupload==true) @OssConfig #end - public String view(ModelMap model) - { + public String view(ModelMap model) { return prefix + "/list"; } - - /** - * list集合 - * @param tablepar - * @param searchText - * @return - */ - //@Log(title = "${tableInfo.tableComment}", action = "111") - @ApiOperation(value = "分页跳转", notes = "分页跳转") - @GetMapping("/list") - @RequiresPermissions("gen:${tableInfo.javaTableName_a}:list") - @ResponseBody - public ResultTable list(Tablepar tablepar,${tableInfo.javaTableName} ${tableInfo.javaTableName_a}){ - PageInfo<${tableInfo.javaTableName}> page=${tableInfo.javaTableName_a}Service.list(tablepar,${tableInfo.javaTableName_a}) ; - return pageTable(page.getList(),page.getTotal()); - } - - /** + + /** + * list集合 + * + * @param tablepar + * @return ResultTable + */ + //@Log(title = "${tableInfo.tableComment}", action = "111") + @ApiOperation(value = "分页跳转", notes = "分页跳转") + @GetMapping("/list") + @RequiresPermissions("system:${tableInfo.javaTableName_a}:list") + @ResponseBody + public ResultTable list(Tablepar tablepar) { + QueryWrapper<${tableInfo.javaTableName}> queryWrapper = new QueryWrapper<${tableInfo.javaTableName}>(); + + if (StrUtil.isNotEmpty(tablepar.getSearchText())) { + queryWrapper.like("自定义", tablepar.getSearchText()); + } + + if (StrUtil.isNotEmpty(tablepar.getOrderByColumn())) { + queryWrapper.orderByAsc(tablepar.getOrderByColumn()); + } + + PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); + + PageInfo<${tableInfo.javaTableName}> page = new PageInfo<${tableInfo.javaTableName}>(${tableInfo.javaTableName_a}Service.select${tableInfo.javaTableName}List(queryWrapper)); + return pageTable(page.getList(), page.getTotal()); + + } + + /** * 新增跳转 + * + * @param modelMap + * @return */ - @ApiOperation(value = "新增跳转", notes = "新增跳转") + @ApiOperation(value = "新增跳转", notes = "新增跳转") @GetMapping("/add") #if($isupload==true) @OssConfig #end - public String add(ModelMap modelMap) - { + public String add(ModelMap modelMap) { return prefix + "/add"; } - + /** * 新增保存 - * @param + * + * @param ${tableInfo.javaTableName_a} * @return */ - //@Log(title = "${tableInfo.tableComment}新增", action = "111") - @ApiOperation(value = "新增", notes = "新增") - @PostMapping("/add") - @RequiresPermissions("gen:${tableInfo.javaTableName_a}:add") - @ResponseBody - public AjaxResult add(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}){ - int b=${tableInfo.javaTableName_a}Service.insertSelective(${tableInfo.javaTableName_a}); - if(b>0){ - return success(); - }else{ - return error(); - } - } - - /** - * ${tableInfo.tableComment}删除 - * @param ids - * @return - */ - //@Log(title = "${tableInfo.tableComment}删除", action = "111") - @ApiOperation(value = "删除", notes = "删除") - @DeleteMapping("/remove") - @RequiresPermissions("gen:${tableInfo.javaTableName_a}:remove") - @ResponseBody - public AjaxResult remove(String ids){ - int b=${tableInfo.javaTableName_a}Service.deleteByPrimaryKey(ids); - if(b>0){ - return success(); - }else{ - return error(); - } - } - - - /** - * 修改跳转 - * @param id - * @param mmap - * @return - */ - @ApiOperation(value = "修改跳转", notes = "修改跳转") - @GetMapping("/edit/{id}") + //@Log(title = "${tableInfo.tableComment}新增", action = "111") + @ApiOperation(value = "新增", notes = "新增") + @PostMapping("/add") + @RequiresPermissions("system:${tableInfo.javaTableName_a}:add") + @ResponseBody + public AjaxResult add(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + return toAjax(${tableInfo.javaTableName_a}Service.insert${tableInfo.javaTableName}(${tableInfo.javaTableName_a})); + } + + /** + * ${tableInfo.tableComment}删除 + * + * @param ids + * @return + */ + //@Log(title = "${tableInfo.tableComment}删除", action = "111") + @ApiOperation(value = "删除", notes = "删除") + @DeleteMapping("/remove") + @RequiresPermissions("system:${tableInfo.javaTableName_a}:remove") + @ResponseBody + public AjaxResult remove(String ids) { + return toAjax(${tableInfo.javaTableName_a}Service.delete${tableInfo.javaTableName}ByIds(ids)); + } + + + /** + * 修改跳转 + * + * @param id + * @param map + * @return + */ + @ApiOperation(value = "修改跳转", notes = "修改跳转") + @GetMapping("/edit/{id}") #if($isupload==true) @OssConfig #end - public String edit(@PathVariable("id") String id, ModelMap map) - { - map.put("${tableInfo.javaTableName}", ${tableInfo.javaTableName_a}Service.selectByPrimaryKey(id)); - + public String edit(@PathVariable("id") Long id, ModelMap map) { + map.put("${tableInfo.javaTableName}", ${tableInfo.javaTableName_a}Service.select${tableInfo.javaTableName}ById(id)); return prefix + "/edit"; } - - /** + + /** * 修改保存 + * + * @param ${tableInfo.javaTableName_a} + * @return */ //@Log(title = "${tableInfo.tableComment}修改", action = "111") - @ApiOperation(value = "修改保存", notes = "修改保存") - @RequiresPermissions("gen:${tableInfo.javaTableName_a}:edit") + @ApiOperation(value = "修改保存", notes = "修改保存") + @RequiresPermissions("system:${tableInfo.javaTableName_a}:edit") @PostMapping("/edit") @ResponseBody - public AjaxResult editSave(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) - { - return toAjax(${tableInfo.javaTableName_a}Service.updateByPrimaryKeySelective(${tableInfo.javaTableName_a})); + public AjaxResult editSave(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + return toAjax(${tableInfo.javaTableName_a}Service.update${tableInfo.javaTableName}(${tableInfo.javaTableName_a})); } - - - /** - * 修改状态 - * @param record - * @return - */ - @PutMapping("/updateVisible") - @ResponseBody - public AjaxResult updateVisible(@RequestBody ${tableInfo.javaTableName} ${tableInfo.javaTableName_a}){ - int i=${tableInfo.javaTableName_a}Service.updateVisible(${tableInfo.javaTableName_a}); - return toAjax(i); - } - - - + /** + * 修改状态 + * + * @param ${tableInfo.javaTableName_a} + * @return + */ + @PutMapping("/updateVisible") + @ResponseBody + public AjaxResult updateVisible(@RequestBody ${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + return toAjax(${tableInfo.javaTableName_a}Service.updateVisible(${tableInfo.javaTableName_a})); + } } diff --git a/src/main/resources/auto_code/html/add.html.vm b/src/main/resources/auto_code/html/add.html.vm index be846535c4bc532ddf6e62143d7423d7a289d99f..3380e36da9f91ae0fb8a7c0477f0767ed8d4a9fc 100644 --- a/src/main/resources/auto_code/html/add.html.vm +++ b/src/main/resources/auto_code/html/add.html.vm @@ -11,6 +11,7 @@ #set($isdate = false) #set($isupload = false) #foreach ($column in $beanColumns) +#if(!$tableInfo.isSuperColumn($column.beanName)) #if(${column.column_key} != 'PRI') #if(${column.htmlType} == 1) @@ -87,6 +88,7 @@ #end #end +#end #end diff --git a/src/main/resources/auto_code/html/edit.html.vm b/src/main/resources/auto_code/html/edit.html.vm index 6fcdf377fc990bee016fb54b082c319f92fbc6f2..b99bc10572257e0aa6612082f0f5fec11a4c97d1 100644 --- a/src/main/resources/auto_code/html/edit.html.vm +++ b/src/main/resources/auto_code/html/edit.html.vm @@ -10,6 +10,7 @@
#set($isdate = false) #foreach ($column in $beanColumns) +#if(!$tableInfo.isSuperColumn($column.beanName)) #if(${column.column_key} != 'PRI') #if(${column.htmlType} == 1) @@ -86,6 +87,7 @@
#end +#end #end diff --git a/src/main/resources/auto_code/html/list.html.vm b/src/main/resources/auto_code/html/list.html.vm index 39bf1516c2c1e44efe25e31d7c3b6b64b3619867..c7242c7374d83fe71ec122bfae90e2243d05a9e9 100644 --- a/src/main/resources/auto_code/html/list.html.vm +++ b/src/main/resources/auto_code/html/list.html.vm @@ -32,21 +32,21 @@ @@ -139,26 +139,22 @@ [ {type: 'checkbox'}, #foreach ($column in $beanColumns) +#if(!$tableInfo.isSuperColumn($column.beanName)) #if(${column.htmlType} == 1) - {title: '${column.column_comment}', field: '${column.beanName}', align: 'center'}, #elseif(${column.htmlType} == 2) - {title: '${column.column_comment}', field: '${column.beanName}', align: 'center',templet:function(d){ return selectDictLabel(${column.beanName}_list, d.${column.beanName}); }}, #elseif(${column.htmlType} == 3) - {title: '${column.column_comment}', field: '${column.beanName}', align: 'center',templet: '#${column.beanName}-enable'}, #elseif(${column.htmlType} == 5) - {title: '${column.column_comment}', field: '${column.beanName}', align: 'center',templet: '#${column.beanName}-img'}, #else - {title: '${column.column_comment}', field: '${column.beanName}', align: 'center'}, #end #end - +#end {title: '操作', toolbar: '#${tableInfo.javaTableName_a}-bar', align: 'center'} ] ] diff --git a/src/main/resources/auto_code/mapper/EntityMapper.java.vm b/src/main/resources/auto_code/mapper/EntityMapper.java.vm index 5b452f9c6049939d15decc09eb30ce8edc506f62..66a154391ad5188c1b76c63da8f0729c3dff830f 100644 --- a/src/main/resources/auto_code/mapper/EntityMapper.java.vm +++ b/src/main/resources/auto_code/mapper/EntityMapper.java.vm @@ -1,52 +1,32 @@ package ${parentPack}.mapper.auto; import ${parentPack}.model.auto.${tableInfo.javaTableName}; -import ${parentPack}.model.auto.${tableInfo.javaTableName}Example; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + import java.util.List; -import org.apache.ibatis.annotations.Param; /** - * ${tableInfo.tableComment} ${tableInfo.javaTableName}Mapper - * @author ${author}_自动生成 - * @email ${email} + * ${tableInfo.tableComment}Mapper接口 + * + * @author ${author} * @date ${datetime} */ -public interface ${tableInfo.javaTableName}Mapper { - #set( $pklag = false) - #set( $pk_javaType = '') - #foreach ($column in $beanColumns) - #if(${column.column_key} == 'PRI') - #set( $pklag = true ) - #set( $pk_javaType=$column.javaType) - #end - #end - - long countByExample(${tableInfo.javaTableName}Example example); - - int deleteByExample(${tableInfo.javaTableName}Example example); - #if(${pklag} == true) - - int deleteByPrimaryKey(${pk_javaType} id); - #end - - int insert(${tableInfo.javaTableName} record); - - int insertSelective(${tableInfo.javaTableName} record); - - List<${tableInfo.javaTableName}> selectByExample(${tableInfo.javaTableName}Example example); - #if(${pklag} == true) - - ${tableInfo.javaTableName} selectByPrimaryKey(${pk_javaType} id); - #end - - int updateByExampleSelective(@Param("record") ${tableInfo.javaTableName} record, @Param("example") ${tableInfo.javaTableName}Example example); - - int updateByExample(@Param("record") ${tableInfo.javaTableName} record, @Param("example") ${tableInfo.javaTableName}Example example); - #if(${pklag} == true) - - int updateByPrimaryKeySelective(${tableInfo.javaTableName} record); - - int updateByPrimaryKey(${tableInfo.javaTableName} record); - #end - +public interface ${tableInfo.javaTableName}Mapper extends BaseMapper<${tableInfo.javaTableName}> +{ + #set( $pklag = false) + #set( $pk_javaType = '') + #foreach ($column in $beanColumns) + #if(${column.column_key} == 'PRI') + #set( $pklag = true ) + #set( $pk_javaType=$column.javaType) + #end + #end + + /** + * 查询${tableInfo.tableComment}列表 + * + * @param ${tableInfo.javaTableName_a} + * @return ${tableInfo.javaTableName}集合 + */ + public List<${tableInfo.javaTableName}> select${tableInfo.javaTableName}List(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}); } \ No newline at end of file diff --git a/src/main/resources/auto_code/mapperxml/EntityMapper.xml.vm b/src/main/resources/auto_code/mapperxml/EntityMapper.xml.vm index 6a0171cec475d9574e743eb7940054a432032b58..c5c6131c9bd79742ba92e9d4faba8ad6558886eb 100644 --- a/src/main/resources/auto_code/mapperxml/EntityMapper.xml.vm +++ b/src/main/resources/auto_code/mapperxml/EntityMapper.xml.vm @@ -6,263 +6,22 @@ #end - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - #set( $lag = 0) - #foreach ($column in $beanColumns) - #if(($lag+1) >= (${beanColumns.size()})) - ${column.column_name} - #else - ${column.column_name}, - #end - #set( $lag = ($lag + 1) ) - #end - - - - -#foreach ($column in $beanColumns) -#if(${column.column_key} == 'PRI') - - - delete from ${tableInfo.tableName} - where ${column.column_name} = #{${column.beanName},jdbcType=${column.jdbcType}} - + + select#foreach($column in $beanColumns) $column.column_name#if($velocityCount != $columns.size()),#end#end from ${tableInfo.tableName} + + + - select count(*) from ${tableInfo.tableName} - - - + - - - update ${tableInfo.tableName} - - #foreach ($column in $beanColumns) - - ${column.column_name} = #{record.${column.beanName},jdbcType=${column.jdbcType}}, - - #end - - - - - - - - - - update ${tableInfo.tableName} - set - #set( $lag = 0) - #foreach ($column in $beanColumns) - #if(($lag+1)>=(${beanColumns.size()})) - - ${column.column_name} = #{record.${column.beanName},jdbcType=${column.jdbcType}} - #else - - ${column.column_name} = #{record.${column.beanName},jdbcType=${column.jdbcType}}, - #end - #set( $lag = $lag + 1 ) - #end - - - - - - - - #foreach ($column in $beanColumns) - #if(${column.column_key} == 'PRI') - - update ${tableInfo.tableName} - - #foreach ($column in $beanColumns) - #if(${column.column_key} != 'PRI') - - - ${column.column_name} = #{${column.beanName},jdbcType=${column.jdbcType}}, - - #end - #end - - - where - #foreach ($column in $beanColumns) - #if(${column.column_key} == 'PRI') - - ${column.column_name} = #{${column.beanName},jdbcType=${column.jdbcType}} - #end - #end - - - - #set( $prinum = 0) - #foreach ($column in $beanColumns) - #if(${column.column_key} != 'PRI') - #set( $prinum = $prinum + 1 ) - #end - #end - - - - update ${tableInfo.tableName} - set - #set( $lag = 0) - #foreach ($column in $beanColumns) - #if(${column.column_key} != 'PRI') - #if(($lag+1)>=(${prinum})) - - ${column.column_name} = #{${column.beanName},jdbcType=${column.jdbcType}} - #else - - ${column.column_name} = #{${column.beanName},jdbcType=${column.jdbcType}}, - #end - #set( $lag = $lag + 1 ) - #end - #end - - where - #foreach ($column in $beanColumns) - #if(${column.column_key} == 'PRI') - - ${column.column_name} = #{${column.beanName},jdbcType=${column.jdbcType}} - #end - #end - - - - #end - #end - \ No newline at end of file diff --git a/src/main/resources/auto_code/model/Entity.java.vm b/src/main/resources/auto_code/model/Entity.java.vm index 82f63e7541c37b3c39af2be01b337f8e5891c6e2..78bca532ebcf3beee34b665cd5cae39f17396ac6 100644 --- a/src/main/resources/auto_code/model/Entity.java.vm +++ b/src/main/resources/auto_code/model/Entity.java.vm @@ -1,30 +1,49 @@ package ${parentPack}.model.auto; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.date.DateUtil; -import java.util.Date; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.fc.v2.common.base.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.*; -public class ${tableInfo.javaTableName} implements Serializable { - private static final long serialVersionUID = 1L; +/** + * ${tableInfo.tableComment}对象 ${tableInfo.tableName} + * + * @author ${author} + * @date ${datetime} + */ +@TableName("${tableInfo.tableName}") +public class ${tableInfo.javaTableName} extends BaseEntity { + + private static final long serialVersionUID = 1L; #set($isdate = false) #foreach ($column in $beanColumns) +#if(!$tableInfo.isSuperColumn($column.beanName)) #if(${column.beanType} == "java.util.Date") #set($isdate =true) + /** ${column.column_comment} */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") @ApiModelProperty(value = "$column.column_comment") private ${column.javaType} ${column.beanName}; #else - + + /** ${column.column_comment} */ +#if(${column.column_key} == "PRI") + @TableId(type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) +#end @ApiModelProperty(value = "$column.column_comment") private ${column.javaType} ${column.beanName}; -#end +#end +#end #end #foreach ($column in $beanColumns) +#if(!$tableInfo.isSuperColumn($column.beanName)) #if($column.beanType == "java.util.String") @JsonProperty("${column.beanName}") public ${column.javaType} get${column.javaName}() { @@ -43,32 +62,45 @@ public class ${tableInfo.javaTableName} implements Serializable { public void set${column.javaName}(${column.javaType} ${column.beanName}) { this.${column.beanName} = ${column.beanName}; } -#end +#end +#end #end #set( $lag = 0) #set( $lagstr="") #foreach ($column in $beanColumns) - #if(($lag+1)>=(${beanColumns.size()})) +#if(!$tableInfo.isSuperColumn($column.beanName)) + #if(($lag+1+5)>=(${beanColumns.size()})) #set($lagstr = $lagstr+"${column.javaType} ${column.beanName}") #else #set($lagstr = $lagstr+"${column.javaType} ${column.beanName},") #end #set( $lag = $lag + 1 ) +#end #end public ${tableInfo.javaTableName}(${lagstr}) { - #foreach ($column in $beanColumns)## - +#foreach ($column in $beanColumns) +#if(!$tableInfo.isSuperColumn($column.beanName)) this.${column.beanName} = ${column.beanName}; - #end## - +#end +#end } public ${tableInfo.javaTableName}() { super(); } + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +#foreach ($column in $beanColumns) +#set($AttrName=$column.javaName) + .append("${column.beanName}", get${AttrName}()) +#end + .toString(); + } + #if(($isdate)==true) public String dateToStringConvert(Date date) { if(date!=null) { @@ -77,6 +109,4 @@ public class ${tableInfo.javaTableName} implements Serializable { return ""; } #end - - } \ No newline at end of file diff --git a/src/main/resources/auto_code/model/EntityExample.java.vm b/src/main/resources/auto_code/model/EntityExample.java.vm deleted file mode 100644 index c6dbbaa9810fae35cc4b6f70df48cf60d1091fee..0000000000000000000000000000000000000000 --- a/src/main/resources/auto_code/model/EntityExample.java.vm +++ /dev/null @@ -1,324 +0,0 @@ -package ${parentPack}.model.auto; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import cn.hutool.core.util.StrUtil; - -/** - * ${tableInfo.tableComment} ${tableInfo.javaTableName}Example - * @author ${author}_自动生成 - * @date ${datetime} - */ -public class ${tableInfo.javaTableName}Example { - - protected String orderByClause; - - protected boolean distinct; - - protected List oredCriteria; - - public ${tableInfo.javaTableName}Example() { - oredCriteria = new ArrayList(); - } - - public void setOrderByClause(String orderByClause) { - this.orderByClause = orderByClause; - } - - public String getOrderByClause() { - return orderByClause; - } - - public void setDistinct(boolean distinct) { - this.distinct = distinct; - } - - public boolean isDistinct() { - return distinct; - } - - public List getOredCriteria() { - return oredCriteria; - } - - public void or(Criteria criteria) { - oredCriteria.add(criteria); - } - - public Criteria or() { - Criteria criteria = createCriteriaInternal(); - oredCriteria.add(criteria); - return criteria; - } - - public Criteria createCriteria() { - Criteria criteria = createCriteriaInternal(); - if (oredCriteria.size() == 0) { - oredCriteria.add(criteria); - } - return criteria; - } - - protected Criteria createCriteriaInternal() { - Criteria criteria = new Criteria(); - return criteria; - } - - public void clear() { - oredCriteria.clear(); - orderByClause = null; - distinct = false; - } - - protected abstract static class GeneratedCriteria { - protected List criteria; - - protected GeneratedCriteria() { - super(); - criteria = new ArrayList(); - } - - public boolean isValid() { - return criteria.size() > 0; - } - - public List getAllCriteria() { - return criteria; - } - - public List getCriteria() { - return criteria; - } - - protected void addCriterion(String condition) { - if (condition == null) { - throw new RuntimeException("Value for condition cannot be null"); - } - criteria.add(new Criterion(condition)); - } - - protected void addCriterion(String condition, Object value, String property) { - if (value == null) { - throw new RuntimeException("Value for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value)); - } - - protected void addCriterion(String condition, Object value1, Object value2, String property) { - if (value1 == null || value2 == null) { - throw new RuntimeException("Between values for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value1, value2)); - } - - #foreach ($column in $beanColumns)## - - public Criteria and${column.javaName}IsNull() { - addCriterion("${column.column_name} is null"); - return (Criteria) this; - } - - public Criteria and${column.javaName}IsNotNull() { - addCriterion("${column.column_name} is not null"); - return (Criteria) this; - } - - public Criteria and${column.javaName}EqualTo(${column.javaType} value) { - addCriterion("${column.column_name} =", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}NotEqualTo(${column.javaType} value) { - addCriterion("${column.column_name} <>", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}GreaterThan(${column.javaType} value) { - addCriterion("${column.column_name} >", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}GreaterThanOrEqualTo(${column.javaType} value) { - addCriterion("${column.column_name} >=", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}LessThan(${column.javaType} value) { - addCriterion("${column.column_name} <", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}LessThanOrEqualTo(${column.javaType} value) { - addCriterion("${column.column_name} <=", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}Like(${column.javaType} value) { - addCriterion("${column.column_name} like", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}NotLike(${column.javaType} value) { - addCriterion("${column.column_name} not like", value, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}In(List<${column.javaType}> values) { - addCriterion("${column.column_name} in", values, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}NotIn(List<${column.javaType}> values) { - addCriterion("${column.column_name} not in", values, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}Between(${column.javaType} value1, ${column.javaType} value2) { - addCriterion("${column.column_name} between", value1, value2, "${column.beanName}"); - return (Criteria) this; - } - - public Criteria and${column.javaName}NotBetween(${column.javaType} value1, ${column.javaType} value2) { - addCriterion("${column.column_name} not between", value1, value2, "${column.beanName}"); - return (Criteria) this; - } - - #end## - - public Criteria andLikeQuery(${tableInfo.javaTableName} record) { - List list= new ArrayList(); - List list2= new ArrayList(); - StringBuffer buffer=new StringBuffer(); -#foreach ($column in $beanColumns)## - if(record.get${column.javaName}()!=null&&StrUtil.isNotEmpty(record.get${column.javaName}().toString())) { - list.add("ifnull(${column.column_name},'')"); - } -#end## -#foreach ($column in $beanColumns)## - if(record.get${column.javaName}()!=null&&StrUtil.isNotEmpty(record.get${column.javaName}().toString())) { - list2.add("'%"+record.get${column.javaName}()+"%'"); - } -#end## - buffer.append(" CONCAT("); - buffer.append(StrUtil.join(",",list)); - buffer.append(")"); - buffer.append(" like CONCAT("); - buffer.append(StrUtil.join(",",list2)); - buffer.append(")"); - if(!" CONCAT() like CONCAT()".equals(buffer.toString())) { - addCriterion(buffer.toString()); - } - return (Criteria) this; - } - - public Criteria andLikeQuery2(String searchText) { - List list= new ArrayList(); - StringBuffer buffer=new StringBuffer(); -#foreach ($column in $beanColumns)## - list.add("ifnull(${column.column_name},'')"); -#end## - buffer.append(" CONCAT("); - buffer.append(StrUtil.join(",",list)); - buffer.append(")"); - buffer.append("like '%"); - buffer.append(searchText); - buffer.append("%'"); - addCriterion(buffer.toString()); - return (Criteria) this; - } - -} - - public static class Criteria extends GeneratedCriteria { - protected Criteria() { - super(); - } - } - - public static class Criterion { - private String condition; - - private Object value; - - private Object secondValue; - - private boolean noValue; - - private boolean singleValue; - - private boolean betweenValue; - - private boolean listValue; - - private String typeHandler; - - public String getCondition() { - return condition; - } - - public Object getValue() { - return value; - } - - public Object getSecondValue() { - return secondValue; - } - - public boolean isNoValue() { - return noValue; - } - - public boolean isSingleValue() { - return singleValue; - } - - public boolean isBetweenValue() { - return betweenValue; - } - - public boolean isListValue() { - return listValue; - } - - public String getTypeHandler() { - return typeHandler; - } - - protected Criterion(String condition) { - super(); - this.condition = condition; - this.typeHandler = null; - this.noValue = true; - } - - protected Criterion(String condition, Object value, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.typeHandler = typeHandler; - if (value instanceof List) { - this.listValue = true; - } else { - this.singleValue = true; - } - } - - protected Criterion(String condition, Object value) { - this(condition, value, null); - } - - protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.secondValue = secondValue; - this.typeHandler = typeHandler; - this.betweenValue = true; - } - - protected Criterion(String condition, Object value, Object secondValue) { - this(condition, value, secondValue, null); - } - } -} \ No newline at end of file diff --git a/src/main/resources/auto_code/service/EntityService.java.vm b/src/main/resources/auto_code/service/EntityService.java.vm index d8795e992630f9ca74c47b466473e0527e23b309..1e5eeef6992c5c60962f278037922d2aca417814 100644 --- a/src/main/resources/auto_code/service/EntityService.java.vm +++ b/src/main/resources/auto_code/service/EntityService.java.vm @@ -1,191 +1,91 @@ package ${parentPack}.service; -import java.util.List; -import java.util.Arrays; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import cn.hutool.core.util.StrUtil; -import ${parentPack}.common.base.BaseService; -import ${parentPack}.common.support.ConvertUtil; -import ${parentPack}.mapper.auto.${tableInfo.javaTableName}Mapper; import ${parentPack}.model.auto.${tableInfo.javaTableName}; -import ${parentPack}.model.auto.${tableInfo.javaTableName}Example; -import ${parentPack}.model.custom.Tablepar; -import ${parentPack}.util.SnowflakeIdWorker; -import ${parentPack}.util.StringUtils; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; /** - * ${tableInfo.tableComment} ${tableInfo.javaTableName}Service - * @Title: ${tableInfo.javaTableName}Service.java  - * @Package ${parentPack}.service  - * @author ${author}_自动生成 - * @email ${email} - * @date ${datetime}   - **/ -@Service -public class ${tableInfo.javaTableName}Service implements BaseService<${tableInfo.javaTableName}, ${tableInfo.javaTableName}Example>{ - @Autowired - private ${tableInfo.javaTableName}Mapper ${tableInfo.javaTableName_a}Mapper; - - #set( $pklag = false) - #set( $pkfield = '' ) - #set( $pk_column_name = '' ) - #set( $pk_attrType = '') - #foreach ($column in $beanColumns) - #if(${column.column_key} == 'PRI') - #set( $pklag = true ) - #set( $pkfield = $column.javaName ) - #set( $pk_column_name=$column.column_name) - #set( $pk_attrType=$column.javaType) - #end - #end - + * ${tableInfo.tableComment}Service接口 + * + * @author ${author} + * @date ${datetime} +*/ +public interface I${tableInfo.javaTableName}Service extends IService<${tableInfo.javaTableName}>{ + #set( $pklag = false) + #set( $pkfield = '' ) + #set( $pk_column_name = '' ) + #set( $pk_attrType = '') + #foreach ($column in $beanColumns) + #if(${column.column_key} == 'PRI') + #set( $pklag = true ) + #set( $pkfield = $column.javaName ) + #set( $pk_column_name=$column.column_name) + #set( $pk_attrType=$column.javaType) + #end + #end + /** - * 分页查询 - * @param pageNum - * @param pageSize - * @return + * 查询${tableInfo.tableComment} + * + * @param id + * @return ${tableInfo.javaTableName} */ - public PageInfo<${tableInfo.javaTableName}> list(Tablepar tablepar,${tableInfo.javaTableName} ${tableInfo.javaTableName_a}){ - ${tableInfo.javaTableName}Example testExample=new ${tableInfo.javaTableName}Example(); - //搜索 - if(StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体 - testExample.createCriteria().andLikeQuery2(tablepar.getSearchText()); - }else {//大搜索 - testExample.createCriteria().andLikeQuery(${tableInfo.javaTableName_a}); - } - //表格排序 - //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) { - // testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc()); - //}else{ - // testExample.setOrderByClause("${pk_column_name} ASC"); - //} - PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); - List<${tableInfo.javaTableName}> list= ${tableInfo.javaTableName_a}Mapper.selectByExample(testExample); - PageInfo<${tableInfo.javaTableName}> pageInfo = new PageInfo<${tableInfo.javaTableName}>(list); - return pageInfo; - } -#if(${pklag} == true) + public ${tableInfo.javaTableName} select${tableInfo.javaTableName}ById(${pk_attrType} id); - @Override - public int deleteByPrimaryKey(String ids) { - #if(${pk_attrType} == 'String') - - List lista=ConvertUtil.toListStrArray(ids); - ${tableInfo.javaTableName}Example example=new ${tableInfo.javaTableName}Example(); - example.createCriteria().and${pkfield}In(lista); - return ${tableInfo.javaTableName_a}Mapper.deleteByExample(example); - - #elseif(${pk_attrType} == 'Long') - - Long[] integers = ConvertUtil.toLongArray(",", ids); - List stringB = Arrays.asList(integers); - ${tableInfo.javaTableName}Example example=new ${tableInfo.javaTableName}Example(); - example.createCriteria().and${pkfield}In(stringB); - return ${tableInfo.javaTableName_a}Mapper.deleteByExample(example); - - #else - - Integer[] integers = ConvertUtil.toIntArray(",", ids); - List stringB = Arrays.asList(integers); - ${tableInfo.javaTableName}Example example=new ${tableInfo.javaTableName}Example(); - example.createCriteria().and${pkfield}In(stringB); - return ${tableInfo.javaTableName_a}Mapper.deleteByExample(example); - - #end - - } - - - @Override - public ${tableInfo.javaTableName} selectByPrimaryKey(String id) { - #if(${pk_attrType} == 'String') - - return ${tableInfo.javaTableName_a}Mapper.selectByPrimaryKey(id); - #elseif(${pk_attrType} == 'Long') - - Long id1 = Long.valueOf(id); - return ${tableInfo.javaTableName_a}Mapper.selectByPrimaryKey(id1); - - #else - - Integer id1 = Integer.valueOf(id); - return ${tableInfo.javaTableName_a}Mapper.selectByPrimaryKey(id1); - #end - - } + /** + * 查询${tableInfo.tableComment}列表 + * + * @param queryWrapper + * @return ${tableInfo.javaTableName}集合 + */ + public List<${tableInfo.javaTableName}> select${tableInfo.javaTableName}List(Wrapper<${tableInfo.javaTableName}> queryWrapper); - - @Override - public int updateByPrimaryKeySelective(${tableInfo.javaTableName} record) { - return ${tableInfo.javaTableName_a}Mapper.updateByPrimaryKeySelective(record); - } - -#end - /** - * 添加 + * 查询${tableInfo.tableComment}列表 + * + * @param ${tableInfo.javaTableName_a} + * @return ${tableInfo.javaTableName}集合 */ - @Override - public int insertSelective(${tableInfo.javaTableName} record) { - #if(${pk_attrType} == 'String') - - //添加雪花主键id - record.set${pkfield}(SnowflakeIdWorker.getUUID()); - - #else - - record.set${pkfield}(null); - - #end - - return ${tableInfo.javaTableName_a}Mapper.insertSelective(record); - } - - - @Override - public int updateByExampleSelective(${tableInfo.javaTableName} record, ${tableInfo.javaTableName}Example example) { - - return ${tableInfo.javaTableName_a}Mapper.updateByExampleSelective(record, example); - } + public List<${tableInfo.javaTableName}> select${tableInfo.javaTableName}List(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}); - - @Override - public int updateByExample(${tableInfo.javaTableName} record, ${tableInfo.javaTableName}Example example) { - - return ${tableInfo.javaTableName_a}Mapper.updateByExample(record, example); - } + /** + * 新增${tableInfo.tableComment} + * + * @param ${tableInfo.javaTableName_a} + * @return 结果 + */ + public int insert${tableInfo.javaTableName}(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}); + + /** + * 修改${tableInfo.tableComment} + * + * @param ${tableInfo.javaTableName_a} + * @return 结果 + */ + public int update${tableInfo.javaTableName}(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}); - @Override - public List<${tableInfo.javaTableName}> selectByExample(${tableInfo.javaTableName}Example example) { - - return ${tableInfo.javaTableName_a}Mapper.selectByExample(example); - } + /** + * 批量删除${tableInfo.tableComment} + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int delete${tableInfo.javaTableName}ByIds(String ids); - - @Override - public long countByExample(${tableInfo.javaTableName}Example example) { - - return ${tableInfo.javaTableName_a}Mapper.countByExample(example); - } + /** + * 删除${tableInfo.tableComment}信息 + * + * @param id + * @return 结果 + */ + public int delete${tableInfo.javaTableName}ById(${pk_attrType} id); - - @Override - public int deleteByExample(${tableInfo.javaTableName}Example example) { - - return ${tableInfo.javaTableName_a}Mapper.deleteByExample(example); - } - /** * 修改权限状态展示或者不展示 * @param ${tableInfo.javaTableName_a} * @return */ - public int updateVisible(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { - return ${tableInfo.javaTableName_a}Mapper.updateByPrimaryKeySelective(${tableInfo.javaTableName_a}); - } - - + public int updateVisible(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}); } diff --git a/src/main/resources/auto_code/service/impl/EntityServiceImpl.java.vm b/src/main/resources/auto_code/service/impl/EntityServiceImpl.java.vm new file mode 100644 index 0000000000000000000000000000000000000000..e0b6c5b4c752449792771e42c5a81731174788b7 --- /dev/null +++ b/src/main/resources/auto_code/service/impl/EntityServiceImpl.java.vm @@ -0,0 +1,136 @@ +package ${parentPack}.service.impl; + +import java.util.List; +import java.util.Arrays; +import java.util.Map; + +import com.fc.v2.service.I${tableInfo.javaTableName}Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import ${parentPack}.common.support.ConvertUtil; +import ${parentPack}.mapper.auto.${tableInfo.javaTableName}Mapper; +import ${parentPack}.model.auto.${tableInfo.javaTableName}; +import cn.hutool.core.bean.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * ${tableInfo.tableComment}Service业务层处理 + * + * @author ${author} + * @date ${datetime} + */ +@Service +public class ${tableInfo.javaTableName}ServiceImpl extends ServiceImpl<${tableInfo.javaTableName}Mapper, ${tableInfo.javaTableName}> implements I${tableInfo.javaTableName}Service { + + private static final Logger logger = LoggerFactory.getLogger(${tableInfo.javaTableName}ServiceImpl.class); + + @Autowired + private ${tableInfo.javaTableName}Mapper ${tableInfo.javaTableName_a}Mapper; + #set( $pklag = false) + #set( $pkfield = '' ) + #set( $pk_column_name = '' ) + #set( $pk_attrType = '') + #foreach ($column in $beanColumns) + #if(${column.column_key} == 'PRI') + #set( $pklag = true ) + #set( $pkfield = $column.javaName ) + #set( $pk_column_name=$column.column_name) + #set( $pk_attrType=$column.javaType) + #end + #end + /** + * 查询${tableInfo.tableComment} + * + * @param id + * @return ${tableInfo.javaTableName} + */ + @Override + public ${tableInfo.javaTableName} select${tableInfo.javaTableName}ById(${pk_attrType} id) { + return this.baseMapper.selectById(id); + } + + /** + * 查询${tableInfo.tableComment}列表 + * + * @param queryWrapper + * @return ${tableInfo.javaTableName}集合 + */ + @Override + public List<${tableInfo.javaTableName}> select${tableInfo.javaTableName}List(Wrapper<${tableInfo.javaTableName}> queryWrapper) { + return this.baseMapper.selectList(queryWrapper); + } + + /** + * 查询${tableInfo.tableComment}列表 + * + * @param ${tableInfo.javaTableName_a} + * @return ${tableInfo.javaTableName}集合 + */ + @Override + public List<${tableInfo.javaTableName}> select${tableInfo.javaTableName}List(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + Map map = BeanUtil.beanToMap(${tableInfo.javaTableName_a}, true, true); + QueryWrapper<${tableInfo.javaTableName}> queryWrapper = new QueryWrapper<${tableInfo.javaTableName}>(); + queryWrapper.allEq(map,false); + return this.baseMapper.selectList(queryWrapper); + } + + /** + * 新增${tableInfo.tableComment} + * + * @param ${tableInfo.javaTableName_a} + * @return 结果 + */ + @Override + public int insert${tableInfo.javaTableName}(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + return this.baseMapper.insert(${tableInfo.javaTableName_a}); + } + + /** + * 修改${tableInfo.tableComment} + * + * @param ${tableInfo.javaTableName_a} + * @return 结果 + */ + @Override + public int update${tableInfo.javaTableName} (${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + return this.baseMapper.updateById(${tableInfo.javaTableName_a}); + } + + /** + * 批量删除${tableInfo.tableComment} + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int delete${tableInfo.javaTableName}ByIds(String ids) { + return this.baseMapper.deleteBatchIds(Arrays.asList(ConvertUtil.toStrArray(ids))); + } + + /** + * 删除${tableInfo.tableComment}信息 + * + * @param id + * @return 结果 + */ + @Override + public int delete${tableInfo.javaTableName}ById(${pk_attrType} id) { + return this.baseMapper.deleteById(id); + } + + /** + * 修改权限状态展示或者不展示 + * + * @param ${tableInfo.javaTableName_a} + * @return + */ + @Override + public int updateVisible(${tableInfo.javaTableName} ${tableInfo.javaTableName_a}) { + return this.baseMapper.updateById(${tableInfo.javaTableName_a}); + } +} diff --git a/src/main/resources/auto_code/sql/menu.sql.vm b/src/main/resources/auto_code/sql/menu.sql.vm index 6682500ca591aa7c465a03fda92c92258b9fe790..6d17d667345e8afb83617e187beab670ff4d9698 100644 --- a/src/main/resources/auto_code/sql/menu.sql.vm +++ b/src/main/resources/auto_code/sql/menu.sql.vm @@ -3,9 +3,10 @@ #set( $id2 = $!{SnowflakeIdWorker.getUUID()}) #set( $id3 = $!{SnowflakeIdWorker.getUUID()}) #set( $id4 = $!{SnowflakeIdWorker.getUUID()}) -INSERT INTO `t_sys_permission` VALUES ('${id}', '${tableInfo.tableComment}管理', '${tableInfo.tableComment}展示', '/${tableInfo.javaTableName}Controller/view','0', '${pid}', 'gen:${tableInfo.javaTableName_a}:view', 1, 'layui-icon layui-icon-face-smile', NULL,0) -,('${id1}', '${tableInfo.tableComment}集合', '${tableInfo.tableComment}集合', '/${tableInfo.javaTableName}Controller/list','0', '${id}', 'gen:${tableInfo.javaTableName_a}:list', 2, '', NULL,0) -,('${id2}', '${tableInfo.tableComment}添加', '${tableInfo.tableComment}添加', '/${tableInfo.javaTableName}Controller/add','0', '${id}', 'gen:${tableInfo.javaTableName_a}:add', 2, 'layui-icon layui-icon-add-1', NULL,0) -,('${id3}', '${tableInfo.tableComment}删除', '${tableInfo.tableComment}删除', '/${tableInfo.javaTableName}Controller/remove','0', '${id}', 'gen:${tableInfo.javaTableName_a}:remove', 2, 'layui-icon layui-icon-delete', NULL,0) -,('${id4}', '${tableInfo.tableComment}修改', '${tableInfo.tableComment}修改', '/${tableInfo.javaTableName}Controller/edit','0', '${id}', 'gen:${tableInfo.javaTableName_a}:edit', 2, 'layui-icon layui-icon-edit', NULL,0); +INSERT INTO `t_sys_permission` VALUES + (${id}, '${tableInfo.tableComment}管理', '${tableInfo.tableComment}展示', '/${tableInfo.javaTableName}Controller/view','0', '${pid}', 'system:${tableInfo.javaTableName_a}:view', 1, 'layui-icon layui-icon-face-smile', NULL,0, 'admin', sysdate(), NULL, NULL, NULL ) +,(${id1}, '${tableInfo.tableComment}集合', '${tableInfo.tableComment}集合', '/${tableInfo.javaTableName}Controller/list','0', '${id}', 'system:${tableInfo.javaTableName_a}:list', 2, '', NULL,0, 'admin', sysdate(), NULL, NULL, NULL) +,(${id2}, '${tableInfo.tableComment}添加', '${tableInfo.tableComment}添加', '/${tableInfo.javaTableName}Controller/add','0', '${id}', 'system:${tableInfo.javaTableName_a}:add', 2, 'layui-icon layui-icon-add-1', NULL,0, 'admin', sysdate(), NULL, NULL, NULL) +,(${id3}, '${tableInfo.tableComment}删除', '${tableInfo.tableComment}删除', '/${tableInfo.javaTableName}Controller/remove','0', '${id}', 'system:${tableInfo.javaTableName_a}:remove', 2, 'layui-icon layui-icon-delete', NULL,0, 'admin', sysdate(), NULL, NULL, NULL) +,(${id4}, '${tableInfo.tableComment}修改', '${tableInfo.tableComment}修改', '/${tableInfo.javaTableName}Controller/edit','0', '${id}', 'system:${tableInfo.javaTableName_a}:edit', 2, 'layui-icon layui-icon-edit', NULL,0, 'admin', sysdate(), NULL, NULL, NULL); diff --git a/src/main/resources/generator/MyBatisGenerator/1.bat b/src/main/resources/generator/MyBatisGenerator/1.bat deleted file mode 100644 index 3ce510d6dc049b5870335e74e3b9d49489e3a799..0000000000000000000000000000000000000000 --- a/src/main/resources/generator/MyBatisGenerator/1.bat +++ /dev/null @@ -1 +0,0 @@ -java -jar mybatis-generator-core-1.3.7.jar -configfile generator.xml -overwrite \ No newline at end of file diff --git a/src/main/resources/generator/MyBatisGenerator/generator.xml b/src/main/resources/generator/MyBatisGenerator/generator.xml deleted file mode 100644 index 59238ebf61bb782fa9e2b9bdb9edf7a917601d6c..0000000000000000000000000000000000000000 --- a/src/main/resources/generator/MyBatisGenerator/generator.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/generator/MyBatisGenerator/mybatis-generator-core-1.3.2.jar b/src/main/resources/generator/MyBatisGenerator/mybatis-generator-core-1.3.2.jar deleted file mode 100644 index 4cc961e3878d3defb3584bc82f36d3c7de76e7a0..0000000000000000000000000000000000000000 Binary files a/src/main/resources/generator/MyBatisGenerator/mybatis-generator-core-1.3.2.jar and /dev/null differ diff --git a/src/main/resources/generator/MyBatisGenerator/mybatis-generator-core-1.3.7.jar b/src/main/resources/generator/MyBatisGenerator/mybatis-generator-core-1.3.7.jar deleted file mode 100644 index 1e4f08dc94727be211ce07b63a30d92ab8df99ae..0000000000000000000000000000000000000000 Binary files a/src/main/resources/generator/MyBatisGenerator/mybatis-generator-core-1.3.7.jar and /dev/null differ diff --git a/src/main/resources/generator/MyBatisGenerator/mysqldriver.jar b/src/main/resources/generator/MyBatisGenerator/mysqldriver.jar deleted file mode 100644 index b9397711318137c8df2b10c1b67adef8fda15d7f..0000000000000000000000000000000000000000 Binary files a/src/main/resources/generator/MyBatisGenerator/mysqldriver.jar and /dev/null differ diff --git a/src/main/resources/templates/admin/permission/list.html b/src/main/resources/templates/admin/permission/list.html index e259ab0611b0b845a0e2e9b8e28fb05d72d81c7a..bcb520f4ba4038bca3eccf7e12670b992c471bc9 100644 --- a/src/main/resources/templates/admin/permission/list.html +++ b/src/main/resources/templates/admin/permission/list.html @@ -77,34 +77,30 @@ let MODULE_PATH = rootPath+"/PermissionController/"; - window.render = function () { - treetable.render({ - treeColIndex: 1, - treeSpid: 0, - treeIdName: 'id', - treePidName: 'parentId', - skin: 'line', - method: 'post', - treeDefaultClose: true, - toolbar: '#power-toolbar', - elem: '#power-table', - url: MODULE_PATH+'list', - page: false, - cols: [ - [ - {type: 'checkbox'}, - {field: 'name', minWidth: 200, title: '权限名称'}, - {field: 'icon', title: '图标', templet: '#icon'}, - {field: 'type', title: '权限类型', templet: '#power-type'}, - {field: 'visible', title: '是否可用', templet: '#power-enable'}, - {field: 'orderNum', title: '排序'}, - {title: '操作', templet: '#power-bar', width: 150, align: 'center'} - ] + treetable.render({ + treeColIndex: 1, + treeSpid: 0, + treeIdName: 'id', + treePidName: 'pid', + skin: 'line', + method: 'post', + treeDefaultClose: true, + toolbar: '#power-toolbar', + elem: '#power-table', + url: MODULE_PATH+'list', + page: false, + cols: [ + [ + {type: 'checkbox'}, + {field: 'name', minWidth: 200, title: '权限名称'}, + {field: 'icon', title: '图标', templet: '#icon'}, + {field: 'type', title: '权限类型', templet: '#power-type'}, + {field: 'visible', title: '是否可用', templet: '#power-enable'}, + {field: 'orderNum', title: '排序'}, + {title: '操作', templet: '#power-bar', width: 150, align: 'center'} ] - }); - } - - render(); + ] + }); form.on('submit(power-query)', function (data) { var keyword = data.field.powerName; diff --git a/src/main/resources/templates/admin/sysDepartment/list.html b/src/main/resources/templates/admin/sysDepartment/list.html index 02369331c713ab6178d8dd80d6fc2e3ed167ffc1..105bba1b063a176358017348b463e1509c26fa84 100644 --- a/src/main/resources/templates/admin/sysDepartment/list.html +++ b/src/main/resources/templates/admin/sysDepartment/list.html @@ -8,7 +8,7 @@
- +
@@ -66,35 +66,31 @@ let MODULE_PATH = rootPath+"/SysDepartmentController/"; - window.render = function () { - treetable.render({ - treeColIndex: 1, - treeSpid: 0, - treeIdName: 'id', - treePidName: 'parentId', - skin: 'line', - method: 'get', - treeDefaultClose: true, - toolbar: '#department-toolbar', - elem: '#department-table', - url: MODULE_PATH+'list', - page: false, - cols: [ - [ - {type: 'checkbox'}, - {field: 'deptName', minWidth: 200, title: '部门名称'}, - {field: 'leader', title: '部门负责人'}, - {field: 'phone', title: '电话'}, - {field: 'email', title: '邮箱'}, - {field: 'status', title: '状态',templet: '#department-enable'}, - {field: 'orderNum', title: '排序'}, - {title: '操作', templet: '#department-bar', width: 150, align: 'center'} - ] + treetable.render({ + treeColIndex: 1, + treeSpid: 0, + treeIdName: 'id', + treePidName: 'parentId', + skin: 'line', + method: 'get', + treeDefaultClose: true, + toolbar: '#department-toolbar', + elem: '#department-table', + url: MODULE_PATH+'list', + page: false, + cols: [ + [ + {type: 'checkbox'}, + {field: 'deptName', minWidth: 200, title: '部门名称'}, + {field: 'leader', title: '部门负责人'}, + {field: 'phone', title: '电话'}, + {field: 'email', title: '邮箱'}, + {field: 'status', title: '状态',templet: '#department-enable'}, + {field: 'orderNum', title: '排序'}, + {title: '操作', templet: '#department-bar', width: 150, align: 'center'} ] - }); - } - - render(); + ] + }); form.on('submit(department-query)', function (data) { var keyword = data.field.powerName;