Compare commits
5 Commits
77745c42ed
...
c478aa9418
Author | SHA1 | Date |
---|---|---|
|
c478aa9418 | |
|
cadedad259 | |
|
1ce2a7e210 | |
|
25c8e27e9b | |
|
2b3cddca52 |
|
@ -18,6 +18,8 @@ bunny-web.site.key
|
|||
bunny-web.site_bundle.crt
|
||||
bunny-web.site_bundle.pem
|
||||
|
||||
application-prod.yml
|
||||
|
||||
yarn.lock
|
||||
npm-debug.log*
|
||||
.pnpm-error.log*
|
||||
|
|
|
@ -30,12 +30,6 @@ public class GeneratorController {
|
|||
|
||||
private final GeneratorService generatorService;
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
*
|
||||
* @param dto 生成参数DTO
|
||||
* @return 生成的代码结果,按表名分组
|
||||
*/
|
||||
@Operation(summary = "生成代码", description = "根据SQL或数据库表生成代码")
|
||||
@PostMapping
|
||||
public Result<Map<String, List<GeneratorVo>>> generator(@Valid @RequestBody VmsArgumentDto dto) {
|
||||
|
@ -48,12 +42,6 @@ public class GeneratorController {
|
|||
return Result.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包代码为ZIP下载
|
||||
*
|
||||
* @param dto 生成参数DTO
|
||||
* @return ZIP文件响应实体
|
||||
*/
|
||||
@Operation(summary = "打包下载", description = "将生成的代码打包为ZIP文件下载")
|
||||
@PostMapping("downloadByZip")
|
||||
public ResponseEntity<byte[]> downloadByZip(@Valid @RequestBody VmsArgumentDto dto) {
|
||||
|
|
|
@ -30,6 +30,16 @@ public class VmsTBaseTemplateGenerator extends AbstractTemplateGenerator {
|
|||
this.dto = dto;
|
||||
this.path = path;
|
||||
this.tableMetaData = tableMetaData;
|
||||
|
||||
// 处理表名称,替换前缀
|
||||
String tableName = tableMetaData.getTableName();
|
||||
String[] prefixes = dto.getTablePrefixes().split("[,,]");
|
||||
for (String prefix : prefixes) {
|
||||
if (tableName.startsWith(prefix)) {
|
||||
String handlerTableName = tableName.replace(prefix, "");
|
||||
tableMetaData.setCleanTableName(handlerTableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +50,7 @@ public class VmsTBaseTemplateGenerator extends AbstractTemplateGenerator {
|
|||
@Override
|
||||
public void addContext(VelocityContext context) {
|
||||
// 当前的表名
|
||||
String tableName = tableMetaData.getTableName();
|
||||
String handlerTableName = tableMetaData.getCleanTableName();
|
||||
// 表的注释内容
|
||||
String comment = tableMetaData.getComment();
|
||||
|
||||
|
@ -61,11 +71,11 @@ public class VmsTBaseTemplateGenerator extends AbstractTemplateGenerator {
|
|||
context.put("package", dto.getPackageName());
|
||||
|
||||
// 将类名称转成小驼峰
|
||||
String lowerCamelCase = MysqlTypeConvertUtil.convertToCamelCase(tableName, false);
|
||||
String lowerCamelCase = MysqlTypeConvertUtil.convertToCamelCase(handlerTableName, false);
|
||||
context.put("classLowercaseName", lowerCamelCase);
|
||||
|
||||
// 将类名称转成大驼峰
|
||||
String upperCameCase = MysqlTypeConvertUtil.convertToCamelCase(tableName, true);
|
||||
String upperCameCase = MysqlTypeConvertUtil.convertToCamelCase(handlerTableName, true);
|
||||
context.put("classUppercaseName", upperCameCase);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
@ -13,11 +14,14 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "TableMetaData", description = "表信息数据")
|
||||
public class TableMetaData {
|
||||
public class TableMetaData implements Serializable {
|
||||
|
||||
@Schema(name = "tableName", description = "表名")
|
||||
private String tableName;
|
||||
|
||||
@Schema(name = "handlerTableName", description = "处理后的表名称")
|
||||
private String cleanTableName;
|
||||
|
||||
@Schema(name = "comment", description = "注释内容")
|
||||
private String comment;
|
||||
|
||||
|
@ -33,4 +37,5 @@ public class TableMetaData {
|
|||
@Schema(name = "columns", description = "列名称")
|
||||
private List<ColumnMetaData> columns = List.of();
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package cn.bunny.service.helper;
|
||||
|
||||
import cn.bunny.domain.dto.VmsArgumentDto;
|
||||
import cn.bunny.utils.MysqlTypeConvertUtil;
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
|
@ -23,36 +22,25 @@ public class VmsGeneratorPathHelper {
|
|||
/**
|
||||
* 处理模板文件路径和命名
|
||||
*
|
||||
* @param dto 生成参数
|
||||
* @param path 原始模板路径
|
||||
* @param tableName 数据库表名
|
||||
* @return 处理后的文件路径
|
||||
*/
|
||||
public static String processVmPath(VmsArgumentDto dto, String path, String tableName) {
|
||||
String className = removeTablePrefixes(dto, tableName);
|
||||
public static String processVmPath(String path, String tableName) {
|
||||
String lowerCamelCase = MysqlTypeConvertUtil.convertToCamelCase(tableName, false);
|
||||
String[] pathParts = path.replace("$className", lowerCamelCase).split("/");
|
||||
|
||||
// 处理文件名
|
||||
pathParts[pathParts.length - 1] = processFilename(
|
||||
pathParts[pathParts.length - 1],
|
||||
className
|
||||
);
|
||||
if (lowerCamelCase != null) {
|
||||
String[] pathParts = path.replace("$className", lowerCamelCase).split("/");
|
||||
// 处理文件名
|
||||
pathParts[pathParts.length - 1] = processFilename(
|
||||
pathParts[pathParts.length - 1],
|
||||
lowerCamelCase
|
||||
);
|
||||
|
||||
return String.join("/", pathParts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除表前缀
|
||||
*/
|
||||
private static String removeTablePrefixes(VmsArgumentDto dto, String tableName) {
|
||||
String[] prefixes = dto.getTablePrefixes().split("[,,]");
|
||||
for (String prefix : prefixes) {
|
||||
if (tableName.startsWith(prefix)) {
|
||||
return tableName.substring(prefix.length());
|
||||
}
|
||||
return String.join("/", pathParts);
|
||||
}
|
||||
return tableName;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,10 +56,12 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||
*/
|
||||
@Override
|
||||
public Map<String, List<GeneratorVo>> generateCodeBySql(VmsArgumentDto dto) {
|
||||
// 根据Sql语句进行分析表的属性和表列字段
|
||||
String sql = dto.getSql();
|
||||
TableMetaData tableMeta = sqlMetadataProvider.getTableMetadata(sql);
|
||||
List<ColumnMetaData> columns = sqlMetadataProvider.getColumnInfoList(sql);
|
||||
|
||||
// 生成代码
|
||||
List<GeneratorVo> generatorVoList = getGeneratorStream(dto, tableMeta, columns).toList();
|
||||
|
||||
Map<String, List<GeneratorVo>> map = new HashMap<>();
|
||||
|
@ -68,11 +70,23 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数据库进行生成
|
||||
*
|
||||
* @param dto 生成参数
|
||||
* @return 生成的ZIP文件
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<byte[]> downloadByZipByDatabase(VmsArgumentDto dto) {
|
||||
return downloadByZip(dto, this::generateCodeByDatabase);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Sql语句及逆行生成
|
||||
*
|
||||
* @param dto 生成参数
|
||||
* @return 生成的ZIP文件
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<byte[]> downloadByZipBySqL(VmsArgumentDto dto) {
|
||||
return downloadByZip(dto, this::generateCodeBySql);
|
||||
|
@ -117,16 +131,22 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||
* @return 生成器流
|
||||
*/
|
||||
public Stream<GeneratorVo> getGeneratorStream(VmsArgumentDto dto, TableMetaData tableMeta, List<ColumnMetaData> columns) {
|
||||
// 因为这里使用到了并行流,对 tableMeta 操作正常是会拿到修改后的值,但是在并行流会有线程安全问题,所以直接要手动实现深拷贝
|
||||
|
||||
return dto.getPath().parallelStream().map(path -> {
|
||||
// 创建生成模板
|
||||
VmsTBaseTemplateGenerator generator = new VmsTBaseTemplateGenerator(dto, path, tableMeta);
|
||||
|
||||
// 生成好的模板
|
||||
String code = generator.generateCode(tableMeta, columns).toString();
|
||||
String processVmPath = VmsGeneratorPathHelper.processVmPath(path, tableMeta.getCleanTableName());
|
||||
|
||||
return GeneratorVo.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.code(code)
|
||||
.comment(tableMeta.getComment())
|
||||
.tableName(tableMeta.getTableName())
|
||||
.path(VmsGeneratorPathHelper.processVmPath(dto, path, tableMeta.getTableName()))
|
||||
.path(processVmPath)
|
||||
.build();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ const AppGeneratorPage = defineComponent({
|
|||
* 几秒后恢复原状
|
||||
*/
|
||||
async onCopyToClipboard(code) {
|
||||
this.copied = true;
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
antd.notification.open({
|
||||
|
@ -119,6 +121,13 @@ const AppGeneratorPage = defineComponent({
|
|||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
||||
// 显示已复制图标时长
|
||||
if (this.copied) {
|
||||
setTimeout(() => {
|
||||
this.copied = false;
|
||||
}, 2000)
|
||||
}
|
||||
},
|
||||
|
||||
/* 下载全部文件 */
|
||||
|
|
|
@ -34,6 +34,8 @@ axiosInstance.interceptors.response.use(
|
|||
} else {
|
||||
antd.message.error(message || '系统出错');
|
||||
}
|
||||
|
||||
return error.response.data;
|
||||
}
|
||||
return Promise.reject(error.message);
|
||||
}
|
||||
|
|
|
@ -288,11 +288,12 @@ const DatabaseForm = {
|
|||
async onDownloadZip() {
|
||||
this.downloadLoading = true;
|
||||
try {
|
||||
// 重要:指定响应类型为blob
|
||||
const response = await axiosInstance({
|
||||
url: "/generator/downloadByZip",
|
||||
method: "POST",
|
||||
data: this.form,
|
||||
responseType: 'blob' // 重要:指定响应类型为blob
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
// 从响应头中获取文件名
|
||||
|
|
|
@ -169,21 +169,32 @@
|
|||
},
|
||||
watch: {
|
||||
/* 数据表选择 */
|
||||
dbSelect: {
|
||||
handler() {
|
||||
this.getDatabaseTableList();
|
||||
}
|
||||
},
|
||||
dbSelect: "getDatabaseTableList",
|
||||
|
||||
/* 过滤数据表 */
|
||||
tableSelect: {
|
||||
handler(val) {
|
||||
this.tableList = this.rawTableList;
|
||||
// 根据表名进行过滤筛选或者根据注释内容进行筛选
|
||||
this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val));
|
||||
}
|
||||
tableSelect(val) {
|
||||
this.tableList = this.rawTableList;
|
||||
// 根据表名进行过滤筛选或者根据注释内容进行筛选
|
||||
this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val));
|
||||
},
|
||||
|
||||
/**
|
||||
* 监听form表单放到 localStorage
|
||||
* 不要使用 immediate 否则初始话加载的时候会将 localStorage 改成 原始表单
|
||||
*/
|
||||
form: {
|
||||
deep: true,
|
||||
handler(val) {
|
||||
localStorage.setItem("form", JSON.stringify(val));
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const form = localStorage.getItem("form");
|
||||
if (form !== null) {
|
||||
this.form = JSON.parse(form);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 注册组件
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package ${package}.controller;
|
||||
|
||||
import cn.bunny.domain.pojo.result.Result;
|
||||
import cn.bunny.domain.pojo.result.ResultCodeEnum;
|
||||
import ${package}.domain.dto.${classUppercaseName}Dto;
|
||||
import ${package}.domain.entity.${classUppercaseName};
|
||||
import ${package}.domain.vo.${classUppercaseName}Vo;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
import cn.bunny.domain.pojo.result.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import ${package}.service.${classUppercaseName}Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,42 +23,42 @@ import java.util.List;
|
|||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Tag(name = "${comment}" , description = "${comment}相关接口" )
|
||||
@Tag(name = "${comment}", description = "${comment}相关接口")
|
||||
@RestController
|
||||
@RequestMapping("${requestMapping}/${classLowercaseName}" )
|
||||
@RequestMapping("${requestMapping}/${classLowercaseName}")
|
||||
@RequiredArgsConstructor
|
||||
public class ${classUppercaseName}Controller {
|
||||
|
||||
@Resource
|
||||
private ${classUppercaseName}Service ${classLowercaseName}Service;
|
||||
private final ${classUppercaseName}Service ${classLowercaseName}Service;
|
||||
|
||||
@Operation(summary = "分页查询${comment}" , description = "分页${comment}" )
|
||||
@GetMapping("{page}/{limit}" )
|
||||
@Operation(summary = "分页查询${comment}", description = "分页${comment}")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<${classUppercaseName}Vo>> get${classUppercaseName}Page(
|
||||
@Parameter(name = "page" , description = "当前页" , required = true)
|
||||
@PathVariable("page" ) Integer page,
|
||||
@Parameter(name = "limit" , description = "每页记录数" , required = true)
|
||||
@PathVariable("limit" ) Integer limit,
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
${classUppercaseName}Dto dto) {
|
||||
Page<${classUppercaseName}> pageParams = new Page<>(page, limit);
|
||||
PageResult<${classUppercaseName}Vo> pageResult = ${classLowercaseName}Service.get${classUppercaseName}Page(pageParams, dto);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加${comment}" , description = "添加${comment}" )
|
||||
@Operation(summary = "添加${comment}", description = "添加${comment}")
|
||||
@PostMapping()
|
||||
public Result<String> add${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}to dto) {
|
||||
public Result<String> add${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}Dto dto) {
|
||||
${classLowercaseName}Service.add${classUppercaseName}(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新${comment}" , description = "更新${comment}" )
|
||||
@Operation(summary = "更新${comment}", description = "更新${comment}")
|
||||
@PutMapping()
|
||||
public Result<String> update${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}Dto dto) {
|
||||
${classLowercaseName}Service.update${classUppercaseName}(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除${comment}" , description = "删除${comment}" )
|
||||
@Operation(summary = "删除${comment}", description = "删除${comment}")
|
||||
@DeleteMapping()
|
||||
public Result<String> delete${classUppercaseName}(@RequestBody List<Long> ids) {
|
||||
${classLowercaseName}Service.delete${classUppercaseName}(ids);
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
package ${package}.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
package ${package}.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Getter
|
||||
@Setter
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
package ${package}.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "${classUppercaseName}VO对象", title = "${comment}", description = "${comment}的VO对象")
|
||||
public class ${classUppercaseName}Vo {
|
||||
|
||||
#foreach($field in ${columnInfoList})
|
||||
@Schema(name = "${field.lowercaseName}", title = "${field.comment}")
|
||||
private ${field.javaType} ${field.lowercaseName};
|
||||
#foreach($field in ${columnInfoList})
|
||||
@Schema(name = "${field.lowercaseName}", title = "${field.comment}")
|
||||
private ${field.javaType} ${field.lowercaseName};
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import ${package}.domain.dto.${classUppercaseName}Dto;
|
||||
import ${package}.domain.entity.${classUppercaseName};
|
||||
import ${package}.domain.vo.${classUppercaseName}Vo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,6 +30,6 @@ public interface ${classUppercaseName}Mapper extends BaseMapper<${classUppercase
|
|||
* @param dto ${comment}查询表单
|
||||
* @return ${comment}分页结果
|
||||
*/
|
||||
IPage<${classUppercaseName}Vo> selectListByPage(@Param("page" ) Page<${classUppercaseName}> pageParams, @Param("dto" ) ${classUppercaseName}Dto dto);
|
||||
IPage<${classUppercaseName}Vo> selectListByPage(@Param("page") Page<${classUppercaseName}> pageParams, @Param("dto") ${classUppercaseName}Dto dto);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<mapper namespace="${package}.mapper.${classUppercaseName}Mapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${classUppercaseName}">
|
||||
<resultMap id="BaseResultMap" type="${package}.domain.entity.${classUppercaseName}">
|
||||
#foreach($field in ${columnInfoList})
|
||||
<id column="${field.columnName}" property="${field.lowercaseName}"/>
|
||||
#end
|
||||
|
@ -15,7 +15,7 @@
|
|||
</sql>
|
||||
|
||||
<!-- 分页查询${comment}内容 -->
|
||||
<select id="selectListByPage" resultType="${voClassType}">
|
||||
<select id="selectListByPage" resultType="${package}.domain.vo.${classUppercaseName}Vo">
|
||||
select
|
||||
base.*,
|
||||
create_user.username as create_username,
|
|
@ -1,6 +1,5 @@
|
|||
package ${package}.service.impl;
|
||||
|
||||
import cn.bunny.domain.pojo.result.PageResult;
|
||||
import ${package}.mapper.${classUppercaseName}Mapper;
|
||||
import ${package}.service.${classUppercaseName}Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
@ -8,6 +7,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${package}.service.${classUppercaseName}Service;
|
||||
import ${package}.domain.dto.${classUppercaseName}Dto;
|
||||
import ${package}.domain.entity.${classUppercaseName};
|
||||
import ${package}.domain.vo.${classUppercaseName}Vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -20,6 +24,7 @@ import java.util.List;
|
|||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class ${classUppercaseName}ServiceImpl extends ServiceImpl<${classUppercaseName}Mapper, ${classUppercaseName}> implements ${classUppercaseName}Service {
|
||||
|
||||
/**
|
||||
|
@ -47,7 +52,7 @@ public class ${classUppercaseName}ServiceImpl extends ServiceImpl<${classUpperca
|
|||
* @param dto ${comment}添加
|
||||
*/
|
||||
@Override
|
||||
public void add${classUppercaseName}(@Valid ${classUppercaseName}AddDto dto) {
|
||||
public void add${classUppercaseName}(${classUppercaseName}Dto dto) {
|
||||
${classUppercaseName} ${classLowercaseName} =new ${classUppercaseName}();
|
||||
BeanUtils.copyProperties(dto, ${classLowercaseName});
|
||||
save(${classLowercaseName});
|
||||
|
@ -59,7 +64,7 @@ public class ${classUppercaseName}ServiceImpl extends ServiceImpl<${classUpperca
|
|||
* @param dto ${comment}更新
|
||||
*/
|
||||
@Override
|
||||
public void update${classUppercaseName}(@Valid ${classUppercaseName}UpdateDto dto) {
|
||||
public void update${classUppercaseName}(${classUppercaseName}Dto dto) {
|
||||
${classUppercaseName} ${classLowercaseName} =new ${classUppercaseName}();
|
||||
BeanUtils.copyProperties(dto, ${classLowercaseName});
|
||||
updateById(${classLowercaseName});
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ${package}.service;
|
||||
|
||||
import cn.bunny.domain.entity.system.MenuIcon;
|
||||
import cn.bunny.domain.pojo.result.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
import ${package}.domain.dto.${classUppercaseName}Dto;
|
||||
import ${package}.domain.entity.${classUppercaseName};
|
||||
import ${package}.domain.vo.${classUppercaseName}Vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -28,16 +29,16 @@ public interface ${classUppercaseName}Service extends IService<${classUppercaseN
|
|||
/**
|
||||
* 添加${comment}
|
||||
*
|
||||
* @param dto 添加表单
|
||||
* @param dto {@link ${classUppercaseName}Dto} 添加表单
|
||||
*/
|
||||
void add${classUppercaseName}(${classUppercaseName}AddDto dto);
|
||||
void add${classUppercaseName}(${classUppercaseName}Dto dto);
|
||||
|
||||
/**
|
||||
* 更新${comment}
|
||||
*
|
||||
* @param dto {@link ${classUppercaseName}UpdateDto}
|
||||
* @param dto {@link ${classUppercaseName}Dto} 更新表单
|
||||
*/
|
||||
void update${classUppercaseName}(${classUppercaseName}UpdateDto dto);
|
||||
void update${classUppercaseName}(${classUppercaseName}Dto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除${comment}类型
|
||||
|
|
Loading…
Reference in New Issue