Merge branch 'develop' of https://gitee.com/likeadmin/likeadmin_java into develop
This commit is contained in:
commit
b693e829f9
|
|
@ -8,3 +8,5 @@ application-pro.yml
|
||||||
application-dem.yml
|
application-dem.yml
|
||||||
application-prod.yml
|
application-prod.yml
|
||||||
application-test.yml
|
application-test.yml
|
||||||
|
/public/uploads/*
|
||||||
|
!/public/uploads/index.html
|
||||||
|
|
@ -10,6 +10,7 @@ import com.mdd.common.validator.annotation.IDMust;
|
||||||
import com.mdd.generator.service.IGenerateService;
|
import com.mdd.generator.service.IGenerateService;
|
||||||
import com.mdd.generator.validate.GenParam;
|
import com.mdd.generator.validate.GenParam;
|
||||||
import com.mdd.generator.validate.PageParam;
|
import com.mdd.generator.validate.PageParam;
|
||||||
|
import com.mdd.generator.vo.DbColumnVo;
|
||||||
import com.mdd.generator.vo.DbTableVo;
|
import com.mdd.generator.vo.DbTableVo;
|
||||||
import com.mdd.generator.vo.GenTableVo;
|
import com.mdd.generator.vo.GenTableVo;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
@ -38,8 +39,8 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@GetMapping("/db")
|
@GetMapping("/db")
|
||||||
public Object db(@Validated PageParam pageParam,
|
public AjaxResult<PageResult<DbTableVo>> db(@Validated PageParam pageParam,
|
||||||
@RequestParam Map<String, String> params) {
|
@RequestParam Map<String, String> params) {
|
||||||
PageResult<DbTableVo> list = iGenerateService.db(pageParam, params);
|
PageResult<DbTableVo> list = iGenerateService.db(pageParam, params);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
@ -52,11 +53,23 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@GetMapping("/dbAll")
|
@GetMapping("/dbAll")
|
||||||
public Object dbAll(@RequestParam Map<String, String> params) {
|
public AjaxResult<List<DbTableVo>> dbAll(@RequestParam Map<String, String> params) {
|
||||||
List<DbTableVo> list = iGenerateService.dbAll(params);
|
List<DbTableVo> list = iGenerateService.dbAll(params);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据表名查字段
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return List<DbColumnVo>
|
||||||
|
*/
|
||||||
|
@GetMapping("/dbColumn")
|
||||||
|
public AjaxResult<List<DbColumnVo>> dbColumn(@RequestParam String tableName) {
|
||||||
|
List<DbColumnVo> list = iGenerateService.dbColumn(tableName);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成列表
|
* 生成列表
|
||||||
*
|
*
|
||||||
|
|
@ -66,8 +79,8 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Object list(@Validated PageParam pageParam,
|
public AjaxResult<PageResult<GenTableVo>> list(@Validated PageParam pageParam,
|
||||||
@RequestParam Map<String, String> params) {
|
@RequestParam Map<String, String> params) {
|
||||||
PageResult<GenTableVo> list = iGenerateService.list(pageParam, params);
|
PageResult<GenTableVo> list = iGenerateService.list(pageParam, params);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +93,7 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
public AjaxResult<Map<String, Object>> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||||
Map<String, Object> maps = iGenerateService.detail(id);
|
Map<String, Object> maps = iGenerateService.detail(id);
|
||||||
return AjaxResult.success(maps);
|
return AjaxResult.success(maps);
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +105,7 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public Object importTable(String tables) {
|
public AjaxResult<Object> importTable(String tables) {
|
||||||
Assert.notNull(tables, "请选择要导入的表");
|
Assert.notNull(tables, "请选择要导入的表");
|
||||||
String[] tableNames = tables.split(",");
|
String[] tableNames = tables.split(",");
|
||||||
iGenerateService.importTable(tableNames);
|
iGenerateService.importTable(tableNames);
|
||||||
|
|
@ -107,7 +120,7 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@PostMapping("/editTable")
|
@PostMapping("/editTable")
|
||||||
public Object editTable(@Validated() @RequestBody GenParam genParam) {
|
public AjaxResult<Object> editTable(@Validated() @RequestBody GenParam genParam) {
|
||||||
iGenerateService.editTable(genParam);
|
iGenerateService.editTable(genParam);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +133,7 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@PostMapping("/delTable")
|
@PostMapping("/delTable")
|
||||||
public Object deleteTable(@Validated(value = GenParam.delete.class) @RequestBody GenParam genParam) {
|
public AjaxResult<Object> deleteTable(@Validated(value = GenParam.delete.class) @RequestBody GenParam genParam) {
|
||||||
iGenerateService.deleteTable(genParam.getIds());
|
iGenerateService.deleteTable(genParam.getIds());
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +146,7 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@PostMapping("/syncTable")
|
@PostMapping("/syncTable")
|
||||||
public Object syncTable(@Validated @IDMust() @RequestParam("id") Integer id) {
|
public AjaxResult<Object> syncTable(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||||
iGenerateService.syncTable(id);
|
iGenerateService.syncTable(id);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +159,7 @@ public class GenController {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
@GetMapping("/previewCode")
|
@GetMapping("/previewCode")
|
||||||
public Object previewCode(@Validated @IDMust() @RequestParam("id") Integer id) {
|
public AjaxResult<Map<String, String>> previewCode(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||||
Map<String, String> map = iGenerateService.previewCode(id);
|
Map<String, String> map = iGenerateService.previewCode(id);
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(map);
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +171,7 @@ public class GenController {
|
||||||
* @param tables 表名
|
* @param tables 表名
|
||||||
*/
|
*/
|
||||||
@GetMapping("/genCode")
|
@GetMapping("/genCode")
|
||||||
public Object genCode(String tables) {
|
public AjaxResult<Object> genCode(String tables) {
|
||||||
String production = YmlUtils.get("like.production");
|
String production = YmlUtils.get("like.production");
|
||||||
if (StringUtils.isNotEmpty(production) && production.equals("true")) {
|
if (StringUtils.isNotEmpty(production) && production.equals("true")) {
|
||||||
throw new OperateException("抱歉,演示环境不允许操作!");
|
throw new OperateException("抱歉,演示环境不允许操作!");
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.mdd.generator.service;
|
||||||
import com.mdd.common.core.PageResult;
|
import com.mdd.common.core.PageResult;
|
||||||
import com.mdd.generator.validate.GenParam;
|
import com.mdd.generator.validate.GenParam;
|
||||||
import com.mdd.generator.validate.PageParam;
|
import com.mdd.generator.validate.PageParam;
|
||||||
|
import com.mdd.generator.vo.DbColumnVo;
|
||||||
import com.mdd.generator.vo.DbTableVo;
|
import com.mdd.generator.vo.DbTableVo;
|
||||||
import com.mdd.generator.vo.GenTableVo;
|
import com.mdd.generator.vo.GenTableVo;
|
||||||
|
|
||||||
|
|
@ -33,6 +34,14 @@ public interface IGenerateService {
|
||||||
*/
|
*/
|
||||||
List<DbTableVo> dbAll(Map<String, String> params);
|
List<DbTableVo> dbAll(Map<String, String> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据表名查字段
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return List<DbColumnVo>
|
||||||
|
*/
|
||||||
|
List<DbColumnVo> dbColumn(String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成列表
|
* 生成列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import com.mdd.generator.util.GenUtil;
|
||||||
import com.mdd.generator.util.VelocityUtil;
|
import com.mdd.generator.util.VelocityUtil;
|
||||||
import com.mdd.generator.validate.GenParam;
|
import com.mdd.generator.validate.GenParam;
|
||||||
import com.mdd.generator.validate.PageParam;
|
import com.mdd.generator.validate.PageParam;
|
||||||
|
import com.mdd.generator.vo.DbColumnVo;
|
||||||
import com.mdd.generator.vo.DbTableVo;
|
import com.mdd.generator.vo.DbTableVo;
|
||||||
import com.mdd.generator.vo.GenColumnVo;
|
import com.mdd.generator.vo.GenColumnVo;
|
||||||
import com.mdd.generator.vo.GenTableVo;
|
import com.mdd.generator.vo.GenTableVo;
|
||||||
|
|
@ -104,6 +105,28 @@ public class GenerateServiceImpl implements IGenerateService {
|
||||||
return tables;
|
return tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据表名查字段
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return List<DbColumnVo>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DbColumnVo> dbColumn(String tableName) {
|
||||||
|
List<GenTableColumn> columns = genTableMapper.selectDbTableColumnsByName(tableName);
|
||||||
|
|
||||||
|
List<DbColumnVo> list = new LinkedList<>();
|
||||||
|
for (GenTableColumn col : columns) {
|
||||||
|
DbColumnVo vo = new DbColumnVo();
|
||||||
|
vo.setColumnName(col.getColumnName());
|
||||||
|
vo.setColumnType(col.getColumnType());
|
||||||
|
vo.setColumnComment(col.getColumnComment());
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成列表
|
* 生成列表
|
||||||
*
|
*
|
||||||
|
|
@ -264,6 +287,7 @@ public class GenerateServiceImpl implements IGenerateService {
|
||||||
model.setGenType(genParam.getGenType());
|
model.setGenType(genParam.getGenType());
|
||||||
model.setGenPath(genParam.getGenPath());
|
model.setGenPath(genParam.getGenPath());
|
||||||
model.setSubTableFk(genParam.getSubTableFk());
|
model.setSubTableFk(genParam.getSubTableFk());
|
||||||
|
model.setSubTableFr(genParam.getSubTableFr());
|
||||||
model.setSubTableName(genParam.getSubTableName());
|
model.setSubTableName(genParam.getSubTableName());
|
||||||
genTableMapper.updateById(model);
|
genTableMapper.updateById(model);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,4 +248,17 @@ public class GenUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取表的别名
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String getTableAlias(String tableName) {
|
||||||
|
StringBuilder val = new StringBuilder();
|
||||||
|
for (String name : tableName.split("_")) {
|
||||||
|
val.append(name.charAt(0));
|
||||||
|
}
|
||||||
|
return val.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ public class VelocityUtil {
|
||||||
|
|
||||||
// 替换前缀
|
// 替换前缀
|
||||||
table.setSubTableName(table.getSubTableName().replace(GlobalConfig.tablePrefix, ""));
|
table.setSubTableName(table.getSubTableName().replace(GlobalConfig.tablePrefix, ""));
|
||||||
|
System.out.println(GenUtil.getTableAlias(table.getSubTableName()));
|
||||||
|
|
||||||
// 设置模板变量
|
// 设置模板变量
|
||||||
VelocityContext velocityContext = new VelocityContext();
|
VelocityContext velocityContext = new VelocityContext();
|
||||||
|
|
@ -84,6 +85,7 @@ public class VelocityUtil {
|
||||||
velocityContext.put("notesType", GenConfig.notesType);
|
velocityContext.put("notesType", GenConfig.notesType);
|
||||||
velocityContext.put("table", table);
|
velocityContext.put("table", table);
|
||||||
velocityContext.put("columns", columns);
|
velocityContext.put("columns", columns);
|
||||||
|
velocityContext.put("subTableAlias", GenUtil.getTableAlias(table.getSubTableName()));
|
||||||
velocityContext.put("dateFields", SqlConstants.COLUMN_TIME_NAME);
|
velocityContext.put("dateFields", SqlConstants.COLUMN_TIME_NAME);
|
||||||
velocityContext.put("primaryKey", primaryKey);
|
velocityContext.put("primaryKey", primaryKey);
|
||||||
velocityContext.put("primaryField", primaryField);
|
velocityContext.put("primaryField", primaryField);
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,6 @@ public class GenParam implements Serializable {
|
||||||
|
|
||||||
private String subTableFk = "";
|
private String subTableFk = "";
|
||||||
|
|
||||||
|
private String subTableFr = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mdd.generator.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DbColumnVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String columnName; // 字段名称
|
||||||
|
private String columnComment; // 字段描述
|
||||||
|
private String columnType; // 字段类型
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
#set($queryWrapper = "mpjQueryWrapper")
|
#set($queryWrapper = "mpjQueryWrapper")
|
||||||
MPJQueryWrapper<${EntityName}> mpjQueryWrapper = new MPJQueryWrapper<>();
|
MPJQueryWrapper<${EntityName}> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||||
mpjQueryWrapper.selectAll(${EntityName}.class);
|
mpjQueryWrapper.selectAll(${EntityName}.class);
|
||||||
mpjQueryWrapper.innerJoin("?_$table.subTableName f ON f.$table.SubTableFr=t.$table.SubTableFk".replace("?_", GlobalConfig.tablePrefix));
|
mpjQueryWrapper.innerJoin("?_$table.subTableName $subTableAlias ON $subTableAlias.$table.SubTableFk=t.$table.SubTableFr".replace("?_", GlobalConfig.tablePrefix));
|
||||||
#if($allFields.contains("is_delete"))
|
#if($allFields.contains("is_delete"))
|
||||||
mpjQueryWrapper.eq("t.is_delete", 0);
|
mpjQueryWrapper.eq("t.is_delete", 0);
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ CREATE TABLE `la_gen_table` (
|
||||||
`table_comment` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '表描述',
|
`table_comment` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '表描述',
|
||||||
`sub_table_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联表名称',
|
`sub_table_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联表名称',
|
||||||
`sub_table_fk` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联表外键',
|
`sub_table_fk` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联表外键',
|
||||||
|
`sub_table_fr` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联表主键',
|
||||||
`author_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '作者的名称',
|
`author_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '作者的名称',
|
||||||
`entity_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '实体的名称',
|
`entity_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '实体的名称',
|
||||||
`module_name` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '生成模块名',
|
`module_name` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '生成模块名',
|
||||||
|
|
@ -526,7 +527,7 @@ BEGIN;
|
||||||
INSERT INTO `la_system_auth_dept` VALUES (1, 0, '默认部门', 'LikeAdmin', '18327647788', 10, 0, 0, 1649841995, 1660190949, 0);
|
INSERT INTO `la_system_auth_dept` VALUES (1, 0, '默认部门', 'LikeAdmin', '18327647788', 10, 0, 0, 1649841995, 1660190949, 0);
|
||||||
INSERT INTO `la_system_auth_role` VALUES (1, '审核员', '审核数据', 0, 0, 1668679451, 1668679468);
|
INSERT INTO `la_system_auth_role` VALUES (1, '审核员', '审核数据', 0, 0, 1668679451, 1668679468);
|
||||||
INSERT INTO `la_system_auth_admin` VALUES (1, '0', '1', '', 'admin', 'admin', '4919832b10f1d2133c0f24a7dbe8330e', '/api/static/backend_avatar.png', 'Huku0', 0, 1, 0, 0, '127.0.0.1', 1670314940, 1642321599, 1670376604, 0);
|
INSERT INTO `la_system_auth_admin` VALUES (1, '0', '1', '', 'admin', 'admin', '4919832b10f1d2133c0f24a7dbe8330e', '/api/static/backend_avatar.png', 'Huku0', 0, 1, 0, 0, '127.0.0.1', 1670314940, 1642321599, 1670376604, 0);
|
||||||
INSERT INTO `la_crontab` VALUES (1, '有参数任务', 'default', 'myJob.handle(\"参数\")', '* * * * * ?', '', '', 1, 1, 0, 0, 1670377612, 1670377612, 0, 1669970830, 1670289651, 0);
|
INSERT INTO `la_crontab` VALUES (1, '有参数任务', 'default', 'myJob.handle(\"参数\")', '* * * * * ?', '', '', 2, 1, 0, 0, 1670377612, 1670377612, 0, 1669970830, 1670289651, 0);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue