init project v1.0.0
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://${zlt.datasource.ip}:3306/user-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/mapper/*Mapper.xml
|
||||
#实体扫描,多个package用逗号或者分号分隔
|
||||
typeAliasesPackage: com.central.generator.model
|
||||
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 7300
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: code-generator
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: ${zlt.nacos.server-addr}
|
||||
file-extension: yml
|
||||
shared-dataids: common.yml
|
||||
discovery:
|
||||
server-addr: ${zlt.nacos.server-addr}
|
||||
@@ -0,0 +1,33 @@
|
||||
#包前缀
|
||||
package=com.central
|
||||
#模块名,生成的类的package为:com.central.generator
|
||||
moduleName=generator
|
||||
#作者名
|
||||
author=zlt
|
||||
#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
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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, 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>
|
||||
@@ -0,0 +1,74 @@
|
||||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import ${package}.${moduleName}.model.${className};
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/${pathName}")
|
||||
@Api(tags = "${comments}")
|
||||
public class ${className}Controller {
|
||||
@Autowired
|
||||
private I${className}Service ${classname}Service;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@ApiOperation(value = "查询列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer")
|
||||
})
|
||||
@GetMapping("/${className}")
|
||||
public PageResult list(@RequestParam Map<String, Object> params) {
|
||||
return ${classname}Service.findList(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
@ApiOperation(value = "查询")
|
||||
@GetMapping("/${className}/{id}")
|
||||
public Result findUserById(@PathVariable Long ${pk.attrname}) {
|
||||
${className} model = ${classname}Service.getById(id);
|
||||
return Result.succeed(model, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增or更新
|
||||
*/
|
||||
@ApiOperation(value = "保存")
|
||||
@PostMapping("/${className}")
|
||||
public Result save(@RequestBody ${className} ${classname}) {
|
||||
${classname}Service.saveOrUpdateUser(${classname});
|
||||
return Result.succeed("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping("/${className}/{id}")
|
||||
public Result delete(@PathVariable Long ${pk.attrname}) {
|
||||
${classname}Service.removeById(${pk.attrname});
|
||||
return Result.succeed("删除成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package ${package}.${moduleName}.dao;
|
||||
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import com.central.db.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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
|
||||
order by t.id desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,31 @@
|
||||
package ${package}.${moduleName}.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotations.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.EqualsAndHashCode;
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package ${package}.${moduleName}.service;
|
||||
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${className}Service extends IService<${className}> {
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
PageResult<${className}> findList(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package ${package}.${moduleName}.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.dao.${className}Dao;
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements I${className}Service {
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public PageResult<${className}> findList(Map<String, Object> params){
|
||||
Integer page = MapUtils.getInteger(params, "page");
|
||||
Integer limit = MapUtils.getInteger(params, "limit");
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
if (limit == null) {
|
||||
limit = -1;
|
||||
}
|
||||
Page<${className}> page = new Page<>(page, limit);
|
||||
List<${className}> list = baseMapper.findList(page, params);
|
||||
return PageResult.<${className}>builder().data(list).code(0).count(page.getTotal()).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user