Merge branch 'develop' of gitee.com:youlaiorg/youlai-boot
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
package com.youlai.system.config.property;
|
||||||
|
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码生成配置属性
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2.11.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "generator")
|
||||||
|
@Data
|
||||||
|
public class GeneratorProperties {
|
||||||
|
|
||||||
|
private Map<String, TemplateConfig> templateConfigs = MapUtil.newHashMap(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板配置
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class TemplateConfig{
|
||||||
|
|
||||||
|
private String templatePath;
|
||||||
|
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ public class SecurityProperties {
|
|||||||
public static class JwtProperty {
|
public static class JwtProperty {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JWT 秘钥
|
* JWT 密钥
|
||||||
*/
|
*/
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.youlai.system.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.youlai.system.common.result.PageResult;
|
||||||
|
import com.youlai.system.common.result.Result;
|
||||||
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
|
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.service.GeneratorService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Tag(name = "09.代码生成")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/generator")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GeneratorController {
|
||||||
|
|
||||||
|
private final GeneratorService generatorService;
|
||||||
|
|
||||||
|
@Operation(summary = "获取数据表分页列表")
|
||||||
|
@GetMapping("/table/page")
|
||||||
|
public PageResult<TablePageVO> getTablePage(
|
||||||
|
TablePageQuery queryParams
|
||||||
|
) {
|
||||||
|
Page<TablePageVO> result = generatorService.getTablePage(queryParams);
|
||||||
|
return PageResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取数据表字段列表")
|
||||||
|
@GetMapping("/table/{tableName}/columns")
|
||||||
|
public Result<List<TableColumnVO>> getTableColumns(
|
||||||
|
@Parameter(description = "表名", example = "sys_user") @PathVariable String tableName
|
||||||
|
) {
|
||||||
|
List<TableColumnVO> list = generatorService.getTableColumns(tableName);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "获取预览生成代码")
|
||||||
|
@GetMapping("/table/{tableName}/preview")
|
||||||
|
public Result<List<TableGeneratePreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
||||||
|
List<TableGeneratePreviewVO> list = generatorService.getTablePreviewData(tableName);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -36,6 +36,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,9 +55,9 @@ public class SysUserController {
|
|||||||
|
|
||||||
@Operation(summary = "用户分页列表")
|
@Operation(summary = "用户分页列表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@LogAnnotation( value = "用户分页列表",module = LogModuleEnum.USER)
|
@LogAnnotation(value = "用户分页列表", module = LogModuleEnum.USER)
|
||||||
public PageResult<UserPageVO> listPagedUsers(
|
public PageResult<UserPageVO> listPagedUsers(
|
||||||
UserPageQuery queryParams
|
UserPageQuery queryParams
|
||||||
) {
|
) {
|
||||||
IPage<UserPageVO> result = userService.listPagedUsers(queryParams);
|
IPage<UserPageVO> result = userService.listPagedUsers(queryParams);
|
||||||
return PageResult.success(result);
|
return PageResult.success(result);
|
||||||
@@ -138,9 +139,9 @@ public class SysUserController {
|
|||||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||||
String fileName = "用户导入模板.xlsx";
|
String fileName = "用户导入模板.xlsx";
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
||||||
|
|
||||||
String fileClassPath = "excel-templates" + File.separator + fileName;
|
String fileClassPath = "templates" + File.separator + "excel" + File.separator + fileName;
|
||||||
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileClassPath);
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileClassPath);
|
||||||
|
|
||||||
ServletOutputStream outputStream = response.getOutputStream();
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
@@ -151,7 +152,7 @@ public class SysUserController {
|
|||||||
|
|
||||||
@Operation(summary = "导入用户")
|
@Operation(summary = "导入用户")
|
||||||
@PostMapping("/import")
|
@PostMapping("/import")
|
||||||
public Result importUsers( MultipartFile file) throws IOException {
|
public Result importUsers(MultipartFile file) throws IOException {
|
||||||
UserImportListener listener = new UserImportListener();
|
UserImportListener listener = new UserImportListener();
|
||||||
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportDTO.class, listener);
|
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportDTO.class, listener);
|
||||||
return Result.success(msg);
|
return Result.success(msg);
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import org.mapstruct.Mapper;
|
|||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface DeptConverter {
|
public interface DeptConverter {
|
||||||
|
|
||||||
DeptForm convertToForm(SysDept entity);
|
DeptForm toForm(SysDept entity);
|
||||||
|
|
||||||
DeptVO convertToVo(SysDept entity);
|
DeptVO convertToVo(SysDept entity);
|
||||||
|
|
||||||
SysDept convertToEntity(DeptForm deptForm);
|
SysDept toEntity(DeptForm deptForm);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ public interface DictConverter {
|
|||||||
|
|
||||||
Page<DictPageVO> convertToPageVo(Page<SysDict> page);
|
Page<DictPageVO> convertToPageVo(Page<SysDict> page);
|
||||||
|
|
||||||
DictForm convertToForm(SysDict entity);
|
DictForm toForm(SysDict entity);
|
||||||
|
|
||||||
SysDict convertToEntity(DictForm entity);
|
SysDict toEntity(DictForm entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ public interface DictItemConverter {
|
|||||||
|
|
||||||
Page<DictPageVO> convertToPageVo(Page<SysDictItem> page);
|
Page<DictPageVO> convertToPageVo(Page<SysDictItem> page);
|
||||||
|
|
||||||
DictForm convertToForm(SysDictItem entity);
|
DictForm toForm(SysDictItem entity);
|
||||||
|
|
||||||
SysDictItem convertToEntity(DictForm.DictItem dictFormDictItems);
|
SysDictItem toEntity(DictForm.DictItem dictFormDictItems);
|
||||||
List<SysDictItem> convertToEntity(List<DictForm.DictItem> dictFormDictItems);
|
List<SysDictItem> toEntity(List<DictForm.DictItem> dictFormDictItems);
|
||||||
|
|
||||||
DictForm.DictItem convertToDictFormDictItem(SysDictItem entity);
|
DictForm.DictItem convertToDictFormDictItem(SysDictItem entity);
|
||||||
List<DictForm.DictItem> convertToDictFormDictItem(List<SysDictItem> entities);
|
List<DictForm.DictItem> convertToDictFormDictItem(List<SysDictItem> entities);
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ public interface MenuConverter {
|
|||||||
MenuVO convertToVo(SysMenu entity);
|
MenuVO convertToVo(SysMenu entity);
|
||||||
|
|
||||||
@Mapping(target = "params", ignore = true)
|
@Mapping(target = "params", ignore = true)
|
||||||
MenuForm convertToForm(SysMenu entity);
|
MenuForm toForm(SysMenu entity);
|
||||||
|
|
||||||
@Mapping(target = "params", ignore = true)
|
@Mapping(target = "params", ignore = true)
|
||||||
SysMenu convertToEntity(MenuForm menuForm);
|
SysMenu toEntity(MenuForm menuForm);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ public interface RoleConverter {
|
|||||||
|
|
||||||
List<Option> entities2Options(List<SysRole> roles);
|
List<Option> entities2Options(List<SysRole> roles);
|
||||||
|
|
||||||
SysRole convertToEntity(RoleForm roleForm);
|
SysRole toEntity(RoleForm roleForm);
|
||||||
|
|
||||||
RoleForm convertToForm(SysRole entity);
|
RoleForm toForm(SysRole entity);
|
||||||
}
|
}
|
||||||
@@ -28,16 +28,16 @@ public interface UserConverter {
|
|||||||
|
|
||||||
Page<UserPageVO> toPageVo(Page<UserBO> bo);
|
Page<UserPageVO> toPageVo(Page<UserBO> bo);
|
||||||
|
|
||||||
UserForm convertToForm(SysUser entity);
|
UserForm toForm(SysUser entity);
|
||||||
|
|
||||||
@InheritInverseConfiguration(name = "convertToForm")
|
@InheritInverseConfiguration(name = "toForm")
|
||||||
SysUser convertToEntity(UserForm entity);
|
SysUser toEntity(UserForm entity);
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@Mapping(target = "userId", source = "id")
|
@Mapping(target = "userId", source = "id")
|
||||||
})
|
})
|
||||||
UserInfoVO toUserInfoVo(SysUser entity);
|
UserInfoVO toUserInfoVo(SysUser entity);
|
||||||
|
|
||||||
SysUser convertToEntity(UserImportDTO vo);
|
SysUser toEntity(UserImportDTO vo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/main/java/com/youlai/system/mapper/DatabaseMapper.java
Normal file
23
src/main/java/com/youlai/system/mapper/DatabaseMapper.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.youlai.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.youlai.system.model.entity.SysDept;
|
||||||
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
|
import com.youlai.system.model.vo.TableColumnVO;
|
||||||
|
import com.youlai.system.model.vo.TablePageVO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DatabaseMapper extends BaseMapper<SysDept> {
|
||||||
|
|
||||||
|
|
||||||
|
Page<TablePageVO> getTablePage(Page<TablePageVO> page, TablePageQuery queryParams);
|
||||||
|
|
||||||
|
List<TableColumnVO> getTableColumns(String tableName);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.youlai.system.model.form;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "代码生成配置表单")
|
||||||
|
@Data
|
||||||
|
public class GeneratorConfigForm {
|
||||||
|
|
||||||
|
@Schema(description = "表名")
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
@Schema(description = "实体名")
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
|
@Schema(description = "包名")
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
@Schema(description = "模块名")
|
||||||
|
private String moduleName;
|
||||||
|
|
||||||
|
@Schema(description = "作者")
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
@Schema(description = "字段配置")
|
||||||
|
private List<FieldConfig> fieldConfigs;
|
||||||
|
|
||||||
|
@Schema(description = "字段配置")
|
||||||
|
@Data
|
||||||
|
public static class FieldConfig {
|
||||||
|
|
||||||
|
@Schema(description = "字段名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "字段类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "字段描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "是否在列表显示")
|
||||||
|
private Boolean showInList;
|
||||||
|
|
||||||
|
@Schema(description = "是否在表单显示")
|
||||||
|
private Boolean showInForm;
|
||||||
|
|
||||||
|
@Schema(description = "是否在查询条件显示")
|
||||||
|
private Boolean showInQuery;
|
||||||
|
|
||||||
|
@Schema(description = "表单类型")
|
||||||
|
private String formType;
|
||||||
|
|
||||||
|
@Schema(description = "查询方式")
|
||||||
|
private String queryMethod;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.youlai.system.model.query;
|
||||||
|
|
||||||
|
import com.youlai.system.common.base.BasePageQuery;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据表分页查询对象
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2.10.0
|
||||||
|
*/
|
||||||
|
@Schema(description = "数据表分页查询对象")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class TablePageQuery extends BasePageQuery {
|
||||||
|
|
||||||
|
@Schema(description="关键字(表名)")
|
||||||
|
private String keywords;
|
||||||
|
|
||||||
|
}
|
||||||
34
src/main/java/com/youlai/system/model/vo/TableColumnVO.java
Normal file
34
src/main/java/com/youlai/system/model/vo/TableColumnVO.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package com.youlai.system.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "数据表字段VO")
|
||||||
|
@Data
|
||||||
|
public class TableColumnVO {
|
||||||
|
|
||||||
|
@Schema(description = "字段名称", example = "id")
|
||||||
|
private String columnName;
|
||||||
|
|
||||||
|
@Schema(description = "字段类型", example = "bigint")
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
@Schema(description = "字段描述", example = "主键")
|
||||||
|
private String columnComment;
|
||||||
|
|
||||||
|
@Schema(description = "字段长度", example = "20")
|
||||||
|
private Integer characterMaximumLength;
|
||||||
|
|
||||||
|
@Schema(description = "是否主键(1-是 0-否)", example = "1")
|
||||||
|
private Integer isPrimaryKey;
|
||||||
|
|
||||||
|
@Schema(description = "是否可为空(1-是 0-否)", example = "1")
|
||||||
|
private String isNullable;
|
||||||
|
|
||||||
|
@Schema(description = "字符集", example = "utf8mb4")
|
||||||
|
private String characterSetName;
|
||||||
|
|
||||||
|
@Schema(description = "字符集排序规则", example = "utf8mb4_general_ci")
|
||||||
|
private String collationName;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.youlai.system.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "表生成代码预览VO")
|
||||||
|
@Data
|
||||||
|
public class TableGeneratePreviewVO {
|
||||||
|
|
||||||
|
@Schema(description = "生成文件路径")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@Schema(description = "生成文件名称",example = "SysUser.java" )
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@Schema(description = "生成文件内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
}
|
||||||
29
src/main/java/com/youlai/system/model/vo/TablePageVO.java
Normal file
29
src/main/java/com/youlai/system/model/vo/TablePageVO.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package com.youlai.system.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "数据表分页VO")
|
||||||
|
@Data
|
||||||
|
public class TablePageVO {
|
||||||
|
|
||||||
|
@Schema(description = "数据表名称", example = "sys_user")
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
@Schema(description = "数据表注释",example = "用户表")
|
||||||
|
private String tableComment;
|
||||||
|
|
||||||
|
@Schema(description = "数据表排序规则",example = "用户表")
|
||||||
|
private String tableCollation;
|
||||||
|
|
||||||
|
@Schema(description = "存储引擎",example = "InnoDB")
|
||||||
|
private String engine;
|
||||||
|
|
||||||
|
@Schema(description = "字符集",example = "utf8mb4_general_ci")
|
||||||
|
private String charset;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间",example = "2023-08-08 08:08:08")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -104,7 +104,7 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportDTO> {
|
|||||||
|
|
||||||
if (validationMsg.isEmpty()) {
|
if (validationMsg.isEmpty()) {
|
||||||
// 校验通过,持久化至数据库
|
// 校验通过,持久化至数据库
|
||||||
SysUser entity = userConverter.convertToEntity(userImportDTO);
|
SysUser entity = userConverter.toEntity(userImportDTO);
|
||||||
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
|
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
|
||||||
// 性别翻译
|
// 性别翻译
|
||||||
String genderLabel = userImportDTO.getGenderLabel();
|
String genderLabel = userImportDTO.getGenderLabel();
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.youlai.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
|
import com.youlai.system.model.vo.TableColumnVO;
|
||||||
|
import com.youlai.system.model.vo.TableGeneratePreviewVO;
|
||||||
|
import com.youlai.system.model.vo.TablePageVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库服务接口
|
||||||
|
*
|
||||||
|
* @author haoxr
|
||||||
|
* @since 2.11.0
|
||||||
|
*/
|
||||||
|
public interface GeneratorService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据表分页列表
|
||||||
|
*
|
||||||
|
* @param queryParams 查询参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<TablePageVO> getTablePage(TablePageQuery queryParams);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据表字段列表
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TableColumnVO> getTableColumns(String tableName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预览生成代码
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TableGeneratePreviewVO> getTablePreviewData(String tableName);
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package com.youlai.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.extra.template.Template;
|
||||||
|
import cn.hutool.extra.template.TemplateConfig;
|
||||||
|
import cn.hutool.extra.template.TemplateEngine;
|
||||||
|
import cn.hutool.extra.template.TemplateUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.youlai.system.mapper.DatabaseMapper;
|
||||||
|
import com.youlai.system.model.query.TablePageQuery;
|
||||||
|
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.service.GeneratorService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import cn.hutool.extra.template.TemplateConfig.ResourceMode;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库服务实现类
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2.11.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GeneratorServiceImpl implements GeneratorService {
|
||||||
|
|
||||||
|
private final DatabaseMapper databaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据表分页列表
|
||||||
|
*
|
||||||
|
* @param queryParams 查询参数
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
public Page<TablePageVO> getTablePage(TablePageQuery queryParams) {
|
||||||
|
Page<TablePageVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
|
||||||
|
return databaseMapper.getTablePage(page, queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据表字段列表
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return 字段列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TableColumnVO> getTableColumns(String tableName) {
|
||||||
|
return databaseMapper.getTableColumns(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预览生成代码
|
||||||
|
*
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return 预览数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TableGeneratePreviewVO> getTablePreviewData(String tableName) {
|
||||||
|
|
||||||
|
List<TableGeneratePreviewVO> list = new ArrayList<>();
|
||||||
|
|
||||||
|
TemplateConfig templateConfig = new TemplateConfig("templates" , ResourceMode.CLASSPATH);
|
||||||
|
TemplateEngine templateEngine = TemplateUtil.createEngine(templateConfig);
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> bindingMap = new HashMap<>();
|
||||||
|
bindingMap.put("tableName", "sys_user");
|
||||||
|
bindingMap.put("author", "Ray");
|
||||||
|
bindingMap.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||||
|
bindingMap.put("entityName", "User" );
|
||||||
|
bindingMap.put("lowerFirstEntityName", "user");
|
||||||
|
bindingMap.put("tableComment", "用户");
|
||||||
|
|
||||||
|
// 包路径
|
||||||
|
bindingMap.put("package", "com.youlai.system");
|
||||||
|
|
||||||
|
Template template = templateEngine.getTemplate("generator" + File.separator + "controller.java.vm");
|
||||||
|
String content = template.render(bindingMap);
|
||||||
|
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);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String generatePath(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -141,7 +141,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
Assert.isTrue(count == 0, "部门编号已存在");
|
Assert.isTrue(count == 0, "部门编号已存在");
|
||||||
|
|
||||||
// form->entity
|
// form->entity
|
||||||
SysDept entity = deptConverter.convertToEntity(formData);
|
SysDept entity = deptConverter.toEntity(formData);
|
||||||
|
|
||||||
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
||||||
String treePath = generateDeptTreePath(formData.getParentId());
|
String treePath = generateDeptTreePath(formData.getParentId());
|
||||||
@@ -164,7 +164,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
@Override
|
@Override
|
||||||
public DeptForm getDeptForm(Long deptId) {
|
public DeptForm getDeptForm(Long deptId) {
|
||||||
SysDept entity = this.getById(deptId);
|
SysDept entity = this.getById(deptId);
|
||||||
return deptConverter.convertToForm(entity);
|
return deptConverter.toForm(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
|
|
||||||
|
|
||||||
// form->entity
|
// form->entity
|
||||||
SysDept entity = deptConverter.convertToEntity(formData);
|
SysDept entity = deptConverter.toEntity(formData);
|
||||||
entity.setId(deptId);
|
entity.setId(deptId);
|
||||||
|
|
||||||
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.youlai.system.service.impl;
|
package com.youlai.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@@ -62,7 +61,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
@Override
|
@Override
|
||||||
public boolean saveDict(DictForm dictForm) {
|
public boolean saveDict(DictForm dictForm) {
|
||||||
// 保存字典
|
// 保存字典
|
||||||
SysDict entity = dictConverter.convertToEntity(dictForm);
|
SysDict entity = dictConverter.toEntity(dictForm);
|
||||||
|
|
||||||
// 校验 code 是否唯一
|
// 校验 code 是否唯一
|
||||||
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
||||||
@@ -74,7 +73,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
// 保存字典项
|
// 保存字典项
|
||||||
if (result) {
|
if (result) {
|
||||||
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
|
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
|
||||||
List<SysDictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
|
List<SysDictItem> dictItems = dictItemConverter.toEntity(dictFormDictItems);
|
||||||
dictItems.forEach(dictItem -> dictItem.setDictId(entity.getId()));
|
dictItems.forEach(dictItem -> dictItem.setDictId(entity.getId()));
|
||||||
dictItemService.saveBatch(dictItems);
|
dictItemService.saveBatch(dictItems);
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
// 获取字典
|
// 获取字典
|
||||||
SysDict entity = this.getById(id);
|
SysDict entity = this.getById(id);
|
||||||
Assert.isTrue(entity != null, "字典不存在");
|
Assert.isTrue(entity != null, "字典不存在");
|
||||||
DictForm dictForm = dictConverter.convertToForm(entity);
|
DictForm dictForm = dictConverter.toForm(entity);
|
||||||
|
|
||||||
// 获取字典项集合
|
// 获取字典项集合
|
||||||
List<SysDictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
|
List<SysDictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
|
||||||
@@ -113,7 +112,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateDict(Long id, DictForm dictForm) {
|
public boolean updateDict(Long id, DictForm dictForm) {
|
||||||
// 更新字典
|
// 更新字典
|
||||||
SysDict entity = dictConverter.convertToEntity(dictForm);
|
SysDict entity = dictConverter.toEntity(dictForm);
|
||||||
|
|
||||||
// 校验 code 是否唯一
|
// 校验 code 是否唯一
|
||||||
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
||||||
@@ -127,7 +126,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
if (result) {
|
if (result) {
|
||||||
// 更新字典项
|
// 更新字典项
|
||||||
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
|
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
|
||||||
List<SysDictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
|
List<SysDictItem> dictItems = dictItemConverter.toEntity(dictFormDictItems);
|
||||||
|
|
||||||
// 获取当前数据库中的字典项
|
// 获取当前数据库中的字典项
|
||||||
List<SysDictItem> currentDictItemEntities = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
|
List<SysDictItem> currentDictItemEntities = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
menuForm.setComponent(null);
|
menuForm.setComponent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
SysMenu entity = menuConverter.convertToEntity(menuForm);
|
SysMenu entity = menuConverter.toEntity(menuForm);
|
||||||
String treePath = generateMenuTreePath(menuForm.getParentId());
|
String treePath = generateMenuTreePath(menuForm.getParentId());
|
||||||
entity.setTreePath(treePath);
|
entity.setTreePath(treePath);
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
public MenuForm getMenuForm(Long id) {
|
public MenuForm getMenuForm(Long id) {
|
||||||
SysMenu entity = this.getById(id);
|
SysMenu entity = this.getById(id);
|
||||||
Assert.isTrue(entity != null, "菜单不存在");
|
Assert.isTrue(entity != null, "菜单不存在");
|
||||||
MenuForm formData = menuConverter.convertToForm(entity);
|
MenuForm formData = menuConverter.toForm(entity);
|
||||||
// 路由参数字符串 {"id":"1","name":"张三"} 转换为 [{key:"id", value:"1"}, {key:"name", value:"张三"}]
|
// 路由参数字符串 {"id":"1","name":"张三"} 转换为 [{key:"id", value:"1"}, {key:"name", value:"张三"}]
|
||||||
String params = entity.getParams();
|
String params = entity.getParams();
|
||||||
if (StrUtil.isNotBlank(params)) {
|
if (StrUtil.isNotBlank(params)) {
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
|
|||||||
list.forEach(item -> {
|
list.forEach(item -> {
|
||||||
String roleCode = item.getRoleCode();
|
String roleCode = item.getRoleCode();
|
||||||
Set<String> perms = item.getPerms();
|
Set<String> perms = item.getPerms();
|
||||||
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
|
if (CollectionUtil.isNotEmpty(perms)) {
|
||||||
|
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +75,9 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<String> perms = rolePerms.getPerms();
|
Set<String> perms = rolePerms.getPerms();
|
||||||
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
|
if (CollectionUtil.isNotEmpty(perms)) {
|
||||||
|
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
Assert.isTrue(count == 0, "角色名称或角色编码已存在,请修改后重试!");
|
Assert.isTrue(count == 0, "角色名称或角色编码已存在,请修改后重试!");
|
||||||
|
|
||||||
// 实体转换
|
// 实体转换
|
||||||
SysRole role = roleConverter.convertToEntity(roleForm);
|
SysRole role = roleConverter.toEntity(roleForm);
|
||||||
|
|
||||||
boolean result = this.saveOrUpdate(role);
|
boolean result = this.saveOrUpdate(role);
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -143,7 +143,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
@Override
|
@Override
|
||||||
public RoleForm getRoleForm(Long roleId) {
|
public RoleForm getRoleForm(Long roleId) {
|
||||||
SysRole entity = this.getById(roleId);
|
SysRole entity = this.getById(roleId);
|
||||||
return roleConverter.convertToForm(entity);
|
return roleConverter.toForm(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
Assert.isTrue(count == 0, "用户名已存在");
|
Assert.isTrue(count == 0, "用户名已存在");
|
||||||
|
|
||||||
// 实体转换 form->entity
|
// 实体转换 form->entity
|
||||||
SysUser entity = userConverter.convertToEntity(userForm);
|
SysUser entity = userConverter.toEntity(userForm);
|
||||||
|
|
||||||
// 设置默认加密密码
|
// 设置默认加密密码
|
||||||
String defaultEncryptPwd = passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD);
|
String defaultEncryptPwd = passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD);
|
||||||
@@ -141,7 +141,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
Assert.isTrue(count == 0, "用户名已存在");
|
Assert.isTrue(count == 0, "用户名已存在");
|
||||||
|
|
||||||
// form -> entity
|
// form -> entity
|
||||||
SysUser entity = userConverter.convertToEntity(userForm);
|
SysUser entity = userConverter.toEntity(userForm);
|
||||||
|
|
||||||
// 修改用户
|
// 修改用户
|
||||||
boolean result = this.updateById(entity);
|
boolean result = this.updateById(entity);
|
||||||
|
|||||||
9
src/main/resources/application-generator.yml
Normal file
9
src/main/resources/application-generator.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
### 代码生成器配置
|
||||||
|
generator:
|
||||||
|
## 模板配置
|
||||||
|
templateConfigs:
|
||||||
|
Controller:
|
||||||
|
## 模板路径
|
||||||
|
templatePath: templates/generator/controller.java.vm
|
||||||
|
## 包名
|
||||||
|
packageName: controller
|
||||||
@@ -3,3 +3,5 @@ spring:
|
|||||||
name: youlai-boot
|
name: youlai-boot
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
|
include:
|
||||||
|
- generator
|
||||||
43
src/main/resources/mapper/DatabaseMapper.xml
Normal file
43
src/main/resources/mapper/DatabaseMapper.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?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.DatabaseMapper">
|
||||||
|
|
||||||
|
<!-- 查询数据库表分页 -->
|
||||||
|
<select id="getTablePage" resultType="com.youlai.system.model.vo.TablePageVO">
|
||||||
|
SELECT
|
||||||
|
TABLE_NAME ,
|
||||||
|
TABLE_COMMENT ,
|
||||||
|
TABLE_COLLATION,
|
||||||
|
ENGINE,
|
||||||
|
CREATE_TIME
|
||||||
|
FROM
|
||||||
|
information_schema.tables
|
||||||
|
WHERE
|
||||||
|
TABLE_SCHEMA = (SELECT DATABASE())
|
||||||
|
AND table_type = 'BASE TABLE'
|
||||||
|
<if test="queryParams.keywords != null and queryParams.keywords.trim() neq ''">
|
||||||
|
AND TABLE_NAME LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
|
</if>
|
||||||
|
ORDER BY
|
||||||
|
CREATE_TIME DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getTableColumns" resultType="com.youlai.system.model.vo.TableColumnVO">
|
||||||
|
SELECT
|
||||||
|
COLUMN_NAME,
|
||||||
|
DATA_TYPE,
|
||||||
|
COLUMN_COMMENT,
|
||||||
|
CASE COLUMN_KEY WHEN 'PRI' THEN 1 ELSE 0 END AS isPrimaryKey,
|
||||||
|
IS_NULLABLE,
|
||||||
|
CHARACTER_MAXIMUM_LENGTH,
|
||||||
|
CHARACTER_SET_NAME,
|
||||||
|
COLLATION_NAME
|
||||||
|
FROM
|
||||||
|
information_schema.columns
|
||||||
|
WHERE
|
||||||
|
TABLE_SCHEMA = (SELECT DATABASE())
|
||||||
|
AND TABLE_NAME = #{tableName}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
72
src/main/resources/templates/generator/controller.java.vm
Normal file
72
src/main/resources/templates/generator/controller.java.vm
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package ${package}.controller;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import ${package}.model.form.${entityName}Form;
|
||||||
|
import ${package}.model.query.${entityName}PageQuery;
|
||||||
|
import ${package}.model.vo.${entityName}PageVO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.youlai.common.result.PageResult;
|
||||||
|
import com.youlai.common.result.Result;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment} 前端控制器
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Tag(name = "${tableComment}接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/${lowerFirstEntityName}s")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ${entityName}Controller {
|
||||||
|
|
||||||
|
private final ${entityName}Serivie ${lowerFirstEntityName}Service;
|
||||||
|
|
||||||
|
@Operation(summary = "$!{tableComment}分页列表")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public PageResult<${entityName}PageVO> get${entityName}Page(${entityName}PageQuery queryParams ) {
|
||||||
|
IPage<${entityName}PageVO> result = ${lowerFirstEntityName}Service.get${entityName}Page(queryParams);
|
||||||
|
return PageResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增$!{tableComment}")
|
||||||
|
@PostMapping
|
||||||
|
public Result save${entityName}(@RequestBody @Valid ${entityName}Form formData ) {
|
||||||
|
boolean result = ${lowerFirstEntityName}Service.save${entityName}(formData);
|
||||||
|
return Result.judge(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "$!{tableComment}表单数据")
|
||||||
|
@GetMapping("/{id}/form")
|
||||||
|
public Result<${entityName}Form> get${entityName}Form(
|
||||||
|
@Parameter(description = "$!{tableComment}ID") @PathVariable Long id
|
||||||
|
) {
|
||||||
|
${entityName}Form formData = ${lowerFirstEntityName}Service.get${entityName}FormData(id);
|
||||||
|
return Result.success(formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改$!{tableComment}")
|
||||||
|
@PutMapping(value = "/{id}")
|
||||||
|
public Result update${entityName}(@Parameter(description = "$!{tableComment}ID") @PathVariable Long id,
|
||||||
|
@RequestBody @Validated ${entityName}Form formData) {
|
||||||
|
boolean result = ${lowerFirstEntityName}Service.update${entityName}(id, formData);
|
||||||
|
return Result.judge(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除$!{tableComment}")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result delete${entityName}s(
|
||||||
|
@Parameter(description = "$!{tableComment}ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||||
|
) {
|
||||||
|
boolean result = ${lowerFirstEntityName}Service.delete${entityName}s(ids);
|
||||||
|
return Result.judge(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/resources/templates/generator/converter.java.vm
Normal file
20
src/main/resources/templates/generator/converter.java.vm
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package ${package}.converter;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import ${package}.model.entity.${entityName};
|
||||||
|
import ${package}.model.form.${entityName}Form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment}转换器
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface ${entityName}Converter{
|
||||||
|
|
||||||
|
${entityName}Form toForm(${entityName} entity);
|
||||||
|
|
||||||
|
${entityName} toEntity(${entityName}Form entity);
|
||||||
|
}
|
||||||
35
src/main/resources/templates/generator/entity.java.vm
Normal file
35
src/main/resources/templates/generator/entity.java.vm
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package ${package}.model.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
#if(${hasLocalDateTime})
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
#end
|
||||||
|
#if(${hasBigDecimal})
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
#end
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment}实体对象
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("${tableName}")
|
||||||
|
public class ${entityName} extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
#foreach($field in ${table.fields})
|
||||||
|
#if("$!field.comment" != "")
|
||||||
|
/**
|
||||||
|
* ${field.comment}
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
|
#end
|
||||||
|
}
|
||||||
37
src/main/resources/templates/generator/form.java.vm
Normal file
37
src/main/resources/templates/generator/form.java.vm
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package ${package}.model.form;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
#if(${hasLocalDateTime})
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
#end
|
||||||
|
#if(${hasBigDecimal})
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment} 表单对象
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Schema(description = "$!{tableComment}表单对象")
|
||||||
|
public class ${entityName}Form implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
## ---------- BEGIN 字段循环遍历 ----------
|
||||||
|
#foreach($field in ${fields})
|
||||||
|
#if("$!field.comment" != "")
|
||||||
|
@Schema(description = "${field.comment}")
|
||||||
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
|
#end
|
||||||
|
}
|
||||||
27
src/main/resources/templates/generator/mapper.java.vm
Normal file
27
src/main/resources/templates/generator/mapper.java.vm
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package ${package}.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import ${package}.model.entity.${entityName};
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import ${package}.model.query.${entityName}Query;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment} 数据库访问层
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取$!{tableComment}分页数据
|
||||||
|
*
|
||||||
|
* @param page 分页对象
|
||||||
|
* @param queryParams 查询参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<${entityName}VO> get${entityName}Page(Page<${entityName}VO> page, ${entityName}Query queryParams);
|
||||||
|
|
||||||
|
}
|
||||||
29
src/main/resources/templates/generator/mapper.xml.vm
Normal file
29
src/main/resources/templates/generator/mapper.xml.vm
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?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}.mapper.${entityName}Mapper">
|
||||||
|
|
||||||
|
<!-- 获取${tableComment}分页列表 -->
|
||||||
|
<select id="listPaged${entityName}s" resultType="${package}.model.entity.${entityName}">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
${tableName}
|
||||||
|
<where>
|
||||||
|
is_deleted = 0
|
||||||
|
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
||||||
|
AND (
|
||||||
|
name LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="queryParams.startTime != null">
|
||||||
|
AND create_time >= #{queryParams.startTime}
|
||||||
|
</if>
|
||||||
|
<if test="queryParams.endTime != null">
|
||||||
|
AND create_time <= #{queryParams.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY
|
||||||
|
create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
34
src/main/resources/templates/generator/query.java.vm
Normal file
34
src/main/resources/templates/generator/query.java.vm
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package ${package}.model.query;
|
||||||
|
|
||||||
|
import com.youlai.common.base.BasePageQuery;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
#if(${hasLocalDateTime})
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
#end
|
||||||
|
#if(${hasBigDecimal})
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment}分页查询对象
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Schema(description ="$!{tableComment}分页查询对象")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ${entityName}Query extends BasePageQuery {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
#foreach($field in ${fields})
|
||||||
|
#if("$!field.comment" != "")
|
||||||
|
@Schema(description = "${field.comment}")
|
||||||
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
|
#end
|
||||||
|
}
|
||||||
61
src/main/resources/templates/generator/service.java.vm
Normal file
61
src/main/resources/templates/generator/service.java.vm
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package ${package}.Service;
|
||||||
|
|
||||||
|
import ${package}.model.entity.${entityName};
|
||||||
|
import ${package}.model.form.${entityName}Form;
|
||||||
|
import ${package}.model.query.${entityName}PageQuery;
|
||||||
|
import ${package}.model.vo.${entityName}PageVO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
/**
|
||||||
|
* $!{tableComment} 服务类
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
public interface ${entityName}Service extends IService<${entityName}> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*$!{tableComment}分页列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取$!{tableComment}表单数据
|
||||||
|
*
|
||||||
|
* @param id $!{tableComment}ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
${entityName}Form get${entityName}FormData(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增$!{tableComment}
|
||||||
|
*
|
||||||
|
* @param formData $!{tableComment}表单对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean save${entityName}(${entityName}Form formData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改$!{tableComment}
|
||||||
|
*
|
||||||
|
* @param id $!{tableComment}ID
|
||||||
|
* @param formData $!{tableComment}表单对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean update${entityName}(Long id, ${entityName}Form formData);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除$!{tableComment}
|
||||||
|
*
|
||||||
|
* @param ids $!{tableComment}ID,多个以英文逗号(,)分割
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean delete${entityName}s(String ids);
|
||||||
|
|
||||||
|
}
|
||||||
103
src/main/resources/templates/generator/serviceImpl.java.vm
Normal file
103
src/main/resources/templates/generator/serviceImpl.java.vm
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package ${package}.service.impl;
|
||||||
|
|
||||||
|
import ${package}.model.entity.${entityName};
|
||||||
|
import ${package}.mapper.${entityName}Mapper;
|
||||||
|
import ${package}.service.${entityName}Service;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ${package}.model.form.${entityName}Form;
|
||||||
|
import ${package}.model.query.${entityName}Query;
|
||||||
|
import ${package}.model.vo.${entityName}PageVO;
|
||||||
|
import ${package}.converter.${entityName}Converter;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment}服务实现类
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ${table.serviceImplName} extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {
|
||||||
|
|
||||||
|
private final ${entityName}Converter ${lowerFirstEntityName}Converter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取$!{tableComment}分页列表
|
||||||
|
*
|
||||||
|
* @param queryParams 查询参数
|
||||||
|
* @return {@link IPage<${entityName}PageVO>} $!{tableComment}分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams) {
|
||||||
|
Page<${entityName}VO> pageVO = this.baseMapper.get${entityName}Page(
|
||||||
|
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||||
|
queryParams
|
||||||
|
);
|
||||||
|
returnv pageVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取$!{tableComment}表单数据
|
||||||
|
*
|
||||||
|
* @param id $!{tableComment}ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ${entityName}Form get${entityName}FormData(Long id) {
|
||||||
|
${entityName} entity = this.getById(id);
|
||||||
|
return ${lowerFirstEntityName}Converter.toForm(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增$!{tableComment}
|
||||||
|
*
|
||||||
|
* @param formData $!{tableComment}表单对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean save${entityName}(${entityName}Form formData) {
|
||||||
|
${entityName} entity = ${lowerFirstEntityName}Converter.toEntity(formData);
|
||||||
|
return this.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新$!{tableComment}
|
||||||
|
*
|
||||||
|
* @param id $!{tableComment}ID
|
||||||
|
* @param formData $!{tableComment}表单对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean update${entityName}(Long id,${entityName}Form formData) {
|
||||||
|
${entityName} entity = ${lowerFirstEntityName}Converter.toEntity(formData);
|
||||||
|
return this.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除$!{tableComment}
|
||||||
|
*
|
||||||
|
* @param ids $!{tableComment}ID,多个以英文逗号(,)分割
|
||||||
|
* @return true|false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean delete${entityName}s(String ids) {
|
||||||
|
Assert.isTrue(StrUtil.isNotBlank(ids), "删除的$!{tableComment}数据为空");
|
||||||
|
// 逻辑删除
|
||||||
|
List<Long> idList = Arrays.stream(ids.split(","))
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.toList();
|
||||||
|
return this.removeByIds(idList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
src/main/resources/templates/generator/vo.java.vm
Normal file
37
src/main/resources/templates/generator/vo.java.vm
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package ${package}.model.vo;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
#if(${hasLocalDateTime})
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
#end
|
||||||
|
#if(${hasBigDecimal})
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{tableComment} 图对象
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Schema( description = "$!{tableComment}视图对象")
|
||||||
|
public class ${entityName}VO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
#foreach($field in ${fields})
|
||||||
|
#if("$!field.comment" != "")
|
||||||
|
@Schema(description = "${field.comment}")
|
||||||
|
#end
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
|
#end
|
||||||
|
|
||||||
|
}
|
||||||
@@ -48,20 +48,20 @@ public class FastAutoGeneratorTest {
|
|||||||
// 注入配置(设置扩展类的模板路径和包路径)
|
// 注入配置(设置扩展类的模板路径和包路径)
|
||||||
.injectionConfig(consumer -> {
|
.injectionConfig(consumer -> {
|
||||||
List<CustomFile> customFiles = new ArrayList<>();
|
List<CustomFile> customFiles = new ArrayList<>();
|
||||||
customFiles.add(new CustomFile.Builder().fileName("DTO.java").templatePath("/templates/dto.java.vm").packageName("model.dto").build());
|
customFiles.add(new CustomFile.Builder().fileName("DTO.java").templatePath("/templates/generator/dto.java.vm").packageName("model.dto").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/vo.java.vm").packageName("model.vo").build());
|
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/generator/vo.java.vm").packageName("model.vo").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/bo.java.vm").packageName("model.bo").build());
|
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/generator/bo.java.vm").packageName("model.bo").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/pageQuery.java.vm").packageName("model.query").build());
|
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/generator/query.java.vm").packageName("model.query").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("PageVO.java").templatePath("/templates/pageVO.java.vm").packageName("model.vo").build());
|
customFiles.add(new CustomFile.Builder().fileName("PageVO.java").templatePath("/templates/pageVO.java.vm").packageName("model.vo").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("Form.java").templatePath("/templates/form.java.vm").packageName("model.form").build());
|
customFiles.add(new CustomFile.Builder().fileName("Form.java").templatePath("/templates/generator/form.java.vm").packageName("model.form").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("Converter.java").templatePath("/templates/converter.java.vm").packageName("converter").build());
|
customFiles.add(new CustomFile.Builder().fileName("Converter.java").templatePath("/templates/generator/converter.java.vm").packageName("converter").build());
|
||||||
consumer.customFile(customFiles);
|
consumer.customFile(customFiles);
|
||||||
consumer.beforeOutputFile((tableInfo, objectMap) -> {
|
consumer.beforeOutputFile((tableInfo, objectMap) -> {
|
||||||
// 为每个表生成首字母小写的实体名
|
// 为每个表生成首字母小写的实体名
|
||||||
String entityName = tableInfo.getEntityName();
|
String entityName = tableInfo.getEntityName();
|
||||||
String lowerCaseEntity = entityName.substring(0, 1).toLowerCase() + entityName.substring(1);
|
String lowerCaseEntity = entityName.substring(0, 1).toLowerCase() + entityName.substring(1);
|
||||||
// 注入自定义参数
|
// 注入自定义参数
|
||||||
objectMap.put("firstCharLowerCaseEntity", lowerCaseEntity);
|
objectMap.put("lowerFirstEntityName", lowerCaseEntity);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
package ${package.Parent}.model.bo;
|
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
|
||||||
import ${pkg};
|
|
||||||
#end
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
#if(${chainModel})
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
#if(${chainModel})
|
|
||||||
@Accessors(chain = true)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${superEntityClass})
|
|
||||||
public class ${entity}BO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
|
||||||
#elseif(${activeRecord})
|
|
||||||
public class ${entity}BO extends Model<${entity}> {
|
|
||||||
#elseif(${entitySerialVersionUID})
|
|
||||||
public class ${entity}BO implements Serializable {
|
|
||||||
#else
|
|
||||||
public class ${entity}BO {
|
|
||||||
#end
|
|
||||||
#if(${entitySerialVersionUID})
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
#end
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
#set($keyPropertyName=${field.propertyName})
|
|
||||||
#end
|
|
||||||
#if("$!field.comment" != "")
|
|
||||||
/**
|
|
||||||
* ${field.comment}
|
|
||||||
*/
|
|
||||||
#end
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
## 主键
|
|
||||||
#if(${field.keyIdentityFlag})
|
|
||||||
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
|
||||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
|
||||||
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
|
||||||
#elseif(${field.convert})
|
|
||||||
@TableId("${field.annotationColumnName}")
|
|
||||||
#end
|
|
||||||
## 普通字段
|
|
||||||
#elseif(${field.fill})
|
|
||||||
## ----- 存在字段填充设置 -----
|
|
||||||
#if(${field.convert})
|
|
||||||
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
|
||||||
#else
|
|
||||||
@TableField(fill = FieldFill.${field.fill})
|
|
||||||
#end
|
|
||||||
#elseif(${field.convert})
|
|
||||||
@TableField("${field.annotationColumnName}")
|
|
||||||
#end
|
|
||||||
## 乐观锁注解
|
|
||||||
#if(${field.versionField})
|
|
||||||
@Version
|
|
||||||
#end
|
|
||||||
## 逻辑删除注解
|
|
||||||
#if(${field.logicDeleteField})
|
|
||||||
@TableLogic
|
|
||||||
#end
|
|
||||||
private ${field.propertyType} ${field.propertyName};
|
|
||||||
#end
|
|
||||||
## ---------- END 字段循环遍历 ----------
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.propertyType.equals("boolean")})
|
|
||||||
#set($getprefix="is")
|
|
||||||
#else
|
|
||||||
#set($getprefix="get")
|
|
||||||
#end
|
|
||||||
|
|
||||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
||||||
return ${field.propertyName};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if(${chainModel})
|
|
||||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#else
|
|
||||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#end
|
|
||||||
this.${field.propertyName} = ${field.propertyName};
|
|
||||||
#if(${chainModel})
|
|
||||||
return this;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
## --foreach end---
|
|
||||||
#end
|
|
||||||
## --end of #if(!${entityLombokModel})--
|
|
||||||
#if(${entityColumnConstant})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${activeRecord})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable pkVal() {
|
|
||||||
#if(${keyPropertyName})
|
|
||||||
return this.${keyPropertyName};
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "${entity}{" +
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if($!{foreach.index}==0)
|
|
||||||
"${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#else
|
|
||||||
", ${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package ${package.Controller};
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import ${package.Parent}.model.form.${entity}Form;
|
|
||||||
import ${package.Parent}.model.query.${entity}PageQuery;
|
|
||||||
import ${package.Parent}.model.vo.${entity}PageVO;
|
|
||||||
import ${package.Parent}.service.${table.serviceName};
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.youlai.common.result.PageResult;
|
|
||||||
import com.youlai.common.result.Result;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
#if(${superControllerClassPackage})
|
|
||||||
import ${superControllerClassPackage};
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment} 前端控制器
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
@Tag(name = "${table.comment}接口")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/v1/${firstCharLowerCaseEntity}s")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
#if(${superControllerClass})
|
|
||||||
public class ${table.controllerName} extends ${superControllerClass} {
|
|
||||||
#else
|
|
||||||
public class ${table.controllerName} {
|
|
||||||
#end
|
|
||||||
|
|
||||||
private final ${table.serviceName} ${firstCharLowerCaseEntity}Service;
|
|
||||||
|
|
||||||
@Operation(summary = "$!{table.comment}分页列表")
|
|
||||||
@GetMapping("/page")
|
|
||||||
public PageResult<${entity}PageVO> listPaged${entity}s(${entity}PageQuery queryParams ) {
|
|
||||||
IPage<${entity}PageVO> result = ${firstCharLowerCaseEntity}Service.listPaged${entity}s(queryParams);
|
|
||||||
return PageResult.success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "新增$!{table.comment}")
|
|
||||||
@PostMapping
|
|
||||||
public Result save${entity}(@RequestBody @Valid ${entity}Form formData ) {
|
|
||||||
boolean result = ${firstCharLowerCaseEntity}Service.save${entity}(formData);
|
|
||||||
return Result.judge(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "$!{table.comment}表单数据")
|
|
||||||
@GetMapping("/{id}/form")
|
|
||||||
public Result<${entity}Form> get${entity}Form(
|
|
||||||
@Parameter(description = "$!{table.comment}ID") @PathVariable Long id
|
|
||||||
) {
|
|
||||||
${entity}Form formData = ${firstCharLowerCaseEntity}Service.get${entity}FormData(id);
|
|
||||||
return Result.success(formData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "修改$!{table.comment}")
|
|
||||||
@PutMapping(value = "/{id}")
|
|
||||||
public Result update${entity}(@Parameter(description = "$!{table.comment}ID") @PathVariable Long id,
|
|
||||||
@RequestBody @Validated ${entity}Form formData) {
|
|
||||||
boolean result = ${firstCharLowerCaseEntity}Service.update${entity}(id, formData);
|
|
||||||
return Result.judge(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除$!{table.comment}")
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public Result delete${entity}s(
|
|
||||||
@Parameter(description = "$!{table.comment}ID,多个以英文逗号(,)分割") @PathVariable String ids
|
|
||||||
) {
|
|
||||||
boolean result = ${firstCharLowerCaseEntity}Service.delete${entity}s(ids);
|
|
||||||
return Result.judge(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package ${package.Parent}.converter;
|
|
||||||
|
|
||||||
import org.mapstruct.InheritInverseConfiguration;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
|
|
||||||
import ${package.Parent}.model.dto.${entity}DTO;
|
|
||||||
import ${package.Parent}.model.entity.${entity};
|
|
||||||
import ${package.Parent}.model.vo.${entity}PageVO;
|
|
||||||
import ${package.Parent}.model.form.${entity}Form;
|
|
||||||
import ${package.Parent}.model.bo.${entity}BO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment}转换器
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
@Mapper(componentModel = "spring")
|
|
||||||
public interface ${entity}Converter{
|
|
||||||
|
|
||||||
${entity}PageVO toPageVo(${entity}BO bo);
|
|
||||||
|
|
||||||
Page<${entity}PageVO> toPageVo(Page<${entity}BO> bo);
|
|
||||||
|
|
||||||
${entity}Form convertToForm(${entity} entity);
|
|
||||||
|
|
||||||
@InheritInverseConfiguration(name = "convertToForm")
|
|
||||||
${entity} convertToEntity(${entity}Form entity);
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
package ${package.Parent}.model.dto;
|
|
||||||
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
#if(${chainModel})
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
/**
|
|
||||||
* $!{table.comment} DTO
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
#if(${chainModel})
|
|
||||||
@Accessors(chain = true)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
@Schema( description = "$!{table.comment}传输层对象")
|
|
||||||
#if(${superEntityClass})
|
|
||||||
public class ${entity}DTO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
|
||||||
#elseif(${activeRecord})
|
|
||||||
public class ${entity}DTO extends Model<${entity}> {
|
|
||||||
#elseif(${entitySerialVersionUID})
|
|
||||||
public class ${entity}DTO implements Serializable {
|
|
||||||
#else
|
|
||||||
public class ${entity}DTO {
|
|
||||||
#end
|
|
||||||
#if(${entitySerialVersionUID})
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
#end
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
#set($keyPropertyName=${field.propertyName})
|
|
||||||
#end
|
|
||||||
#if("$!field.comment" != "")
|
|
||||||
@Schema(description = "${field.comment}")
|
|
||||||
#end
|
|
||||||
|
|
||||||
private ${field.propertyType} ${field.propertyName};
|
|
||||||
#end
|
|
||||||
## ---------- END 字段循环遍历 ----------
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.propertyType.equals("boolean")})
|
|
||||||
#set($getprefix="is")
|
|
||||||
#else
|
|
||||||
#set($getprefix="get")
|
|
||||||
#end
|
|
||||||
|
|
||||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
||||||
return ${field.propertyName};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if(${chainModel})
|
|
||||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#else
|
|
||||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#end
|
|
||||||
this.${field.propertyName} = ${field.propertyName};
|
|
||||||
#if(${chainModel})
|
|
||||||
return this;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
## --foreach end---
|
|
||||||
#end
|
|
||||||
## --end of #if(!${entityLombokModel})--
|
|
||||||
#if(${entityColumnConstant})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${activeRecord})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable pkVal() {
|
|
||||||
#if(${keyPropertyName})
|
|
||||||
return this.${keyPropertyName};
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "${entity}{" +
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if($!{foreach.index}==0)
|
|
||||||
"${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#else
|
|
||||||
", ${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
package ${package.Entity};
|
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
|
||||||
import ${pkg};
|
|
||||||
#end
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
#if(${chainModel})
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment}实体
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
#if(${chainModel})
|
|
||||||
@Accessors(chain = true)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${table.convert})
|
|
||||||
@TableName("${schemaName}${table.name}")
|
|
||||||
#end
|
|
||||||
#if(${superEntityClass})
|
|
||||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
|
||||||
#elseif(${activeRecord})
|
|
||||||
public class ${entity} extends Model<${entity}> {
|
|
||||||
#elseif(${entitySerialVersionUID})
|
|
||||||
public class ${entity} implements Serializable {
|
|
||||||
#else
|
|
||||||
public class ${entity} {
|
|
||||||
#end
|
|
||||||
#if(${entitySerialVersionUID})
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
#end
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
#set($keyPropertyName=${field.propertyName})
|
|
||||||
#end
|
|
||||||
#if("$!field.comment" != "")
|
|
||||||
/**
|
|
||||||
* ${field.comment}
|
|
||||||
*/
|
|
||||||
#end
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
## 主键
|
|
||||||
#if(${field.keyIdentityFlag})
|
|
||||||
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
|
||||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
|
||||||
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
|
||||||
#elseif(${field.convert})
|
|
||||||
@TableId("${field.annotationColumnName}")
|
|
||||||
#end
|
|
||||||
## 普通字段
|
|
||||||
#elseif(${field.fill})
|
|
||||||
## ----- 存在字段填充设置 -----
|
|
||||||
#if(${field.convert})
|
|
||||||
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
|
||||||
#else
|
|
||||||
@TableField(fill = FieldFill.${field.fill})
|
|
||||||
#end
|
|
||||||
#elseif(${field.convert})
|
|
||||||
@TableField("${field.annotationColumnName}")
|
|
||||||
#end
|
|
||||||
## 乐观锁注解
|
|
||||||
#if(${field.versionField})
|
|
||||||
@Version
|
|
||||||
#end
|
|
||||||
## 逻辑删除注解
|
|
||||||
#if(${field.logicDeleteField})
|
|
||||||
@TableLogic
|
|
||||||
#end
|
|
||||||
private ${field.propertyType} ${field.propertyName};
|
|
||||||
#end
|
|
||||||
## ---------- END 字段循环遍历 ----------
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.propertyType.equals("boolean")})
|
|
||||||
#set($getprefix="is")
|
|
||||||
#else
|
|
||||||
#set($getprefix="get")
|
|
||||||
#end
|
|
||||||
|
|
||||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
||||||
return ${field.propertyName};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if(${chainModel})
|
|
||||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#else
|
|
||||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#end
|
|
||||||
this.${field.propertyName} = ${field.propertyName};
|
|
||||||
#if(${chainModel})
|
|
||||||
return this;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
## --foreach end---
|
|
||||||
#end
|
|
||||||
## --end of #if(!${entityLombokModel})--
|
|
||||||
#if(${entityColumnConstant})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${activeRecord})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable pkVal() {
|
|
||||||
#if(${keyPropertyName})
|
|
||||||
return this.${keyPropertyName};
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "${entity}{" +
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if($!{foreach.index}==0)
|
|
||||||
"${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#else
|
|
||||||
", ${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package ${package.Parent}.model.form;
|
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
|
||||||
import ${pkg};
|
|
||||||
#end
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
#if(${chainModel})
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment} 表单对象
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
#if(${chainModel})
|
|
||||||
@Accessors(chain = true)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
@Schema(description = "$!{table.comment}表单对象")
|
|
||||||
#if(${superEntityClass})
|
|
||||||
public class ${entity}Form extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
|
||||||
#elseif(${activeRecord})
|
|
||||||
public class ${entity}Form extends Model<${entity}> {
|
|
||||||
#elseif(${entitySerialVersionUID})
|
|
||||||
public class ${entity}Form implements Serializable {
|
|
||||||
#else
|
|
||||||
public class ${entity}Form {
|
|
||||||
#end
|
|
||||||
#if(${entitySerialVersionUID})
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
#end
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
#set($keyPropertyName=${field.propertyName})
|
|
||||||
#end
|
|
||||||
#if("$!field.comment" != "")
|
|
||||||
@Schema(description = "${field.comment}")
|
|
||||||
#end
|
|
||||||
|
|
||||||
private ${field.propertyType} ${field.propertyName};
|
|
||||||
#end
|
|
||||||
## ---------- END 字段循环遍历 ----------
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.propertyType.equals("boolean")})
|
|
||||||
#set($getprefix="is")
|
|
||||||
#else
|
|
||||||
#set($getprefix="get")
|
|
||||||
#end
|
|
||||||
|
|
||||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
||||||
return ${field.propertyName};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if(${chainModel})
|
|
||||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#else
|
|
||||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#end
|
|
||||||
this.${field.propertyName} = ${field.propertyName};
|
|
||||||
#if(${chainModel})
|
|
||||||
return this;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
## --foreach end---
|
|
||||||
#end
|
|
||||||
## --end of #if(!${entityLombokModel})--
|
|
||||||
#if(${entityColumnConstant})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${activeRecord})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable pkVal() {
|
|
||||||
#if(${keyPropertyName})
|
|
||||||
return this.${keyPropertyName};
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "${entity}{" +
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if($!{foreach.index}==0)
|
|
||||||
"${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#else
|
|
||||||
", ${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package ${package.Mapper};
|
|
||||||
|
|
||||||
import ${package.Entity}.${entity};
|
|
||||||
import ${superMapperClassPackage};
|
|
||||||
#if(${mapperAnnotationClass})
|
|
||||||
import ${mapperAnnotationClass.name};
|
|
||||||
#end
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import ${package.Parent}.model.bo.${entity}BO;
|
|
||||||
import ${package.Parent}.model.query.${entity}PageQuery;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment} Mapper 接口
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${mapperAnnotationClass})
|
|
||||||
@${mapperAnnotationClass.simpleName}
|
|
||||||
#end
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户分页列表
|
|
||||||
*
|
|
||||||
* @param page
|
|
||||||
* @param queryParams 查询参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Page<${entity}BO> listPaged${entity}s(Page<${entity}BO> page, ${entity}PageQuery queryParams);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
|
||||||
|
|
||||||
#if(${enableCache})
|
|
||||||
<!-- 开启二级缓存 -->
|
|
||||||
<cache type="${cacheClassName}"/>
|
|
||||||
|
|
||||||
#end
|
|
||||||
#if(${baseResultMap})
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.keyFlag})##生成主键排在第一位
|
|
||||||
<id column="${field.name}" property="${field.propertyName}" />
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($field in ${table.commonFields})##生成公共字段
|
|
||||||
<result column="${field.name}" property="${field.propertyName}" />
|
|
||||||
#end
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(!${field.keyFlag})##生成普通字段
|
|
||||||
<result column="${field.name}" property="${field.propertyName}" />
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
#end
|
|
||||||
#if(${baseColumnList})
|
|
||||||
<!-- 通用查询结果列 -->
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
#foreach($field in ${table.commonFields})
|
|
||||||
${field.columnName},
|
|
||||||
#end
|
|
||||||
${table.fieldNames}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
#end
|
|
||||||
|
|
||||||
<!-- ${table.comment}分页列表 -->
|
|
||||||
<select id="listPaged${entity}s" resultType="${package.Parent}.model.bo.${entity}BO">
|
|
||||||
SELECT
|
|
||||||
<include refid="Base_Column_List"/>
|
|
||||||
FROM
|
|
||||||
${table.name}
|
|
||||||
<where>
|
|
||||||
is_deleted = 0
|
|
||||||
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
|
||||||
AND (
|
|
||||||
name LIKE CONCAT('%',#{queryParams.keywords},'%')
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="queryParams.startTime != null">
|
|
||||||
AND create_time >= #{queryParams.startTime}
|
|
||||||
</if>
|
|
||||||
<if test="queryParams.endTime != null">
|
|
||||||
AND create_time <= #{queryParams.endTime}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY create_time DESC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package ${package.Parent}.model.query;
|
|
||||||
|
|
||||||
import com.youlai.common.base.BasePageQuery;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment}分页查询对象
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
@Schema(description ="$!{table.comment}分页查询对象")
|
|
||||||
@Data
|
|
||||||
public class ${entity}PageQuery extends BasePageQuery {
|
|
||||||
|
|
||||||
@Schema(description="关键字")
|
|
||||||
private String keywords;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package ${package.Parent}.model.vo;
|
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
|
||||||
import ${pkg};
|
|
||||||
#end
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
#if(${chainModel})
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment} 分页VO
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
#if(${chainModel})
|
|
||||||
@Accessors(chain = true)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
@Schema( description = "$!{table.comment}分页视图对象")
|
|
||||||
#if(${superEntityClass})
|
|
||||||
public class ${entity}PageVO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
|
||||||
#elseif(${activeRecord})
|
|
||||||
public class ${entity}PageVO extends Model<${entity}> {
|
|
||||||
#elseif(${entitySerialVersionUID})
|
|
||||||
public class ${entity}PageVO implements Serializable {
|
|
||||||
#else
|
|
||||||
public class ${entity}PageVO {
|
|
||||||
#end
|
|
||||||
#if(${entitySerialVersionUID})
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
#end
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
#set($keyPropertyName=${field.propertyName})
|
|
||||||
#end
|
|
||||||
#if("$!field.comment" != "")
|
|
||||||
@Schema(description = "${field.comment}")
|
|
||||||
#end
|
|
||||||
|
|
||||||
private ${field.propertyType} ${field.propertyName};
|
|
||||||
#end
|
|
||||||
## ---------- END 字段循环遍历 ----------
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.propertyType.equals("boolean")})
|
|
||||||
#set($getprefix="is")
|
|
||||||
#else
|
|
||||||
#set($getprefix="get")
|
|
||||||
#end
|
|
||||||
|
|
||||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
||||||
return ${field.propertyName};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if(${chainModel})
|
|
||||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#else
|
|
||||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#end
|
|
||||||
this.${field.propertyName} = ${field.propertyName};
|
|
||||||
#if(${chainModel})
|
|
||||||
return this;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
## --foreach end---
|
|
||||||
#end
|
|
||||||
## --end of #if(!${entityLombokModel})--
|
|
||||||
#if(${entityColumnConstant})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${activeRecord})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable pkVal() {
|
|
||||||
#if(${keyPropertyName})
|
|
||||||
return this.${keyPropertyName};
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "${entity}{" +
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if($!{foreach.index}==0)
|
|
||||||
"${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#else
|
|
||||||
", ${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package ${package.Service};
|
|
||||||
|
|
||||||
import ${package.Entity}.${entity};
|
|
||||||
import ${superServiceClassPackage};
|
|
||||||
import ${package.Parent}.model.form.${entity}Form;
|
|
||||||
import ${package.Parent}.model.query.${entity}PageQuery;
|
|
||||||
import ${package.Parent}.model.vo.${entity}PageVO;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
/**
|
|
||||||
* $!{table.comment} 服务类
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*$!{table.comment}分页列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
IPage<${entity}PageVO> listPaged${entity}s(${entity}PageQuery queryParams);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取$!{table.comment}表单数据
|
|
||||||
*
|
|
||||||
* @param id $!{table.comment}ID
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
${entity}Form get${entity}FormData(Long id);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增$!{table.comment}
|
|
||||||
*
|
|
||||||
* @param formData $!{table.comment}表单对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean save${entity}(${entity}Form formData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改$!{table.comment}
|
|
||||||
*
|
|
||||||
* @param id $!{table.comment}ID
|
|
||||||
* @param formData $!{table.comment}表单对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean update${entity}(Long id, ${entity}Form formData);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除$!{table.comment}
|
|
||||||
*
|
|
||||||
* @param ids $!{table.comment}ID,多个以英文逗号(,)分割
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean delete${entity}s(String ids);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
package ${package.ServiceImpl};
|
|
||||||
|
|
||||||
import ${package.Entity}.${entity};
|
|
||||||
import ${package.Mapper}.${table.mapperName};
|
|
||||||
import ${package.Service}.${table.serviceName};
|
|
||||||
import ${superServiceImplClassPackage};
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.youlai.common.util.DateUtils;
|
|
||||||
import ${package.Parent}.model.form.${entity}Form;
|
|
||||||
import ${package.Parent}.model.query.${entity}PageQuery;
|
|
||||||
import ${package.Parent}.model.bo.${entity}BO;
|
|
||||||
import ${package.Parent}.model.vo.${entity}PageVO;
|
|
||||||
import ${package.Parent}.converter.${entity}Converter;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment}服务实现类
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
|
|
||||||
|
|
||||||
private final ${entity}Converter ${firstCharLowerCaseEntity}Converter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取$!{table.comment}分页列表
|
|
||||||
*
|
|
||||||
* @param queryParams 查询参数
|
|
||||||
* @return {@link IPage<${entity}PageVO>} $!{table.comment}分页列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public IPage<${entity}PageVO> listPaged${entity}s(${entity}PageQuery queryParams) {
|
|
||||||
|
|
||||||
// 参数构建
|
|
||||||
int pageNum = queryParams.getPageNum();
|
|
||||||
int pageSize = queryParams.getPageSize();
|
|
||||||
Page<${entity}BO> page = new Page<>(pageNum, pageSize);
|
|
||||||
|
|
||||||
// 格式化为数据库日期格式,避免日期比较使用格式化函数导致索引失效
|
|
||||||
DateUtils.toDatabaseFormat(queryParams, "startTime", "endTime");
|
|
||||||
|
|
||||||
// 查询数据
|
|
||||||
Page<${entity}BO> boPage = this.baseMapper.listPaged${entity}s(page, queryParams);
|
|
||||||
|
|
||||||
// 实体转换
|
|
||||||
return ${firstCharLowerCaseEntity}Converter.toPageVo(boPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取$!{table.comment}表单数据
|
|
||||||
*
|
|
||||||
* @param id $!{table.comment}ID
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ${entity}Form get${entity}FormData(Long id) {
|
|
||||||
${entity} entity = this.getById(id);
|
|
||||||
return ${firstCharLowerCaseEntity}Converter.convertToForm(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增$!{table.comment}
|
|
||||||
*
|
|
||||||
* @param formData $!{table.comment}表单对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean save${entity}(${entity}Form formData) {
|
|
||||||
// 实体转换 form->entity
|
|
||||||
${entity} entity = ${firstCharLowerCaseEntity}Converter.convertToEntity(formData);
|
|
||||||
return this.save(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新$!{table.comment}
|
|
||||||
*
|
|
||||||
* @param id $!{table.comment}ID
|
|
||||||
* @param formData $!{table.comment}表单对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean update${entity}(Long id,${entity}Form formData) {
|
|
||||||
${entity} entity = ${firstCharLowerCaseEntity}Converter.convertToEntity(formData);
|
|
||||||
return this.updateById(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除$!{table.comment}
|
|
||||||
*
|
|
||||||
* @param ids $!{table.comment}ID,多个以英文逗号(,)分割
|
|
||||||
* @return true|false
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean delete${entity}s(String ids) {
|
|
||||||
Assert.isTrue(StrUtil.isNotBlank(ids), "删除的$!{table.comment}数据为空");
|
|
||||||
// 逻辑删除
|
|
||||||
List<Long> idList = Arrays.stream(ids.split(","))
|
|
||||||
.map(Long::parseLong)
|
|
||||||
.toList();
|
|
||||||
return this.removeByIds(idList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
package ${package.Parent}.model.vo;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
#if(${chainModel})
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $!{table.comment} VO
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @since ${date}
|
|
||||||
*/
|
|
||||||
#if(${entityLombokModel})
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
#if(${chainModel})
|
|
||||||
@Accessors(chain = true)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
@Schema( description = "$!{table.comment}视图对象")
|
|
||||||
#if(${superEntityClass})
|
|
||||||
public class ${entity}VO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
|
||||||
#elseif(${activeRecord})
|
|
||||||
public class ${entity} extends Model<${entity}> {
|
|
||||||
#elseif(${entitySerialVersionUID})
|
|
||||||
public class ${entity}VO implements Serializable {
|
|
||||||
#else
|
|
||||||
public class ${entity}VO {
|
|
||||||
#end
|
|
||||||
#if(${entitySerialVersionUID})
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
#end
|
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
|
||||||
#set($keyPropertyName=${field.propertyName})
|
|
||||||
#end
|
|
||||||
#if("$!field.comment" != "")
|
|
||||||
@Schema(description = "${field.comment}")
|
|
||||||
#end
|
|
||||||
|
|
||||||
private ${field.propertyType} ${field.propertyName};
|
|
||||||
#end
|
|
||||||
## ---------- END 字段循环遍历 ----------
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if(${field.propertyType.equals("boolean")})
|
|
||||||
#set($getprefix="is")
|
|
||||||
#else
|
|
||||||
#set($getprefix="get")
|
|
||||||
#end
|
|
||||||
|
|
||||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
||||||
return ${field.propertyName};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if(${chainModel})
|
|
||||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#else
|
|
||||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
||||||
#end
|
|
||||||
this.${field.propertyName} = ${field.propertyName};
|
|
||||||
#if(${chainModel})
|
|
||||||
return this;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
## --foreach end---
|
|
||||||
#end
|
|
||||||
## --end of #if(!${entityLombokModel})--
|
|
||||||
#if(${entityColumnConstant})
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
|
|
||||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if(${activeRecord})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable pkVal() {
|
|
||||||
#if(${keyPropertyName})
|
|
||||||
return this.${keyPropertyName};
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if(!${entityLombokModel})
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "${entity}{" +
|
|
||||||
#foreach($field in ${table.fields})
|
|
||||||
#if($!{foreach.index}==0)
|
|
||||||
"${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#else
|
|
||||||
", ${field.propertyName} = " + ${field.propertyName} +
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user