@@ -1,6 +1,8 @@
|
|||||||
package com.youlai.system.common.base;
|
package com.youlai.system.common.base;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -12,7 +14,7 @@ import java.time.LocalDateTime;
|
|||||||
/**
|
/**
|
||||||
* 基础实体类
|
* 基础实体类
|
||||||
*
|
*
|
||||||
* <p>实体类的基类,包含了实体类的公共属性,如创建时间、更新时间</p>
|
* <p>实体类的基类,包含了实体类的公共属性,如创建时间、更新时间、逻辑删除标识等</p>
|
||||||
*
|
*
|
||||||
* @author Ray
|
* @author Ray
|
||||||
* @since 2024/6/23
|
* @since 2024/6/23
|
||||||
@@ -23,13 +25,6 @@ public class BaseEntity implements Serializable {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@@ -46,5 +41,9 @@ public class BaseEntity implements Serializable {
|
|||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑删除标识 (0-未删除 1-已删除)
|
||||||
|
*/
|
||||||
|
@TableLogic(value = "0", delval = "1")
|
||||||
|
private Integer isDeleted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.youlai.system.config.property;
|
package com.youlai.system.config.property;
|
||||||
|
|
||||||
import cn.hutool.core.io.file.FileNameUtil;
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@@ -31,11 +30,6 @@ public class GeneratorProperties {
|
|||||||
|
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件扩展名,如 .java
|
|
||||||
*/
|
|
||||||
private String extension= FileNameUtil.EXT_JAVA;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,19 @@ package com.youlai.system.controller;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.youlai.system.common.result.PageResult;
|
import com.youlai.system.common.result.PageResult;
|
||||||
import com.youlai.system.common.result.Result;
|
import com.youlai.system.common.result.Result;
|
||||||
import com.youlai.system.model.form.GenConfigForm;
|
|
||||||
import com.youlai.system.model.query.TablePageQuery;
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
import com.youlai.system.model.vo.GeneratorPreviewVO;
|
import com.youlai.system.model.vo.TableColumnVO;
|
||||||
|
import com.youlai.system.model.vo.TableGeneratePreviewVO;
|
||||||
import com.youlai.system.model.vo.TablePageVO;
|
import com.youlai.system.model.vo.TablePageVO;
|
||||||
import com.youlai.system.service.GeneratorService;
|
import com.youlai.system.service.GeneratorService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -32,26 +36,21 @@ public class GeneratorController {
|
|||||||
return PageResult.success(result);
|
return PageResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取预览生成代码")
|
@Operation(summary = "获取数据表字段列表")
|
||||||
@GetMapping("/{tableName}/preview")
|
@GetMapping("/table/{tableName}/columns")
|
||||||
public Result<List<GeneratorPreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
public Result<List<TableColumnVO>> getTableColumns(
|
||||||
List<GeneratorPreviewVO> list = generatorService.getTablePreviewData(tableName);
|
@Parameter(description = "表名", example = "sys_user") @PathVariable String tableName
|
||||||
|
) {
|
||||||
|
List<TableColumnVO> list = generatorService.getTableColumns(tableName);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "获取代码生成配置")
|
@Operation(summary = "获取预览生成代码")
|
||||||
@GetMapping("/{tableName}/config")
|
@GetMapping("/table/{tableName}/preview")
|
||||||
public Result<GenConfigForm> getGenConfig(@PathVariable String tableName) {
|
public Result<List<TableGeneratePreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
||||||
GenConfigForm formData = generatorService.getGenConfig(tableName);
|
List<TableGeneratePreviewVO> list = generatorService.getTablePreviewData(tableName);
|
||||||
return Result.success(formData);
|
return Result.success(list);
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "保存代码生成配置")
|
|
||||||
@PostMapping("/{tableName}/config")
|
|
||||||
public Result saveGenCodeConfig(@RequestBody GenConfigForm formData) {
|
|
||||||
boolean result = generatorService.saveGenCodeConfig(formData);
|
|
||||||
return Result.judge(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public interface DeptConverter {
|
|||||||
|
|
||||||
DeptForm toForm(SysDept entity);
|
DeptForm toForm(SysDept entity);
|
||||||
|
|
||||||
DeptVO toVo(SysDept entity);
|
DeptVO convertToVo(SysDept entity);
|
||||||
|
|
||||||
SysDept toEntity(DeptForm deptForm);
|
SysDept toEntity(DeptForm deptForm);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.youlai.system.model.vo.DictPageVO;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典对象转换器
|
* 字典 对象转换器
|
||||||
*
|
*
|
||||||
* @author Ray Hao
|
* @author Ray Hao
|
||||||
* @since 2022/6/8
|
* @since 2022/6/8
|
||||||
@@ -15,7 +15,7 @@ import org.mapstruct.Mapper;
|
|||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface DictConverter {
|
public interface DictConverter {
|
||||||
|
|
||||||
Page<DictPageVO> toPageVo(Page<SysDict> page);
|
Page<DictPageVO> convertToPageVo(Page<SysDict> page);
|
||||||
|
|
||||||
DictForm toForm(SysDict entity);
|
DictForm toForm(SysDict entity);
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
package com.youlai.system.converter;
|
|
||||||
|
|
||||||
import com.youlai.system.model.entity.GenConfig;
|
|
||||||
import com.youlai.system.model.entity.GenFieldConfig;
|
|
||||||
import com.youlai.system.model.form.GenConfigForm;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成配置转换器
|
|
||||||
*
|
|
||||||
* @author Ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@Mapper(componentModel = "spring")
|
|
||||||
public interface GenConfigConverter {
|
|
||||||
|
|
||||||
@Mapping(source = "genConfig.tableName", target = "tableName")
|
|
||||||
@Mapping(source = "genConfig.comment", target = "comment")
|
|
||||||
@Mapping(source = "genConfig.moduleName", target = "moduleName")
|
|
||||||
@Mapping(source = "genConfig.packageName", target = "packageName")
|
|
||||||
@Mapping(source = "genConfig.entityName", target = "entityName")
|
|
||||||
@Mapping(source = "genConfig.author", target = "author")
|
|
||||||
@Mapping(source = "fieldConfigs", target = "fieldConfigs")
|
|
||||||
GenConfigForm toGenConfigForm(GenConfig genConfig, List<GenFieldConfig> fieldConfigs);
|
|
||||||
|
|
||||||
List<GenConfigForm.FieldConfig> toFieldConfigList(List<GenFieldConfig> fieldConfigs);
|
|
||||||
|
|
||||||
@Mapping(source = "configId", target = "configId")
|
|
||||||
@Mapping(source = "columnName", target = "columnName")
|
|
||||||
@Mapping(source = "columnType", target = "columnType")
|
|
||||||
@Mapping(source = "fieldName", target = "fieldName")
|
|
||||||
@Mapping(source = "fieldType", target = "fieldType")
|
|
||||||
@Mapping(source = "comment", target = "comment")
|
|
||||||
@Mapping(source = "formType", target = "formType")
|
|
||||||
@Mapping(source = "queryType", target = "queryType")
|
|
||||||
@Mapping(source = "isShowInList", target = "isShowInList")
|
|
||||||
@Mapping(source = "isShowInForm", target = "isShowInForm")
|
|
||||||
@Mapping(source = "isShowInQuery", target = "isShowInQuery")
|
|
||||||
@Mapping(source = "isRequired", target = "isRequired")
|
|
||||||
GenConfigForm.FieldConfig toFieldConfig(GenFieldConfig genFieldConfig);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package com.youlai.system.enums;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
|
||||||
import com.youlai.system.common.base.IBaseEnum;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单类型枚举
|
|
||||||
*
|
|
||||||
* @author Ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum FormTypeEnum implements IBaseEnum<Integer> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输入框
|
|
||||||
*/
|
|
||||||
INPUT(1, "输入框"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下拉框
|
|
||||||
*/
|
|
||||||
SELECT(2, "下拉框"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单选框
|
|
||||||
*/
|
|
||||||
RADIO(3, "单选框"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字输入框
|
|
||||||
*/
|
|
||||||
INPUT_NUMBER(4, "数字输入框"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开关
|
|
||||||
*/
|
|
||||||
SWITCH(5, "开关"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复选框
|
|
||||||
*/
|
|
||||||
CHECK_BOX(6, "复选框"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文本域
|
|
||||||
*/
|
|
||||||
TEXT_AREA(7, "文本域"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日期时间框
|
|
||||||
*/
|
|
||||||
DATE_TIME(8, "日期时间框"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日期框
|
|
||||||
*/
|
|
||||||
DATE(9, "日期框"),;
|
|
||||||
|
|
||||||
|
|
||||||
// Mybatis-Plus 提供注解表示插入数据库时插入该值
|
|
||||||
@EnumValue
|
|
||||||
private final Integer value;
|
|
||||||
|
|
||||||
// @JsonValue // 表示对枚举序列化时返回此字段
|
|
||||||
private final String label;
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.youlai.system.enums;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
|
||||||
import com.youlai.system.common.base.IBaseEnum;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询类型枚举
|
|
||||||
*
|
|
||||||
* @author Ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum QueryTypeEnum implements IBaseEnum<Integer> {
|
|
||||||
|
|
||||||
|
|
||||||
EQ(1, "="),
|
|
||||||
|
|
||||||
|
|
||||||
NE(2, "!="),
|
|
||||||
|
|
||||||
|
|
||||||
GT(3, ">"),
|
|
||||||
|
|
||||||
|
|
||||||
GE(4, ">="),
|
|
||||||
|
|
||||||
LT(5, "<"),
|
|
||||||
|
|
||||||
LE(6, "<="),
|
|
||||||
|
|
||||||
BETWEEN(7, "BETWEEN"),
|
|
||||||
|
|
||||||
LIKE(8, "LIKE '%s%'"),
|
|
||||||
|
|
||||||
LIKE_LEFT(9, "LIKE '%s'"),
|
|
||||||
|
|
||||||
LIKE_RIGHT(10, "LIKE 's%'"),
|
|
||||||
|
|
||||||
IN(11, "IN"),
|
|
||||||
|
|
||||||
NOT_IN(12, "NOT IN"),
|
|
||||||
|
|
||||||
IS_NULL(13, "IS NULL"),
|
|
||||||
|
|
||||||
IS_NOT_NULL(14, "IS NOT NULL")
|
|
||||||
;
|
|
||||||
|
|
||||||
// Mybatis-Plus 提供注解表示插入数据库时插入该值
|
|
||||||
@EnumValue
|
|
||||||
private final Integer value;
|
|
||||||
|
|
||||||
// @JsonValue // 表示对枚举序列化时返回此字段
|
|
||||||
private final String label;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -11,12 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库 Mapper 接口
|
|
||||||
*
|
|
||||||
* @author ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DatabaseMapper extends BaseMapper<SysDept> {
|
public interface DatabaseMapper extends BaseMapper<SysDept> {
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.youlai.system.mapper;
|
|
||||||
|
|
||||||
import com.youlai.system.model.entity.GenConfig;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成基础配置访问层
|
|
||||||
*
|
|
||||||
* @author Ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface GenConfigMapper extends BaseMapper<GenConfig> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.youlai.system.mapper;
|
|
||||||
|
|
||||||
import com.youlai.system.model.entity.GenFieldConfig;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成字段配置访问层
|
|
||||||
*
|
|
||||||
* @author Ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface GenFieldConfigMapper extends BaseMapper<GenFieldConfig> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.youlai.system.model.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成基础配置
|
|
||||||
*/
|
|
||||||
@TableName(value ="gen_config")
|
|
||||||
@Data
|
|
||||||
public class GenConfig extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表名
|
|
||||||
*/
|
|
||||||
private String tableName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 包名
|
|
||||||
*/
|
|
||||||
private String packageName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块名
|
|
||||||
*/
|
|
||||||
private String moduleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实体名
|
|
||||||
*/
|
|
||||||
private String entityName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类描述
|
|
||||||
*/
|
|
||||||
private String comment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单ID
|
|
||||||
*/
|
|
||||||
private Long parentMenuId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 作者
|
|
||||||
*/
|
|
||||||
private String author;
|
|
||||||
|
|
||||||
|
|
||||||
@TableLogic
|
|
||||||
private Integer isDeleted;
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
package com.youlai.system.model.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
|
||||||
import com.youlai.system.enums.FormTypeEnum;
|
|
||||||
import com.youlai.system.enums.QueryTypeEnum;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段生成配置实体
|
|
||||||
*
|
|
||||||
* @author Ray
|
|
||||||
* @since 2.10.0
|
|
||||||
*/
|
|
||||||
@TableName(value = "gen_field_config")
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class GenFieldConfig extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联的配置ID
|
|
||||||
*/
|
|
||||||
private Long configId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列名
|
|
||||||
*/
|
|
||||||
private String columnName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列类型
|
|
||||||
*/
|
|
||||||
private String columnType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段长度
|
|
||||||
*/
|
|
||||||
private String columnLength;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段名称
|
|
||||||
*/
|
|
||||||
private String fieldName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段类型
|
|
||||||
*/
|
|
||||||
private String fieldType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段描述
|
|
||||||
*/
|
|
||||||
private String comment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单类型
|
|
||||||
*/
|
|
||||||
private FormTypeEnum formType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询方式
|
|
||||||
*/
|
|
||||||
private QueryTypeEnum queryType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否在列表显示
|
|
||||||
*/
|
|
||||||
private Integer isShowInList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否在表单显示
|
|
||||||
*/
|
|
||||||
private Integer isShowInForm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否在查询条件显示
|
|
||||||
*/
|
|
||||||
private Integer isShowInQuery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否必填
|
|
||||||
*/
|
|
||||||
private Integer isRequired;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ package com.youlai.system.model.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -17,6 +16,11 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SysDept extends BaseEntity {
|
public class SysDept extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
@@ -58,10 +62,4 @@ public class SysDept extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long updateBy;
|
private Long updateBy;
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标识 (0-未删除 1-已删除)
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
private Boolean isDeleted;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.youlai.system.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -14,6 +13,11 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SysDict extends BaseEntity {
|
public class SysDict extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型名称
|
* 类型名称
|
||||||
@@ -35,10 +39,4 @@ public class SysDict extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标识 (0-未删除 1-已删除)
|
|
||||||
*/
|
|
||||||
@TableLogic(value = "0", delval = "1")
|
|
||||||
private Integer isDeleted;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.youlai.system.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -56,10 +55,4 @@ public class SysRole extends BaseEntity {
|
|||||||
* 更新人 ID
|
* 更新人 ID
|
||||||
*/
|
*/
|
||||||
private Long updateBy;
|
private Long updateBy;
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标识 (0-未删除 1-已删除)
|
|
||||||
*/
|
|
||||||
@TableLogic(value = "0", delval = "1")
|
|
||||||
private Boolean isDeleted;
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.youlai.system.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -73,10 +72,4 @@ public class SysUser extends BaseEntity {
|
|||||||
* 更新人 ID
|
* 更新人 ID
|
||||||
*/
|
*/
|
||||||
private Long updateBy;
|
private Long updateBy;
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标识 (0-未删除 1-已删除)
|
|
||||||
*/
|
|
||||||
@TableLogic(value = "0", delval = "1")
|
|
||||||
private Integer isDeleted;
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.youlai.system.model.form;
|
package com.youlai.system.model.form;
|
||||||
|
|
||||||
import com.youlai.system.enums.FormTypeEnum;
|
|
||||||
import com.youlai.system.enums.QueryTypeEnum;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -9,67 +7,53 @@ import java.util.List;
|
|||||||
|
|
||||||
@Schema(description = "代码生成配置表单")
|
@Schema(description = "代码生成配置表单")
|
||||||
@Data
|
@Data
|
||||||
public class GenConfigForm {
|
public class GeneratorConfigForm {
|
||||||
|
|
||||||
@Schema(description = "表名")
|
@Schema(description = "表名")
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
@Schema(description = "类描述")
|
@Schema(description = "实体名")
|
||||||
private String comment;
|
private String entityName;
|
||||||
|
|
||||||
@Schema(description = "模块名")
|
|
||||||
private String moduleName;
|
|
||||||
|
|
||||||
@Schema(description = "包名")
|
@Schema(description = "包名")
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
||||||
@Schema(description = "实体名")
|
@Schema(description = "模块名")
|
||||||
private String entityName;
|
private String moduleName;
|
||||||
|
|
||||||
@Schema(description = "作者")
|
@Schema(description = "作者")
|
||||||
private String author;
|
private String author;
|
||||||
|
|
||||||
@Schema(description = "字段配置列表")
|
@Schema(description = "字段配置")
|
||||||
private List<FieldConfig> fieldConfigs;
|
private List<FieldConfig> fieldConfigs;
|
||||||
|
|
||||||
@Schema(description = "字段配置")
|
@Schema(description = "字段配置")
|
||||||
@Data
|
@Data
|
||||||
public static class FieldConfig {
|
public static class FieldConfig {
|
||||||
@Schema(description = "ID")
|
|
||||||
private Long configId;
|
|
||||||
|
|
||||||
@Schema(description = "列名")
|
@Schema(description = "字段名称")
|
||||||
private String columnName;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "列类型")
|
|
||||||
private String columnType;
|
|
||||||
|
|
||||||
@Schema(description = "字段名")
|
|
||||||
private String fieldName;
|
|
||||||
|
|
||||||
@Schema(description = "字段类型")
|
@Schema(description = "字段类型")
|
||||||
private String fieldType;
|
private String type;
|
||||||
|
|
||||||
@Schema(description = "字段描述")
|
@Schema(description = "字段描述")
|
||||||
private String comment;
|
private String description;
|
||||||
|
|
||||||
@Schema(description = "是否在列表显示")
|
@Schema(description = "是否在列表显示")
|
||||||
private Integer isShowInList;
|
private Boolean showInList;
|
||||||
|
|
||||||
@Schema(description = "是否在表单显示")
|
@Schema(description = "是否在表单显示")
|
||||||
private Integer isShowInForm;
|
private Boolean showInForm;
|
||||||
|
|
||||||
@Schema(description = "是否在查询条件显示")
|
@Schema(description = "是否在查询条件显示")
|
||||||
private Integer isShowInQuery;
|
private Boolean showInQuery;
|
||||||
|
|
||||||
@Schema(description = "是否必填")
|
|
||||||
private Integer isRequired;
|
|
||||||
|
|
||||||
@Schema(description = "表单类型")
|
@Schema(description = "表单类型")
|
||||||
private FormTypeEnum formType;
|
private String formType;
|
||||||
|
|
||||||
@Schema(description = "查询类型")
|
@Schema(description = "查询方式")
|
||||||
private QueryTypeEnum queryType;
|
private String queryMethod;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Schema(description = "表生成代码预览VO")
|
@Schema(description = "表生成代码预览VO")
|
||||||
@Data
|
@Data
|
||||||
public class GeneratorPreviewVO {
|
public class TableGeneratePreviewVO {
|
||||||
|
|
||||||
@Schema(description = "生成文件路径")
|
@Schema(description = "生成文件路径")
|
||||||
private String path;
|
private String path;
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
package com.youlai.system.service;
|
package com.youlai.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.youlai.system.model.form.GenConfigForm;
|
|
||||||
import com.youlai.system.model.query.TablePageQuery;
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
import com.youlai.system.model.vo.TableColumnVO;
|
import com.youlai.system.model.vo.TableColumnVO;
|
||||||
import com.youlai.system.model.vo.GeneratorPreviewVO;
|
import com.youlai.system.model.vo.TableGeneratePreviewVO;
|
||||||
import com.youlai.system.model.vo.TablePageVO;
|
import com.youlai.system.model.vo.TablePageVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成业务接口
|
* 数据库服务接口
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
* @since 2.11.0
|
* @since 2.11.0
|
||||||
@@ -40,21 +39,5 @@ public interface GeneratorService {
|
|||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<GeneratorPreviewVO> getTablePreviewData(String tableName);
|
List<TableGeneratePreviewVO> getTablePreviewData(String tableName);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取代码生成配置
|
|
||||||
*
|
|
||||||
* @param tableName 表名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
GenConfigForm getGenConfig(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存代码生成配置
|
|
||||||
*
|
|
||||||
* @param formData 表单数据
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean saveGenCodeConfig(GenConfigForm formData);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,18 @@
|
|||||||
package com.youlai.system.service.impl;
|
package com.youlai.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.extra.template.Template;
|
import cn.hutool.extra.template.Template;
|
||||||
import cn.hutool.extra.template.TemplateConfig;
|
import cn.hutool.extra.template.TemplateConfig;
|
||||||
import cn.hutool.extra.template.TemplateEngine;
|
import cn.hutool.extra.template.TemplateEngine;
|
||||||
import cn.hutool.extra.template.TemplateUtil;
|
import cn.hutool.extra.template.TemplateUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.youlai.system.config.property.GeneratorProperties;
|
|
||||||
import com.youlai.system.mapper.DatabaseMapper;
|
import com.youlai.system.mapper.DatabaseMapper;
|
||||||
import com.youlai.system.mapper.GenConfigMapper;
|
|
||||||
import com.youlai.system.mapper.GenFieldConfigMapper;
|
|
||||||
import com.youlai.system.model.entity.GenConfig;
|
|
||||||
import com.youlai.system.model.entity.GenFieldConfig;
|
|
||||||
import com.youlai.system.model.form.GenConfigForm;
|
|
||||||
import com.youlai.system.model.query.TablePageQuery;
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
import com.youlai.system.model.vo.TableColumnVO;
|
import com.youlai.system.model.vo.TableColumnVO;
|
||||||
import com.youlai.system.model.vo.GeneratorPreviewVO;
|
import com.youlai.system.model.vo.TableGeneratePreviewVO;
|
||||||
import com.youlai.system.model.vo.TablePageVO;
|
import com.youlai.system.model.vo.TablePageVO;
|
||||||
import com.youlai.system.service.GeneratorService;
|
import com.youlai.system.service.GeneratorService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import cn.hutool.extra.template.TemplateConfig.ResourceMode;
|
import cn.hutool.extra.template.TemplateConfig.ResourceMode;
|
||||||
|
|
||||||
@@ -43,15 +31,6 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
|
|
||||||
private final DatabaseMapper databaseMapper;
|
private final DatabaseMapper databaseMapper;
|
||||||
|
|
||||||
private final GeneratorProperties generatorProperties;
|
|
||||||
|
|
||||||
private final GenConfigMapper genConfigMapper;
|
|
||||||
private final GenFieldConfigMapper genFieldConfigMapper;
|
|
||||||
|
|
||||||
// 注入 spring.application.name
|
|
||||||
@Value("${spring.application.name}")
|
|
||||||
private String applicationName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据表分页列表
|
* 数据表分页列表
|
||||||
*
|
*
|
||||||
@@ -74,39 +53,6 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
return databaseMapper.getTableColumns(tableName);
|
return databaseMapper.getTableColumns(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取代码生成配置
|
|
||||||
*
|
|
||||||
* @param tableName 表名 eg: sys_user
|
|
||||||
* @return 代码生成配置
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public GenConfigForm getGenConfig(String tableName) {
|
|
||||||
// 查询表生成配置
|
|
||||||
GenConfig genConfig = genConfigMapper.selectOne(
|
|
||||||
new LambdaQueryWrapper<>(GenConfig.class)
|
|
||||||
.eq(GenConfig::getTableName, tableName)
|
|
||||||
.last("LIMIT 1")
|
|
||||||
);
|
|
||||||
|
|
||||||
// 查询字段生成配置
|
|
||||||
List<GenFieldConfig> fieldConfigs = genFieldConfigMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<>(GenFieldConfig.class)
|
|
||||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
|
||||||
);
|
|
||||||
|
|
||||||
GenConfigForm genConfigForm = new GenConfigForm();
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean saveGenCodeConfig(GenConfigForm formData) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取预览生成代码
|
* 获取预览生成代码
|
||||||
*
|
*
|
||||||
@@ -114,133 +60,49 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
* @return 预览数据
|
* @return 预览数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GeneratorPreviewVO> getTablePreviewData(String tableName) {
|
public List<TableGeneratePreviewVO> getTablePreviewData(String tableName) {
|
||||||
|
|
||||||
List<GeneratorPreviewVO> list = new ArrayList<>();
|
List<TableGeneratePreviewVO> list = new ArrayList<>();
|
||||||
|
|
||||||
GenConfig genConfig = genConfigMapper.selectOne(new LambdaQueryWrapper<GenConfig>()
|
TemplateConfig templateConfig = new TemplateConfig("templates" , ResourceMode.CLASSPATH);
|
||||||
.eq(GenConfig::getTableName, tableName)
|
TemplateEngine templateEngine = TemplateUtil.createEngine(templateConfig);
|
||||||
);
|
|
||||||
Assert.isTrue(genConfig != null, "未找到表生成配置");
|
|
||||||
|
|
||||||
List<GenFieldConfig> fieldConfigs = genFieldConfigMapper.selectList(new LambdaQueryWrapper<GenFieldConfig>()
|
|
||||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
|
||||||
);
|
|
||||||
Assert.isTrue(CollectionUtil.isNotEmpty(fieldConfigs), "未找到字段生成配置");
|
|
||||||
|
|
||||||
// 遍历模板配置
|
|
||||||
Map<String, GeneratorProperties.TemplateConfig> templateConfigs = generatorProperties.getTemplateConfigs();
|
|
||||||
for (Map.Entry<String, GeneratorProperties.TemplateConfig> templateConfigEntry : templateConfigs.entrySet()) {
|
|
||||||
GeneratorPreviewVO previewVO = new GeneratorPreviewVO();
|
|
||||||
|
|
||||||
GeneratorProperties.TemplateConfig templateConfig = templateConfigEntry.getValue();
|
|
||||||
|
|
||||||
/* 1. 生成文件名 UserController */
|
|
||||||
// User Role Menu Dept
|
|
||||||
String entityName = genConfig.getEntityName();
|
|
||||||
// Controller Service Mapper Entity
|
|
||||||
String templateName = templateConfigEntry.getKey();
|
|
||||||
// .java .ts .vue
|
|
||||||
String extension = templateConfig.getExtension();
|
|
||||||
|
|
||||||
// 文件名 UserController.java
|
|
||||||
String fileName = getFileName(entityName, templateName, extension);
|
|
||||||
previewVO.setFileName(fileName);
|
|
||||||
|
|
||||||
|
|
||||||
/* 2. 生成文件路径 */
|
Map<String, Object> bindingMap = new HashMap<>();
|
||||||
// com.youlai.system
|
bindingMap.put("tableName", "sys_user");
|
||||||
String packageName = genConfig.getPackageName();
|
bindingMap.put("author", "Ray");
|
||||||
// controller
|
bindingMap.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||||
String subPackageName = templateConfig.getPackageName();
|
bindingMap.put("entityName", "User" );
|
||||||
// 文件路径 com.youlai.system.controller
|
bindingMap.put("lowerFirstEntityName", "user");
|
||||||
String filePath = getFilePath(templateName, packageName, subPackageName);
|
bindingMap.put("tableComment", "用户");
|
||||||
previewVO.setPath(filePath);
|
|
||||||
|
|
||||||
/* 3. 生成文件内容 */
|
// 包路径
|
||||||
|
bindingMap.put("package", "com.youlai.system");
|
||||||
|
|
||||||
// 生成文件内容
|
Template template = templateEngine.getTemplate("generator" + File.separator + "controller.java.vm");
|
||||||
String content = getCodeContent(templateConfig, genConfig, fieldConfigs);
|
String content = template.render(bindingMap);
|
||||||
previewVO.setContent(content);
|
TableGeneratePreviewVO controller = new TableGeneratePreviewVO();
|
||||||
|
controller.setPath("youlai-boot/controller");
|
||||||
|
controller.setContent(content);
|
||||||
|
controller.setFileName("UserController.java");
|
||||||
|
|
||||||
|
list.add(controller);
|
||||||
|
|
||||||
|
TableGeneratePreviewVO vo = new TableGeneratePreviewVO();
|
||||||
|
vo.setPath("youlai-boot/model/vo");
|
||||||
|
vo.setContent(content);
|
||||||
|
vo.setFileName("UserVO.java");
|
||||||
|
|
||||||
|
list.add(vo);
|
||||||
|
|
||||||
list.add(previewVO);
|
|
||||||
}
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getFileName(String entityName, String templateName, String extension) {
|
private String generatePath(){
|
||||||
if (templateName.equals("Entity")) {
|
|
||||||
return entityName + extension;
|
|
||||||
}
|
|
||||||
if (templateName.equals("MapperXml")) {
|
|
||||||
return entityName + "Mapper" + extension;
|
|
||||||
}
|
|
||||||
if (templateName.equals("API") || templateName.equals("VIEW")) {
|
|
||||||
return StrUtil.toSymbolCase(entityName, '-') + extension;
|
|
||||||
}
|
|
||||||
return entityName + templateName + extension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFilePath(String templateName, String packageName, String subPackageName) {
|
|
||||||
String path;
|
|
||||||
if (templateName.equals("MapperXml")) {
|
|
||||||
path = (applicationName
|
|
||||||
+ File.separator
|
|
||||||
+ "src" + File.separator + "main" + File.separator + "resources"
|
|
||||||
+ File.separator + subPackageName
|
|
||||||
).replace(".", File.separator);
|
|
||||||
} else if (templateName.equals("API") || templateName.equals("VIEW")) {
|
|
||||||
path = ("vue3-element-admin"
|
|
||||||
+ File.separator
|
|
||||||
+ "src" + File.separator + subPackageName
|
|
||||||
).replace(".", File.separator);
|
|
||||||
} else {
|
|
||||||
path = (applicationName
|
|
||||||
+ File.separator
|
|
||||||
+ "src" + File.separator + "main" + File.separator + "java"
|
|
||||||
+ File.separator + packageName + File.separator + subPackageName
|
|
||||||
).replace(".", File.separator);
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码内容
|
|
||||||
*
|
|
||||||
* @param templateConfig 模板配置
|
|
||||||
* @param genConfig 生成配置
|
|
||||||
* @param fieldConfigs 字段配置
|
|
||||||
* @return 代码内容
|
|
||||||
*/
|
|
||||||
private String getCodeContent(GeneratorProperties.TemplateConfig templateConfig, GenConfig genConfig, List<GenFieldConfig> fieldConfigs) {
|
|
||||||
|
|
||||||
Map<String, Object> bindMap = new HashMap<>();
|
|
||||||
|
|
||||||
String entityName = genConfig.getEntityName();
|
|
||||||
|
|
||||||
bindMap.put("package", genConfig.getPackageName());
|
|
||||||
bindMap.put("subPackage", templateConfig.getPackageName());
|
|
||||||
bindMap.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
|
||||||
bindMap.put("entityName", entityName);
|
|
||||||
bindMap.put("tableName", genConfig.getTableName());
|
|
||||||
bindMap.put("author", genConfig.getAuthor());
|
|
||||||
bindMap.put("lowerFirstEntityName", StrUtil.lowerFirst(entityName));
|
|
||||||
bindMap.put("tableComment", StrUtil.replace(genConfig.getComment(), "表", Strings.EMPTY));
|
|
||||||
bindMap.put("fieldConfigs", fieldConfigs);
|
|
||||||
|
|
||||||
for (GenFieldConfig fieldConfig : fieldConfigs) {
|
|
||||||
bindMap.put("hasLocalDateTime", "LocalDateTime".equals(fieldConfig.getFieldType()));
|
|
||||||
bindMap.put("hasBigDecimal", "BigDecimal".equals(fieldConfig.getFieldType()));
|
|
||||||
bindMap.put("hasRequiredField", Boolean.TRUE.equals(fieldConfig.getIsRequired()));
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateEngine templateEngine = TemplateUtil.createEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
|
|
||||||
Template template = templateEngine.getTemplate(templateConfig.getTemplatePath());
|
|
||||||
String content = template.render(bindMap);
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
return deptList.stream()
|
return deptList.stream()
|
||||||
.filter(dept -> dept.getParentId().equals(parentId))
|
.filter(dept -> dept.getParentId().equals(parentId))
|
||||||
.map(dept -> {
|
.map(dept -> {
|
||||||
DeptVO deptVO = deptConverter.toVo(dept);
|
DeptVO deptVO = deptConverter.convertToVo(dept);
|
||||||
List<DeptVO> children = recurDeptList(dept.getId(), deptList);
|
List<DeptVO> children = recurDeptList(dept.getId(), deptList);
|
||||||
deptVO.setChildren(children);
|
deptVO.setChildren(children);
|
||||||
return deptVO;
|
return deptVO;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
* 删除用户
|
* 删除用户
|
||||||
*
|
*
|
||||||
* @param idsStr 用户ID,多个以英文逗号(,)分割
|
* @param idsStr 用户ID,多个以英文逗号(,)分割
|
||||||
* @return
|
* @return true|false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteUsers(String idsStr) {
|
public boolean deleteUsers(String idsStr) {
|
||||||
@@ -175,7 +175,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param password 用户密码
|
* @param password 用户密码
|
||||||
* @return
|
* @return true|false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean updatePassword(Long userId, String password) {
|
public boolean updatePassword(Long userId, String password) {
|
||||||
|
|||||||
@@ -3,41 +3,7 @@ generator:
|
|||||||
## 模板配置
|
## 模板配置
|
||||||
templateConfigs:
|
templateConfigs:
|
||||||
Controller:
|
Controller:
|
||||||
templatePath: generator/controller.java.vm
|
## 模板路径
|
||||||
packageName: controller
|
templatePath: templates/generator/controller.java.vm
|
||||||
Service:
|
## 包名
|
||||||
templatePath: generator/service.java.vm
|
packageName: controller
|
||||||
packageName: service
|
|
||||||
ServiceImpl:
|
|
||||||
templatePath: generator/serviceImpl.java.vm
|
|
||||||
packageName: service.impl
|
|
||||||
Mapper:
|
|
||||||
templatePath: generator/mapper.java.vm
|
|
||||||
packageName: mapper
|
|
||||||
MapperXml:
|
|
||||||
templatePath: generator/mapper.xml.vm
|
|
||||||
packageName: mapper
|
|
||||||
extension: .xml
|
|
||||||
Query:
|
|
||||||
templatePath: generator/query.java.vm
|
|
||||||
packageName: model.query
|
|
||||||
Form:
|
|
||||||
templatePath: generator/form.java.vm
|
|
||||||
packageName: model.form
|
|
||||||
VO:
|
|
||||||
templatePath: generator/vo.java.vm
|
|
||||||
packageName: model.vo
|
|
||||||
Entity:
|
|
||||||
templatePath: generator/entity.java.vm
|
|
||||||
packageName: model.entity
|
|
||||||
API:
|
|
||||||
templatePath: generator/api.ts.vm
|
|
||||||
packageName: api
|
|
||||||
extension: .ts
|
|
||||||
VIEW:
|
|
||||||
templatePath: generator/index.vue.vm
|
|
||||||
packageName: views
|
|
||||||
extension: .vue
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +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.youlai.system.mapper.GenConfigMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,28 +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.youlai.system.mapper.GenFieldConfigMapper">
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="com.youlai.system.model.entity.GenFieldConfig">
|
|
||||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
|
||||||
<result property="configId" column="config_id" jdbcType="BIGINT"/>
|
|
||||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
|
||||||
<result property="type" column="type" jdbcType="VARCHAR"/>
|
|
||||||
<result property="description" column="description" jdbcType="VARCHAR"/>
|
|
||||||
<result property="showInList" column="show_in_list" jdbcType="TINYINT"/>
|
|
||||||
<result property="showInForm" column="show_in_form" jdbcType="TINYINT"/>
|
|
||||||
<result property="showInQuery" column="show_in_query" jdbcType="TINYINT"/>
|
|
||||||
<result property="formType" column="form_type" jdbcType="VARCHAR"/>
|
|
||||||
<result property="queryMethod" column="query_method" jdbcType="VARCHAR"/>
|
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
||||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id,config_id,name,
|
|
||||||
type,description,show_in_list,
|
|
||||||
show_in_form,show_in_query,form_type,
|
|
||||||
query_method,create_time,update_time
|
|
||||||
</sql>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
import request from "@/utils/request";
|
|
||||||
|
|
||||||
const ${className.toUpperCase()}_BASE_URL = "/api/v1/${className.toLowerCase()}s";
|
|
||||||
|
|
||||||
class ${className}API {
|
|
||||||
/** 获取${className}分页数据 */
|
|
||||||
static getPage(queryParams?: ${className}PageQuery) {
|
|
||||||
return request<any, PageResult<${className}PageVO[]>>({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/page`,
|
|
||||||
method: "get",
|
|
||||||
params: queryParams,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取${className}下拉数据源 */
|
|
||||||
static getOptions() {
|
|
||||||
return request<any, OptionType[]>({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/options`,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取${className}的菜单ID集合
|
|
||||||
*
|
|
||||||
* @param ${className.toLowerCase()}Id ${className}ID
|
|
||||||
* @returns ${className}的菜单ID集合
|
|
||||||
*/
|
|
||||||
static get${className}MenuIds(${className.toLowerCase()}Id: number) {
|
|
||||||
return request<any, number[]>({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/${${className.toLowerCase()}Id}/menuIds`,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分配菜单权限
|
|
||||||
*
|
|
||||||
* @param ${className.toLowerCase()}Id ${className}ID
|
|
||||||
* @param data 菜单ID集合
|
|
||||||
*/
|
|
||||||
static update${className}Menus(${className.toLowerCase()}Id: number, data: number[]) {
|
|
||||||
return request({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/${${className.toLowerCase()}Id}/menus`,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取${className}表单数据
|
|
||||||
*
|
|
||||||
* @param id ${className}ID
|
|
||||||
* @returns ${className}表单数据
|
|
||||||
*/
|
|
||||||
static getFormData(id: number) {
|
|
||||||
return request<any, ${className}Form>({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/${id}/form`,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 添加${className} */
|
|
||||||
static add(data: ${className}Form) {
|
|
||||||
return request({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}`,
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新${className}
|
|
||||||
*
|
|
||||||
* @param id ${className}ID
|
|
||||||
* @param data ${className}表单数据
|
|
||||||
*/
|
|
||||||
static update(id: number, data: ${className}Form) {
|
|
||||||
return request({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/${id}`,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${className},多个以英文逗号(,)分割
|
|
||||||
*
|
|
||||||
* @param ids ${className}ID字符串,多个以英文逗号(,)分割
|
|
||||||
*/
|
|
||||||
static deleteByIds(ids: string) {
|
|
||||||
return request({
|
|
||||||
url: `${${className.toUpperCase()}_BASE_URL}/${ids}`,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ${className}API;
|
|
||||||
|
|
||||||
/** ${className}分页查询参数 */
|
|
||||||
export interface ${className}PageQuery extends PageQuery {
|
|
||||||
/** 搜索关键字 */
|
|
||||||
keywords?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** ${className}分页对象 */
|
|
||||||
export interface ${className}PageVO {
|
|
||||||
#foreach($field in $fields)
|
|
||||||
/** ${field.comment} */
|
|
||||||
${field.name}?: ${field.type};
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
/** ${className}表单对象 */
|
|
||||||
export interface ${className}Form {
|
|
||||||
#foreach($field in $fields)
|
|
||||||
/** ${field.comment} */
|
|
||||||
${field.name}?: ${field.type};
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,8 @@ import ${package}.model.form.${entityName}Form;
|
|||||||
import ${package}.model.query.${entityName}PageQuery;
|
import ${package}.model.query.${entityName}PageQuery;
|
||||||
import ${package}.model.vo.${entityName}PageVO;
|
import ${package}.model.vo.${entityName}PageVO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.youlai.system.common.result.PageResult;
|
import com.youlai.common.result.PageResult;
|
||||||
import com.youlai.system.common.result.Result;
|
import com.youlai.common.result.Result;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}前端控制层
|
* $!{tableComment} 前端控制器
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
@@ -44,7 +44,7 @@ public class ${entityName}Controller {
|
|||||||
return Result.judge(result);
|
return Result.judge(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取$!{tableComment}表单数据")
|
@Operation(summary = "$!{tableComment}表单数据")
|
||||||
@GetMapping("/{id}/form")
|
@GetMapping("/{id}/form")
|
||||||
public Result<${entityName}Form> get${entityName}Form(
|
public Result<${entityName}Form> get${entityName}Form(
|
||||||
@Parameter(description = "$!{tableComment}ID") @PathVariable Long id
|
@Parameter(description = "$!{tableComment}ID") @PathVariable Long id
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import ${package}.model.entity.${entityName};
|
|||||||
import ${package}.model.form.${entityName}Form;
|
import ${package}.model.form.${entityName}Form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}对象转换器
|
* $!{tableComment}转换器
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
|
|||||||
@@ -23,14 +23,13 @@ import com.youlai.system.common.base.BaseEntity;
|
|||||||
public class ${entityName} extends BaseEntity {
|
public class ${entityName} extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
#if($fieldConfigs)
|
|
||||||
#foreach($fieldConfig in ${fieldConfigs})
|
#foreach($field in ${table.fields})
|
||||||
#if("$!fieldConfig.fieldComment" != "")
|
#if("$!field.comment" != "")
|
||||||
/**
|
/**
|
||||||
* ${fieldConfig.fieldComment}
|
* ${field.comment}
|
||||||
*/
|
*/
|
||||||
#end
|
#end
|
||||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ${package}.${subPackage};
|
package ${package}.model.form;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -11,12 +11,10 @@ import java.time.LocalDateTime;
|
|||||||
#if(${hasBigDecimal})
|
#if(${hasBigDecimal})
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
#end
|
#end
|
||||||
#if(${hasRequiredField})
|
|
||||||
import jakarta.validation.constraints.*;
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}表单对象
|
* $!{tableComment} 表单对象
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
@@ -30,22 +28,10 @@ public class ${entityName}Form implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
## ---------- BEGIN 字段循环遍历 ----------
|
||||||
#if($fieldConfigs)
|
#foreach($field in ${fields})
|
||||||
#foreach($fieldConfig in ${fieldConfigs})
|
#if("$!field.comment" != "")
|
||||||
#if($fieldConfig.showInForm)
|
@Schema(description = "${field.comment}")
|
||||||
#if($fieldConfig.isRequired)
|
|
||||||
#if($fieldConfig.fieldType == 'String')
|
|
||||||
@NotBlank(message = "$fieldConfig.fieldComment不能为空")
|
|
||||||
#else
|
|
||||||
@NotNull(message = "$fieldConfig.fieldComment不能为空")
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if("$!fieldConfig.fieldComment" != "")
|
|
||||||
@Schema(description = "${fieldConfig.fieldComment}")
|
|
||||||
#end
|
|
||||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<div class="search-container">
|
|
||||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
|
||||||
<el-form-item prop="keywords" label="关键字">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.keywords"
|
|
||||||
placeholder="${className}名称"
|
|
||||||
clearable
|
|
||||||
@keyup.enter="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="handleQuery">
|
|
||||||
<i-ep-search />
|
|
||||||
搜索
|
|
||||||
</el-button>
|
|
||||||
<el-button @click="handleResetQuery">
|
|
||||||
<i-ep-refresh />
|
|
||||||
重置
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card shadow="never" class="table-container">
|
|
||||||
<template #header>
|
|
||||||
<el-button type="success" @click="handleOpenDialog()">
|
|
||||||
<i-ep-plus />
|
|
||||||
新增
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
:disabled="ids.length === 0"
|
|
||||||
@click="handleDelete()"
|
|
||||||
>
|
|
||||||
<i-ep-delete />
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
ref="dataTableRef"
|
|
||||||
v-loading="loading"
|
|
||||||
:data="${className.toLowerCase()}List"
|
|
||||||
highlight-current-row
|
|
||||||
border
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
|
||||||
#foreach($field in $fields)
|
|
||||||
<el-table-column label="${field.comment}" prop="${field.name}" min-width="100" />
|
|
||||||
#end
|
|
||||||
|
|
||||||
<el-table-column fixed="right" label="操作" width="220">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
link
|
|
||||||
@click="handleOpenDialog(scope.row.id)"
|
|
||||||
>
|
|
||||||
<i-ep-edit />
|
|
||||||
编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
size="small"
|
|
||||||
link
|
|
||||||
@click="handleDelete(scope.row.id)"
|
|
||||||
>
|
|
||||||
<i-ep-delete />
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<pagination
|
|
||||||
v-if="total > 0"
|
|
||||||
v-model:total="total"
|
|
||||||
v-model:page="queryParams.pageNum"
|
|
||||||
v-model:limit="queryParams.pageSize"
|
|
||||||
@pagination="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<!-- ${className}表单弹窗 -->
|
|
||||||
<el-dialog
|
|
||||||
v-model="dialog.visible"
|
|
||||||
:title="dialog.title"
|
|
||||||
width="500px"
|
|
||||||
@close="handleCloseDialog"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
ref="${className.toLowerCase()}FormRef"
|
|
||||||
:model="formData"
|
|
||||||
:rules="rules"
|
|
||||||
label-width="100px"
|
|
||||||
>
|
|
||||||
#foreach($field in $fields)
|
|
||||||
<el-form-item label="${field.comment}" prop="${field.name}">
|
|
||||||
<el-input v-model="formData.${field.name}" placeholder="请输入${field.comment}" />
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<div class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
|
||||||
<el-button @click="handleCloseDialog">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
defineOptions({
|
|
||||||
name: "${className}",
|
|
||||||
inheritAttrs: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
import ${className}API, { ${className}PageVO, ${className}Form, ${className}PageQuery } from "@/api/${className.toLowerCase()}";
|
|
||||||
|
|
||||||
const queryFormRef = ref(ElForm);
|
|
||||||
const ${className.toLowerCase()}FormRef = ref(ElForm);
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const ids = ref<number[]>([]);
|
|
||||||
const total = ref(0);
|
|
||||||
|
|
||||||
const queryParams = reactive<${className}PageQuery>({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
});
|
|
||||||
|
|
||||||
// ${className}表格数据
|
|
||||||
const ${className.toLowerCase()}List = ref<${className}PageVO[]>();
|
|
||||||
|
|
||||||
// 弹窗
|
|
||||||
const dialog = reactive({
|
|
||||||
title: "",
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
// ${className}表单
|
|
||||||
const formData = reactive<${className}Form>({});
|
|
||||||
|
|
||||||
const rules = reactive({
|
|
||||||
#foreach($field in $fields)
|
|
||||||
${field.name}: [{ required: true, message: "请输入${field.comment}", trigger: "blur" }],
|
|
||||||
#end
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 查询 */
|
|
||||||
function handleQuery() {
|
|
||||||
loading.value = true;
|
|
||||||
${className}API.getPage(queryParams)
|
|
||||||
.then((data) => {
|
|
||||||
${className.toLowerCase()}List.value = data.list;
|
|
||||||
total.value = data.total;
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 重置查询 */
|
|
||||||
function handleResetQuery() {
|
|
||||||
queryFormRef.value.resetFields();
|
|
||||||
queryParams.pageNum = 1;
|
|
||||||
handleQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 行复选框选中记录选中ID集合 */
|
|
||||||
function handleSelectionChange(selection: any) {
|
|
||||||
ids.value = selection.map((item: any
|
|
||||||
@@ -7,7 +7,7 @@ import ${package}.model.query.${entityName}Query;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}Mapper接口
|
* $!{tableComment} 数据库访问层
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<mapper namespace="${package}.mapper.${entityName}Mapper">
|
<mapper namespace="${package}.mapper.${entityName}Mapper">
|
||||||
|
|
||||||
<!-- 获取${tableComment}分页列表 -->
|
<!-- 获取${tableComment}分页列表 -->
|
||||||
<select id="get${entityName}Page" resultType="${package}.model.vo.${entityName}VO">
|
<select id="listPaged${entityName}s" resultType="${package}.model.entity.${entityName}">
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}分页查询对象
|
* $!{tableComment}分页查询对象
|
||||||
*
|
*
|
||||||
@@ -23,14 +24,11 @@ import java.math.BigDecimal;
|
|||||||
public class ${entityName}Query extends BasePageQuery {
|
public class ${entityName}Query extends BasePageQuery {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
#if($fieldConfigs)
|
|
||||||
#foreach($fieldConfig in ${fieldConfigs})
|
#foreach($field in ${fields})
|
||||||
#if($fieldConfig.showInQuery)
|
#if("$!field.comment" != "")
|
||||||
#if("$!fieldConfig.fieldComment" != "")
|
@Schema(description = "${field.comment}")
|
||||||
@Schema(description = "${field.fieldComment}")
|
|
||||||
#end
|
|
||||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ import ${package}.model.query.${entityName}PageQuery;
|
|||||||
import ${package}.model.vo.${entityName}PageVO;
|
import ${package}.model.vo.${entityName}PageVO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}服务类
|
* $!{tableComment} 服务类
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
*/
|
*/
|
||||||
public interface ${entityName}Service extends IService<${entityName}> {
|
public interface ${entityName}Service extends IService<${entityName}> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*$!{tableComment}分页列表
|
*$!{tableComment}分页列表
|
||||||
*
|
*
|
||||||
@@ -22,6 +22,7 @@ public interface ${entityName}Service extends IService<${entityName}> {
|
|||||||
*/
|
*/
|
||||||
IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams);
|
IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取$!{tableComment}表单数据
|
* 获取$!{tableComment}表单数据
|
||||||
*
|
*
|
||||||
@@ -30,6 +31,7 @@ public interface ${entityName}Service extends IService<${entityName}> {
|
|||||||
*/
|
*/
|
||||||
${entityName}Form get${entityName}FormData(Long id);
|
${entityName}Form get${entityName}FormData(Long id);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增$!{tableComment}
|
* 新增$!{tableComment}
|
||||||
*
|
*
|
||||||
@@ -47,6 +49,7 @@ public interface ${entityName}Service extends IService<${entityName}> {
|
|||||||
*/
|
*/
|
||||||
boolean update${entityName}(Long id, ${entityName}Form formData);
|
boolean update${entityName}(Long id, ${entityName}Form formData);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除$!{tableComment}
|
* 删除$!{tableComment}
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {
|
public class ${table.serviceImplName} extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {
|
||||||
|
|
||||||
private final ${entityName}Converter ${lowerFirstEntityName}Converter;
|
private final ${entityName}Converter ${lowerFirstEntityName}Converter;
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
|||||||
* 删除$!{tableComment}
|
* 删除$!{tableComment}
|
||||||
*
|
*
|
||||||
* @param ids $!{tableComment}ID,多个以英文逗号(,)分割
|
* @param ids $!{tableComment}ID,多个以英文逗号(,)分割
|
||||||
* @return
|
* @return true|false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean delete${entityName}s(String ids) {
|
public boolean delete${entityName}s(String ids) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.math.BigDecimal;
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{tableComment}视图对象
|
* $!{tableComment} 图对象
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
@@ -27,12 +27,11 @@ public class ${entityName}VO implements Serializable {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
#if($fieldConfigs)
|
#foreach($field in ${fields})
|
||||||
#foreach($fieldConfig in ${fieldConfigs})
|
#if("$!field.comment" != "")
|
||||||
#if("$!fieldConfig.fieldComment" != "")
|
@Schema(description = "${field.comment}")
|
||||||
@Schema(description = "${fieldConfig.fieldComment}")
|
|
||||||
#end
|
|
||||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
|
||||||
#end
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user