fix:merge origin/master
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
<td><center><strong><a href="https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi" target="_blank">交流三群</a></strong></center></td>
|
<td><center><strong><a href="https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi" target="_blank">交流三群</a></strong></center></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi" target="_blank"><img width=250px height=300px alt="交流三群" src="http://qiniu.zlt2000.cn/blog/20210616/htVdgkFMohAm.png?imageslim"/></a></td>
|
<td><a href="https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi" target="_blank"><img width=250px height=300px alt="交流三群" src="https://gitee.com/zlt2000/images/raw/master/%E4%BA%A4%E6%B5%81%E4%B8%89%E7%BE%A4.png"/></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-business</artifactId>
|
|
||||||
<version>6.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>code-generator</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-log-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-common-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-db-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.velocity</groupId>
|
|
||||||
<artifactId>velocity</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-configuration2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.micrometer</groupId>
|
|
||||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-configuration</groupId>
|
|
||||||
<artifactId>commons-configuration</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.spotify</groupId>
|
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
|
|
||||||
<imageTags>
|
|
||||||
<imageTag>${project.version}</imageTag>
|
|
||||||
<imageTag>latest</imageTag>
|
|
||||||
</imageTags>
|
|
||||||
<forceTags>true</forceTags>
|
|
||||||
<baseImage>${docker.baseImage}</baseImage>
|
|
||||||
<volumes>${docker.volumes}</volumes>
|
|
||||||
<env>
|
|
||||||
<JAVA_OPTS>${docker.java.opts}</JAVA_OPTS>
|
|
||||||
</env>
|
|
||||||
<entryPoint>["sh","-c","java $JAVA_OPTS ${docker.java.security.egd} -jar /${project.build.finalName}.jar"]</entryPoint>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<targetPath>/</targetPath>
|
|
||||||
<directory>${project.build.directory}</directory>
|
|
||||||
<include>${project.build.finalName}.jar</include>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.central.generator;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zlt
|
|
||||||
*/
|
|
||||||
@EnableDiscoveryClient
|
|
||||||
@EnableFeignClients(basePackages = "com.central.generator")
|
|
||||||
@SpringBootApplication
|
|
||||||
public class CodeGeneratorApp {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(CodeGeneratorApp.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
package com.central.generator.controller;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.central.generator.service.SysGeneratorService;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: zlt
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@Tag(name = "代码生成器")
|
|
||||||
@RequestMapping("/generator")
|
|
||||||
public class SysGeneratorController {
|
|
||||||
@Autowired
|
|
||||||
private SysGeneratorService sysGeneratorService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
*/
|
|
||||||
@ResponseBody
|
|
||||||
@GetMapping("/list")
|
|
||||||
public PageResult getTableList(@RequestParam Map<String, Object> params) {
|
|
||||||
return sysGeneratorService.queryList(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码FileUtil
|
|
||||||
*/
|
|
||||||
@GetMapping("/code")
|
|
||||||
public void makeCode(String tables, HttpServletResponse response) throws IOException {
|
|
||||||
byte[] data = sysGeneratorService.generatorCode(tables.split(","));
|
|
||||||
response.reset();
|
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"generator.zip\"");
|
|
||||||
response.addHeader("Content-Length", "" + data.length);
|
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
|
||||||
IOUtils.write(data, response.getOutputStream());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
package com.central.generator.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.central.db.mapper.SuperMapper;
|
|
||||||
import com.central.generator.model.TableEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author zlt
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Mapper
|
|
||||||
public interface SysGeneratorMapper extends SuperMapper<TableEntity> {
|
|
||||||
List<Map<String, Object>> queryList(Page<Map<String, Object>> page, @Param("p") Map<String, Object> map);
|
|
||||||
|
|
||||||
int queryTotal(Map<String, Object> map);
|
|
||||||
|
|
||||||
Map<String, String> queryTable(String tableName);
|
|
||||||
|
|
||||||
List<Map<String, String>> queryColumns(String tableName);
|
|
||||||
}
|
|
||||||
-91
@@ -1,91 +0,0 @@
|
|||||||
package com.central.generator.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: zlt
|
|
||||||
*/
|
|
||||||
public class ColumnEntity {
|
|
||||||
/**
|
|
||||||
* 列名
|
|
||||||
*/
|
|
||||||
private String columnName;
|
|
||||||
/**
|
|
||||||
* 列名类型
|
|
||||||
*/
|
|
||||||
private String dataType;
|
|
||||||
/**
|
|
||||||
* 列名备注
|
|
||||||
*/
|
|
||||||
private String comments;
|
|
||||||
/**
|
|
||||||
* 属性名称(第一个字母大写),如:user_name => UserName
|
|
||||||
*/
|
|
||||||
private String attrName;
|
|
||||||
/**
|
|
||||||
* 属性名称(第一个字母小写),如:user_name => userName
|
|
||||||
*/
|
|
||||||
private String attrname;
|
|
||||||
/**
|
|
||||||
* 属性类型
|
|
||||||
*/
|
|
||||||
private String attrType;
|
|
||||||
/**
|
|
||||||
* auto_increment
|
|
||||||
*/
|
|
||||||
private String extra;
|
|
||||||
|
|
||||||
public String getColumnName() {
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnName(String columnName) {
|
|
||||||
this.columnName = columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDataType() {
|
|
||||||
return dataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataType(String dataType) {
|
|
||||||
this.dataType = dataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComments() {
|
|
||||||
return comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComments(String comments) {
|
|
||||||
this.comments = comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAttrName() {
|
|
||||||
return attrName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttrName(String attrName) {
|
|
||||||
this.attrName = attrName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAttrname() {
|
|
||||||
return attrname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttrname(String attrname) {
|
|
||||||
this.attrname = attrname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAttrType() {
|
|
||||||
return attrType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttrType(String attrType) {
|
|
||||||
this.attrType = attrType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExtra() {
|
|
||||||
return extra;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExtra(String extra) {
|
|
||||||
this.extra = extra;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-81
@@ -1,81 +0,0 @@
|
|||||||
package com.central.generator.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: zlt
|
|
||||||
*/
|
|
||||||
public class TableEntity {
|
|
||||||
/**
|
|
||||||
* 表的名称
|
|
||||||
*/
|
|
||||||
private String tableName;
|
|
||||||
/**
|
|
||||||
* 表的备注
|
|
||||||
*/
|
|
||||||
private String comments;
|
|
||||||
/**
|
|
||||||
* 表的主键
|
|
||||||
*/
|
|
||||||
private ColumnEntity pk;
|
|
||||||
/**
|
|
||||||
* 表的列名(不包含主键)
|
|
||||||
*/
|
|
||||||
private List<ColumnEntity> columns;
|
|
||||||
/**
|
|
||||||
* 类名(第一个字母大写),如:sys_user => SysUser
|
|
||||||
*/
|
|
||||||
private String className;
|
|
||||||
/**
|
|
||||||
* 类名(第一个字母小写),如:sys_user => sysUser
|
|
||||||
*/
|
|
||||||
private String classname;
|
|
||||||
|
|
||||||
public String getTableName() {
|
|
||||||
return tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableName(String tableName) {
|
|
||||||
this.tableName = tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComments() {
|
|
||||||
return comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComments(String comments) {
|
|
||||||
this.comments = comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColumnEntity getPk() {
|
|
||||||
return pk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPk(ColumnEntity pk) {
|
|
||||||
this.pk = pk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ColumnEntity> getColumns() {
|
|
||||||
return columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumns(List<ColumnEntity> columns) {
|
|
||||||
this.columns = columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName() {
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassName(String className) {
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassname() {
|
|
||||||
return classname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassname(String classname) {
|
|
||||||
this.classname = classname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.central.generator.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.central.generator.model.TableEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author zlt
|
|
||||||
*/
|
|
||||||
public interface SysGeneratorService extends IService<TableEntity> {
|
|
||||||
PageResult queryList(Map<String, Object> map);
|
|
||||||
|
|
||||||
Map<String, String> queryTable(String tableName);
|
|
||||||
|
|
||||||
List<Map<String, String>> queryColumns(String tableName);
|
|
||||||
|
|
||||||
byte[] generatorCode(String[] tableNames);
|
|
||||||
}
|
|
||||||
-68
@@ -1,68 +0,0 @@
|
|||||||
package com.central.generator.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.central.generator.mapper.SysGeneratorMapper;
|
|
||||||
import com.central.generator.model.TableEntity;
|
|
||||||
import com.central.generator.service.SysGeneratorService;
|
|
||||||
import com.central.generator.utils.GenUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author zlt
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
public class SysGeneratorServiceImpl extends ServiceImpl<SysGeneratorMapper, TableEntity> implements SysGeneratorService {
|
|
||||||
@Autowired
|
|
||||||
private SysGeneratorMapper sysGeneratorMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<Map<String, Object>> queryList(Map<String, Object> map) {
|
|
||||||
Page<Map<String, Object>> page = new Page<>(MapUtils.getInteger(map, "page"), MapUtils.getInteger(map, "limit"));
|
|
||||||
|
|
||||||
List<Map<String, Object>> list = sysGeneratorMapper.queryList(page, map);
|
|
||||||
return PageResult.<Map<String, Object>>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> queryTable(String tableName) {
|
|
||||||
return sysGeneratorMapper.queryTable(tableName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Map<String, String>> queryColumns(String tableName) {
|
|
||||||
return sysGeneratorMapper.queryColumns(tableName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] generatorCode(String[] tableNames) {
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
try (
|
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream)
|
|
||||||
) {
|
|
||||||
for (String tableName : tableNames) {
|
|
||||||
//查询表信息
|
|
||||||
Map<String, String> table = queryTable(tableName);
|
|
||||||
//查询列信息
|
|
||||||
List<Map<String, String>> columns = queryColumns(tableName);
|
|
||||||
//生成代码
|
|
||||||
GenUtils.generatorCode(table, columns, zip);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("generatorCode-error: ", e);
|
|
||||||
}
|
|
||||||
return outputStream.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
package com.central.generator.utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.central.common.constant.CommonConstant;
|
|
||||||
import com.central.generator.model.ColumnEntity;
|
|
||||||
import com.central.generator.model.TableEntity;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.configuration.Configuration;
|
|
||||||
import org.apache.commons.configuration.ConfigurationException;
|
|
||||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.commons.lang.WordUtils;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.velocity.Template;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import org.apache.velocity.app.Velocity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成器工具类
|
|
||||||
*
|
|
||||||
* @author zlt
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class GenUtils {
|
|
||||||
private GenUtils() {
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static String FILE_NAME_MODEL = "Model.java.vm";
|
|
||||||
private final static String FILE_NAME_MAPPER = "Mapper.java.vm";
|
|
||||||
private final static String FILE_NAME_MAPPERXML = "Mapper.xml.vm";
|
|
||||||
private final static String FILE_NAME_SERVICE = "Service.java.vm";
|
|
||||||
private final static String FILE_NAME_SERVICEIMPL = "ServiceImpl.java.vm";
|
|
||||||
private final static String FILE_NAME_CONTROLLER = "Controller.java.vm";
|
|
||||||
private final static String FILE_NAME_PAGE = "index.html.vm";
|
|
||||||
private final static String TEMPLATE_PATH = "template/";
|
|
||||||
private final static String PACKAGE = "package";
|
|
||||||
private final static String MODULE_NAME = "moduleName";
|
|
||||||
|
|
||||||
public static List<String> getTemplates() {
|
|
||||||
List<String> templates = new ArrayList<>();
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_MODEL);
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_MAPPER);
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_MAPPERXML);
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_SERVICE);
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_SERVICEIMPL);
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_CONTROLLER);
|
|
||||||
|
|
||||||
templates.add(TEMPLATE_PATH+FILE_NAME_PAGE);
|
|
||||||
|
|
||||||
return templates;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码
|
|
||||||
*/
|
|
||||||
public static void generatorCode(Map<String, String> table,
|
|
||||||
List<Map<String, String>> columns, ZipOutputStream zip) {
|
|
||||||
//配置信息
|
|
||||||
Configuration config = getConfig();
|
|
||||||
boolean hasBigDecimal = false;
|
|
||||||
//表信息
|
|
||||||
TableEntity tableEntity = new TableEntity();
|
|
||||||
tableEntity.setTableName(table.get("tableName"));
|
|
||||||
tableEntity.setComments(table.get("tableComment"));
|
|
||||||
//表名转换成Java类名
|
|
||||||
String className = tableToJava(tableEntity.getTableName(), config.getString("tablePrefix"));
|
|
||||||
tableEntity.setClassName(className);
|
|
||||||
tableEntity.setClassname(StringUtils.uncapitalize(className));
|
|
||||||
|
|
||||||
//列信息
|
|
||||||
List<ColumnEntity> columsList = new ArrayList<>();
|
|
||||||
for (Map<String, String> column : columns) {
|
|
||||||
ColumnEntity columnEntity = new ColumnEntity();
|
|
||||||
columnEntity.setColumnName(column.get("columnName"));
|
|
||||||
columnEntity.setDataType(column.get("dataType"));
|
|
||||||
columnEntity.setComments(column.get("columnComment"));
|
|
||||||
columnEntity.setExtra(column.get("extra"));
|
|
||||||
|
|
||||||
//列名转换成Java属性名
|
|
||||||
String attrName = columnToJava(columnEntity.getColumnName());
|
|
||||||
columnEntity.setAttrName(attrName);
|
|
||||||
columnEntity.setAttrname(StringUtils.uncapitalize(attrName));
|
|
||||||
|
|
||||||
//列的数据类型,转换成Java类型
|
|
||||||
String attrType = config.getString(columnEntity.getDataType(), "unknowType");
|
|
||||||
columnEntity.setAttrType(attrType);
|
|
||||||
if (!hasBigDecimal && "BigDecimal".equals(attrType)) {
|
|
||||||
hasBigDecimal = true;
|
|
||||||
}
|
|
||||||
//是否主键
|
|
||||||
if ("PRI".equalsIgnoreCase(column.get("columnKey")) && tableEntity.getPk() == null) {
|
|
||||||
tableEntity.setPk(columnEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
columsList.add(columnEntity);
|
|
||||||
}
|
|
||||||
tableEntity.setColumns(columsList);
|
|
||||||
|
|
||||||
//没主键,则第一个字段为主键
|
|
||||||
if (tableEntity.getPk() == null) {
|
|
||||||
tableEntity.setPk(tableEntity.getColumns().get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置velocity资源加载器
|
|
||||||
Properties prop = new Properties();
|
|
||||||
prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
|
||||||
Velocity.init(prop);
|
|
||||||
String mainPath = config.getString("mainPath");
|
|
||||||
mainPath = StringUtils.isBlank(mainPath) ? "io.renren" : mainPath;
|
|
||||||
//封装模板数据
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("tableName", tableEntity.getTableName());
|
|
||||||
map.put("comments", tableEntity.getComments());
|
|
||||||
map.put("pk", tableEntity.getPk());
|
|
||||||
map.put("className", tableEntity.getClassName());
|
|
||||||
map.put("classname", tableEntity.getClassname());
|
|
||||||
map.put("pathName", tableEntity.getClassname().toLowerCase());
|
|
||||||
map.put("columns", tableEntity.getColumns());
|
|
||||||
map.put("hasBigDecimal", hasBigDecimal);
|
|
||||||
map.put("mainPath", mainPath);
|
|
||||||
map.put(PACKAGE, config.getString(PACKAGE));
|
|
||||||
map.put(MODULE_NAME, config.getString(MODULE_NAME));
|
|
||||||
map.put("author", config.getString("author"));
|
|
||||||
map.put("email", config.getString("email"));
|
|
||||||
map.put("datetime", DateUtil.format(new Date(), CommonConstant.DATETIME_FORMAT));
|
|
||||||
VelocityContext context = new VelocityContext(map);
|
|
||||||
|
|
||||||
//获取模板列表
|
|
||||||
List<String> templates = getTemplates();
|
|
||||||
for (String template : templates) {
|
|
||||||
//渲染模板
|
|
||||||
try (
|
|
||||||
StringWriter sw = new StringWriter()
|
|
||||||
) {
|
|
||||||
Template tpl = Velocity.getTemplate(template, "UTF-8");
|
|
||||||
tpl.merge(context, sw);
|
|
||||||
|
|
||||||
//添加到zip
|
|
||||||
zip.putNextEntry(new ZipEntry(getFileName(template, tableEntity.getClassName(), config.getString(PACKAGE), config.getString(MODULE_NAME))));
|
|
||||||
IOUtils.write(sw.toString(), zip, StandardCharsets.UTF_8);
|
|
||||||
zip.closeEntry();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("generatorCode-error", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列名转换成Java属性名
|
|
||||||
*/
|
|
||||||
public static String columnToJava(String columnName) {
|
|
||||||
return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表名转换成Java类名
|
|
||||||
*/
|
|
||||||
public static String tableToJava(String tableName, String tablePrefix) {
|
|
||||||
if (StringUtils.isNotBlank(tablePrefix)) {
|
|
||||||
tableName = tableName.substring(tablePrefix.length());
|
|
||||||
}
|
|
||||||
return columnToJava(tableName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取配置信息
|
|
||||||
*/
|
|
||||||
public static Configuration getConfig() {
|
|
||||||
try {
|
|
||||||
return new PropertiesConfiguration("generator.properties");
|
|
||||||
} catch (ConfigurationException e) {
|
|
||||||
throw new RuntimeException("获取配置文件失败,", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件名
|
|
||||||
*/
|
|
||||||
public static String getFileName(String template, String className, String packageName, String moduleName) {
|
|
||||||
String packagePath = "main" + File.separator + "java" + File.separator;
|
|
||||||
if (StringUtils.isNotBlank(packageName)) {
|
|
||||||
packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_MODEL)) {
|
|
||||||
return packagePath + "model" + File.separator + className + ".java";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_MAPPER)) {
|
|
||||||
return packagePath + "mapper" + File.separator + className + "Mapper.java";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_SERVICE)) {
|
|
||||||
return packagePath + "service" + File.separator + "I" + className + "Service.java";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_SERVICEIMPL)) {
|
|
||||||
return packagePath + "service" + File.separator + "impl" + File.separator + className + "ServiceImpl.java";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_CONTROLLER)) {
|
|
||||||
return packagePath + "controller" + File.separator + className + "Controller.java";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_MAPPERXML)) {
|
|
||||||
return "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.contains(FILE_NAME_PAGE)) {
|
|
||||||
return "main" + File.separator + "view" + File.separator + "pages" +
|
|
||||||
File.separator + moduleName + File.separator + "index.html";
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
spring:
|
|
||||||
datasource:
|
|
||||||
url: jdbc:mysql://${zlt.datasource.ip}/order-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
|
||||||
username: ${zlt.datasource.username}
|
|
||||||
password: ${zlt.datasource.password}
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
|
|
||||||
mybatis-plus:
|
|
||||||
mapper-locations: classpath:/mapper/*Mapper.xml
|
|
||||||
#实体扫描,多个package用逗号或者分号分隔
|
|
||||||
typeAliasesPackage: com.central.generator.model
|
|
||||||
|
|
||||||
springdoc:
|
|
||||||
group-configs:
|
|
||||||
- group: 'code'
|
|
||||||
paths-to-match: '/**'
|
|
||||||
packages-to-scan: com.central.generator.controller
|
|
||||||
|
|
||||||
knife4j:
|
|
||||||
enable: true
|
|
||||||
setting:
|
|
||||||
swagger-model-name: 代码生成器接口文档
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 7300
|
|
||||||
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
name: code-generator
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#包前缀
|
|
||||||
package=com.central
|
|
||||||
#模块名,生成的类的package为:com.central.generator
|
|
||||||
moduleName=tourist
|
|
||||||
#作者名
|
|
||||||
author=lsl
|
|
||||||
#Email
|
|
||||||
email=
|
|
||||||
#表前缀,如表tb_sys_user 生成类 sys_user
|
|
||||||
tablePrefix=tb_
|
|
||||||
|
|
||||||
#数据转换类型
|
|
||||||
tinyint=Integer
|
|
||||||
smallint=Integer
|
|
||||||
mediumint=Integer
|
|
||||||
int=Integer
|
|
||||||
integer=Integer
|
|
||||||
bigint=Long
|
|
||||||
float=Float
|
|
||||||
double=Double
|
|
||||||
decimal=BigDecimal
|
|
||||||
bit=Boolean
|
|
||||||
|
|
||||||
char=String
|
|
||||||
varchar=String
|
|
||||||
tinytext=String
|
|
||||||
text=String
|
|
||||||
mediumtext=String
|
|
||||||
longtext=String
|
|
||||||
|
|
||||||
date=Date
|
|
||||||
datetime=Date
|
|
||||||
timestamp=Date
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.central.generator.mapper.SysGeneratorMapper">
|
|
||||||
<select id="queryList" resultType="map">
|
|
||||||
select table_name tableName, engine engine, table_comment tableComment, create_time createTime from
|
|
||||||
information_schema.tables
|
|
||||||
where table_schema = (select database())
|
|
||||||
<if test="p.tableName != null and p.tableName.trim() != ''">
|
|
||||||
and table_name like concat('%', #{p.tableName}, '%')
|
|
||||||
</if>
|
|
||||||
order by create_time desc
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="queryTotal" resultType="int">
|
|
||||||
select count(*) from information_schema.tables where table_schema = (select database())
|
|
||||||
<if test="tableName != null and tableName.trim() != ''">
|
|
||||||
and table_name like concat('%', #{tableName}, '%')
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="queryTable" resultType="map">
|
|
||||||
select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables
|
|
||||||
where table_schema = (select database()) and table_name = #{tableName}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="queryColumns" resultType="map">
|
|
||||||
select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns
|
|
||||||
where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package ${package}.${moduleName}.controller;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import ${package}.${moduleName}.model.${className};
|
|
||||||
import ${package}.${moduleName}.service.I${className}Service;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.central.common.model.Result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${comments}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/${pathName}")
|
|
||||||
@Tag(name = "${comments}")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ${className}Controller {
|
|
||||||
private final I${className}Service ${classname}Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查询列表")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
|
||||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
|
||||||
})
|
|
||||||
@GetMapping
|
|
||||||
public PageResult list(@RequestParam Map<String, Object> params) {
|
|
||||||
return ${classname}Service.findList(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查询")
|
|
||||||
@GetMapping("/{${pk.attrname}}")
|
|
||||||
public Result findUserById(@PathVariable Long ${pk.attrname}) {
|
|
||||||
${className} model = ${classname}Service.getById(${pk.attrname});
|
|
||||||
return Result.succeed(model, "查询成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增or更新
|
|
||||||
*/
|
|
||||||
@Operation(summary = "保存")
|
|
||||||
@PostMapping
|
|
||||||
public Result save(@RequestBody ${className} ${classname}) {
|
|
||||||
${classname}Service.saveOrUpdate(${classname});
|
|
||||||
return Result.succeed("保存成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
@Parameter(name = "id", description = "id", in = ParameterIn.PATH, required = true)
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public Result delete(@PathVariable Long ${pk.attrname}) {
|
|
||||||
${classname}Service.removeById(${pk.attrname});
|
|
||||||
return Result.succeed("删除成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package ${package}.${moduleName}.mapper;
|
|
||||||
|
|
||||||
import ${package}.${moduleName}.model.${className};
|
|
||||||
import com.central.db.mapper.SuperMapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${comments}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface ${className}Mapper extends SuperMapper<${className}> {
|
|
||||||
/**
|
|
||||||
* 分页查询用户列表
|
|
||||||
* @param page
|
|
||||||
* @param params
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<${className}> findList(Page<${className}> page, @Param("p") Map<String, Object> params);
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
|
|
||||||
<mapper namespace="${package}.${moduleName}.mapper.${className}Mapper">
|
|
||||||
<select id="findList" resultType="${package}.${moduleName}.model.${className}">
|
|
||||||
select * from ${tableName} t
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package ${package}.${moduleName}.model;
|
|
||||||
|
|
||||||
import ${package}.common.model.SuperEntity;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
#if(${hasBigDecimal})
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
#end
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${comments}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("${tableName}")
|
|
||||||
public class ${className} extends SuperEntity {
|
|
||||||
private static final long serialVersionUID=1L;
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.columnName != $pk.columnName && $column.columnName != "createTime" && $column.columnName != "updateTime")
|
|
||||||
private $column.attrType $column.attrname;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package ${package}.${moduleName}.service;
|
|
||||||
|
|
||||||
import ${package}.${moduleName}.model.${className};
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import ${package}.common.service.ISuperService;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${comments}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
public interface I${className}Service extends ISuperService<${className}> {
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
* @param params
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
PageResult<${className}> findList(Map<String, Object> params);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package ${package}.${moduleName}.service.impl;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import ${package}.common.service.impl.SuperServiceImpl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import ${package}.${moduleName}.model.${className};
|
|
||||||
import ${package}.${moduleName}.mapper.${className}Mapper;
|
|
||||||
import ${package}.${moduleName}.service.I${className}Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${comments}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
public class ${className}ServiceImpl extends SuperServiceImpl<${className}Mapper, ${className}> implements I${className}Service {
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
* @param params
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public PageResult<${className}> findList(Map<String, Object> params){
|
|
||||||
Page<${className}> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
|
||||||
List<${className}> list = baseMapper.findList(page, params);
|
|
||||||
return PageResult.<${className}>builder().data(list).code(0).count(page.getTotal()).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<div class="layui-card">
|
|
||||||
<div class="layui-card-header">
|
|
||||||
<h2 class="header-title">${comments}</h2>
|
|
||||||
<span class="layui-breadcrumb pull-right">
|
|
||||||
<a href="#!console">首页</a>
|
|
||||||
<a><cite>${comments}</cite></a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="layui-card-body">
|
|
||||||
<div class="layui-form toolbar">
|
|
||||||
搜索:
|
|
||||||
<input id="${classname}-edit-value" class="layui-input search-input" type="text" placeholder="输入关键字"/> 
|
|
||||||
<button id="${classname}-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
|
||||||
<button id="${classname}-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 数据表格 -->
|
|
||||||
<table class="layui-table" id="${classname}-table" lay-filter="${classname}-table"></table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
layui.use(['form', 'table', 'util', 'config', 'admin'], function () {
|
|
||||||
var form = layui.form;
|
|
||||||
var table = layui.table;
|
|
||||||
var config = layui.config;
|
|
||||||
var layer = layui.layer;
|
|
||||||
var util = layui.util;
|
|
||||||
var admin = layui.admin;
|
|
||||||
|
|
||||||
//渲染表格
|
|
||||||
table.render({
|
|
||||||
elem: '#${classname}-table',
|
|
||||||
url: config.base_server + 'api-${moduleName}/${pathName}/list',
|
|
||||||
where: {
|
|
||||||
access_token: config.getToken().access_token
|
|
||||||
},
|
|
||||||
page: true,
|
|
||||||
cols: [[
|
|
||||||
{type: 'numbers'},
|
|
||||||
{field: 'id', sort: true, title: 'ID',width: 80},
|
|
||||||
{field: 'name', sort: true, title: 'name'},
|
|
||||||
{field: 'code', sort: true, title: 'code'},
|
|
||||||
{align: 'center', toolbar: '#${classname}-table-bar', title: '操作',width: 250}
|
|
||||||
]]
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.central.generator.utils;
|
|
||||||
|
|
||||||
import org.assertj.core.api.Assertions;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GenUtils测试用例
|
|
||||||
*
|
|
||||||
* @author zlt
|
|
||||||
* @date 2019/5/10
|
|
||||||
*/
|
|
||||||
@SpringBootTest
|
|
||||||
public class GenUtilsTest {
|
|
||||||
@Test
|
|
||||||
public void testTableToJava() {
|
|
||||||
String javaName = GenUtils.tableToJava("t_event_message", "t_");
|
|
||||||
Assertions.assertThat(javaName).isEqualTo("EventMessage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-1
@@ -177,7 +177,9 @@ public class RedisOAuth2AuthorizationService implements OAuth2AuthorizationServi
|
|||||||
|
|
||||||
public void remove(String accessToken) {
|
public void remove(String accessToken) {
|
||||||
OAuth2Authorization oAuth2Authorization = this.findById(accessToken);
|
OAuth2Authorization oAuth2Authorization = this.findById(accessToken);
|
||||||
this.remove(oAuth2Authorization);
|
if (oAuth2Authorization != null) {
|
||||||
|
this.remove(oAuth2Authorization);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> findTokensByClientId(String clientId) {
|
public List<String> findTokensByClientId(String clientId) {
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ public class UserDetailServiceFactory {
|
|||||||
return this.getService(accountType);
|
return this.getService(accountType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZltUserDetailsService getService() {
|
||||||
|
return this.getService(SecurityConstants.DEF_ACCOUNT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
public ZltUserDetailsService getService(String accountType) {
|
public ZltUserDetailsService getService(String accountType) {
|
||||||
if (StrUtil.isEmpty(accountType)) {
|
if (StrUtil.isEmpty(accountType)) {
|
||||||
accountType = SecurityConstants.DEF_ACCOUNT_TYPE;
|
accountType = SecurityConstants.DEF_ACCOUNT_TYPE;
|
||||||
|
|||||||
Reference in New Issue
Block a user