refactor: 实体命名规范调整,代码生成同步调整

This commit is contained in:
Ray.Hao
2025-12-18 09:43:36 +08:00
parent 5817826bbd
commit 8eaed3cfb7
165 changed files with 1885 additions and 2038 deletions

View File

@@ -0,0 +1,47 @@
/**
* ${entityName} $!{businessName}类型定义
*/
/** $!{businessName}分页查询参数 */
export interface ${entityName}PageQuery extends PageQuery {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInQuery)
#if("$!fieldConfig.fieldComment" != "")
/** ${fieldConfig.fieldComment} */
#end
#if($fieldConfig.formType == "DATE" || $fieldConfig.formType == "DATE_TIME")
#if($fieldConfig.queryType == "BETWEEN")
${fieldConfig.fieldName}?: [string, string];
#else
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#else
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#end
#end
}
/** $!{businessName}表单对象 */
export interface ${entityName}Form {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInForm)
#if("$!fieldConfig.fieldComment" != "")
/** ${fieldConfig.fieldComment} */
#end
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#end
}
/** $!{businessName}分页对象 */
export interface ${entityName}PageVo {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInList)
#if("$!fieldConfig.fieldComment" != "")
/** ${fieldConfig.fieldComment} */
#end
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#end
}

View File

@@ -1,12 +1,13 @@
import request from "@/utils/request";
import type { ${entityName}Form, ${entityName}PageQuery, ${entityName}PageVo } from "@/api/types";
const ${entityName.toUpperCase()}_BASE_URL = "/api/v1/${kebabCaseEntityName}";
const ${entityUpperSnake}_BASE_URL = "/api/v1/${entityKebab}";
const ${entityName}API = {
/** 获取${businessName}分页数据 */
getPage(queryParams?: ${entityName}PageQuery) {
return request<any, PageResult<${entityName}PageVO[]>>({
url: `${${entityName.toUpperCase()}_BASE_URL}/page`,
return request<any, PageResult<${entityName}PageVo[]>>({
url: `${${entityUpperSnake}_BASE_URL}/page`,
method: "get",
params: queryParams,
});
@@ -19,7 +20,7 @@ const ${entityName}API = {
*/
getFormData(id: number) {
return request<any, ${entityName}Form>({
url: `${${entityName.toUpperCase()}_BASE_URL}/${id}/form`,
url: `${${entityUpperSnake}_BASE_URL}/${id}/form`,
method: "get",
});
},
@@ -31,7 +32,7 @@ const ${entityName}API = {
*/
create(data: ${entityName}Form) {
return request({
url: `${${entityName.toUpperCase()}_BASE_URL}`,
url: `${${entityUpperSnake}_BASE_URL}`,
method: "post",
data,
});
@@ -45,7 +46,7 @@ const ${entityName}API = {
*/
update(id: string, data: ${entityName}Form) {
return request({
url: `${${entityName.toUpperCase()}_BASE_URL}/${id}`,
url: `${${entityUpperSnake}_BASE_URL}/${id}`,
method: "put",
data,
});
@@ -58,54 +59,10 @@ const ${entityName}API = {
*/
deleteByIds(ids: string) {
return request({
url: `${${entityName.toUpperCase()}_BASE_URL}/${ids}`,
url: `${${entityUpperSnake}_BASE_URL}/${ids}`,
method: "delete",
});
}
}
export default ${entityName}API;
/** ${businessName}分页查询参数 */
export interface ${entityName}PageQuery extends PageQuery {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInQuery)
#if("$!fieldConfig.fieldComment" != "")
/** ${fieldConfig.fieldComment} */
#end
#if($fieldConfig.formType == "DATE" || $fieldConfig.formType == "DATE_TIME")
#if($fieldConfig.queryType == "BETWEEN")
${fieldConfig.fieldName}?: [string, string];
#else
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#else
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#end
#end
}
/** ${businessName}表单对象 */
export interface ${entityName}Form {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInForm)
#if("$!fieldConfig.fieldComment" != "")
/** ${fieldConfig.fieldComment} */
#end
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#end
}
/** ${businessName}分页对象 */
export interface ${entityName}PageVO {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInList)
#if("$!fieldConfig.fieldComment" != "")
/** ${fieldConfig.fieldComment} */
#end
${fieldConfig.fieldName}?: ${fieldConfig.tsType};
#end
#end
}

View File

@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ${packageName}.${moduleName}.model.form.${entityName}Form;
import ${packageName}.${moduleName}.model.query.${entityName}Query;
import ${packageName}.${moduleName}.model.vo.${entityName}VO;
import ${packageName}.${moduleName}.model.vo.${entityName}Vo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.boot.core.web.PageResult;
import com.youlai.boot.core.web.Result;
@@ -26,56 +26,56 @@ import jakarta.validation.Valid;
*/
@Tag(name = "${businessName}接口")
@RestController
@RequestMapping("/api/v1/${kebabCaseEntityName}")
@RequestMapping("/api/v1/${entityKebab}")
@RequiredArgsConstructor
public class ${entityName}Controller {
private final ${entityName}Service ${lowerFirstEntityName}Service;
private final ${entityName}Service ${entityLowerCamel}Service;
@Operation(summary = "$!{businessName}分页列表")
@GetMapping("/page")
@PreAuthorize("@ss.hasPerm('${moduleName}:${kebabCaseEntityName}:query')")
public PageResult<${entityName}VO> get${entityName}Page(${entityName}Query queryParams ) {
IPage<${entityName}VO> result = ${lowerFirstEntityName}Service.get${entityName}Page(queryParams);
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:query')")
public PageResult<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams ) {
IPage<${entityName}Vo> result = ${entityLowerCamel}Service.get${entityName}Page(queryParams);
return PageResult.success(result);
}
@Operation(summary = "新增${businessName}")
@PostMapping
@PreAuthorize("@ss.hasPerm('${moduleName}:${kebabCaseEntityName}:add')")
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:add')")
public Result<Void> save${entityName}(@RequestBody @Valid ${entityName}Form formData ) {
boolean result = ${lowerFirstEntityName}Service.save${entityName}(formData);
boolean result = ${entityLowerCamel}Service.save${entityName}(formData);
return Result.judge(result);
}
@Operation(summary = "获取${businessName}表单数据")
@GetMapping("/{id}/form")
@PreAuthorize("@ss.hasPerm('${moduleName}:${kebabCaseEntityName}:edit')")
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:edit')")
public Result<${entityName}Form> get${entityName}Form(
@Parameter(description = "$!{businessName}ID") @PathVariable Long id
) {
${entityName}Form formData = ${lowerFirstEntityName}Service.get${entityName}FormData(id);
${entityName}Form formData = ${entityLowerCamel}Service.get${entityName}FormData(id);
return Result.success(formData);
}
@Operation(summary = "修改${businessName}")
@PutMapping(value = "/{id}")
@PreAuthorize("@ss.hasPerm('${moduleName}:${kebabCaseEntityName}:edit')")
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:edit')")
public Result<Void> update${entityName}(
@Parameter(description = "$!{businessName}ID") @PathVariable Long id,
@RequestBody @Validated ${entityName}Form formData
) {
boolean result = ${lowerFirstEntityName}Service.update${entityName}(id, formData);
boolean result = ${entityLowerCamel}Service.update${entityName}(id, formData);
return Result.judge(result);
}
@Operation(summary = "删除${businessName}")
@DeleteMapping("/{ids}")
@PreAuthorize("@ss.hasPerm('${moduleName}:${kebabCaseEntityName}:delete')")
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:delete')")
public Result<Void> delete${entityName}s(
@Parameter(description = "$!{businessName}ID多个以英文逗号(,)分割") @PathVariable String ids
) {
boolean result = ${lowerFirstEntityName}Service.delete${entityName}s(ids);
boolean result = ${entityLowerCamel}Service.delete${entityName}s(ids);
return Result.judge(result);
}
}

View File

@@ -63,7 +63,8 @@
<script setup lang="ts">
defineOptions({ name: "$entityName" });
import ${entityName}API, { ${entityName}Form, ${entityName}PageQuery } from "@/api/${moduleName}/${kebabCaseEntityName}-api";
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
import type { ${entityName}Form, ${entityName}PageQuery } from "@/api/types";
import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
import usePage from "@/components/CURD/usePage";
@@ -85,7 +86,7 @@ const {
// 搜索配置
const searchConfig: ISearchConfig = reactive({
permPrefix: "${moduleName}:${kebabCaseEntityName}",
permPrefix: "${moduleName}:${entityKebab}",
formItems: [
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInQuery == 1)
@@ -136,7 +137,7 @@ const searchConfig: ISearchConfig = reactive({
// 列表配置
const contentConfig: IContentConfig<${entityName}PageQuery> = reactive({
// 权限前缀
permPrefix: "${moduleName}:${kebabCaseEntityName}",
permPrefix: "${moduleName}:${entityKebab}",
table: {
border: true,
highlightCurrentRow: true,
@@ -194,7 +195,7 @@ const contentConfig: IContentConfig<${entityName}PageQuery> = reactive({
// 新增配置
const addModalConfig: IModalConfig<${entityName}Form> = reactive({
// 权限前缀
permPrefix: "${moduleName}:${kebabCaseEntityName}",
permPrefix: "${moduleName}:${entityKebab}",
// 主键
pk: "id",
// 弹窗配置
@@ -340,7 +341,7 @@ const addModalConfig: IModalConfig<${entityName}Form> = reactive({
// 编辑配置
const editModalConfig: IModalConfig<${entityName}Form> = reactive({
permPrefix: "${moduleName}:${kebabCaseEntityName}",
permPrefix: "${moduleName}:${entityKebab}",
component: "drawer",
drawer: {
title: "编辑$!{entityComment}",

View File

@@ -98,13 +98,13 @@
<el-card shadow="never">
<div class="mb-10px">
<el-button
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:add']"
v-hasPerm="['${moduleName}:${entityKebab}:add']"
type="success"
icon="plus"
@click="handleOpenDialog()"
>新增</el-button>
<el-button
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:delete']"
v-hasPerm="['${moduleName}:${entityKebab}:delete']"
type="danger"
:disabled="removeIds.length === 0"
icon="delete"
@@ -143,7 +143,7 @@
<el-table-column fixed="right" label="操作" width="220">
<template #default="scope">
<el-button
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:edit']"
v-hasPerm="['${moduleName}:${entityKebab}:edit']"
type="primary"
size="small"
link
@@ -153,7 +153,7 @@
编辑
</el-button>
<el-button
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:delete']"
v-hasPerm="['${moduleName}:${entityKebab}:delete']"
type="danger"
size="small"
link
@@ -273,7 +273,8 @@
inheritAttrs: false,
});
import ${entityName}API, { ${entityName}PageVO, ${entityName}Form, ${entityName}PageQuery } from "@/api/${moduleName}/${kebabCaseEntityName}-api";
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
import type { ${entityName}PageVo, ${entityName}Form, ${entityName}PageQuery } from "@/api/types";
const queryFormRef = ref();
const dataFormRef = ref();
@@ -288,7 +289,7 @@
});
// $!{businessName}表格数据
const pageData = ref<${entityName}PageVO[]>([]);
const pageData = ref<${entityName}PageVo[]>([]);
// 弹窗
const dialog = reactive({

View File

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import ${packageName}.${moduleName}.model.entity.${entityName};
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${packageName}.${moduleName}.model.query.${entityName}Query;
import ${packageName}.${moduleName}.model.vo.${entityName}VO;
import ${packageName}.${moduleName}.model.vo.${entityName}Vo;
import org.apache.ibatis.annotations.Mapper;
/**
@@ -21,8 +21,8 @@ public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
*
* @param page 分页对象
* @param queryParams 查询参数
* @return {@link Page<${entityName}VO>} $!{businessName}分页列表
* @return {@link Page<${entityName}Vo>} $!{businessName}分页列表
*/
Page<${entityName}VO> get${entityName}Page(Page<${entityName}VO> page, ${entityName}Query queryParams);
Page<${entityName}Vo> get${entityName}Page(Page<${entityName}Vo> page, ${entityName}Query queryParams);
}

View File

@@ -3,7 +3,7 @@
<mapper namespace="${packageName}.${moduleName}.mapper.${entityName}Mapper">
<!-- 获取${businessName}分页列表 -->
<select id="get${entityName}Page" resultType="${packageName}.${moduleName}.model.vo.${entityName}VO">
<select id="get${entityName}Page" resultType="${packageName}.${moduleName}.model.vo.${entityName}Vo">
SELECT
#if($fieldConfigs)
#set ($fields = [])

View File

@@ -3,7 +3,7 @@ package ${packageName}.${moduleName}.${subpackageName};
import ${packageName}.${moduleName}.model.entity.${entityName};
import ${packageName}.${moduleName}.model.form.${entityName}Form;
import ${packageName}.${moduleName}.model.query.${entityName}Query;
import ${packageName}.${moduleName}.model.vo.${entityName}VO;
import ${packageName}.${moduleName}.model.vo.${entityName}Vo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -18,9 +18,9 @@ public interface ${entityName}Service extends IService<${entityName}> {
/**
*$!{businessName}分页列表
*
* @return {@link IPage<${entityName}VO>} $!{businessName}分页列表
* @return {@link IPage<${entityName}Vo>} $!{businessName}分页列表
*/
IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams);
IPage<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams);
/**
* 获取${businessName}表单数据

View File

@@ -10,7 +10,7 @@ import ${packageName}.${moduleName}.service.${entityName}Service;
import ${packageName}.${moduleName}.model.entity.${entityName};
import ${packageName}.${moduleName}.model.form.${entityName}Form;
import ${packageName}.${moduleName}.model.query.${entityName}Query;
import ${packageName}.${moduleName}.model.vo.${entityName}VO;
import ${packageName}.${moduleName}.model.vo.${entityName}Vo;
import ${packageName}.${moduleName}.converter.${entityName}Converter;
import java.util.Arrays;
@@ -30,21 +30,21 @@ import cn.hutool.core.util.StrUtil;
@RequiredArgsConstructor
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {
private final ${entityName}Converter ${lowerFirstEntityName}Converter;
private final ${entityName}Converter ${entityLowerCamel}Converter;
/**
* 获取${businessName}分页列表
*
* @param queryParams 查询参数
* @return {@link IPage<${entityName}VO>} $!{businessName}分页列表
* @return {@link IPage<${entityName}Vo>} $!{businessName}分页列表
*/
@Override
public IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams) {
Page<${entityName}VO> pageVO = this.baseMapper.get${entityName}Page(
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
);
return pageVO;
return pageVo;
}
/**
@@ -56,7 +56,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
@Override
public ${entityName}Form get${entityName}FormData(Long id) {
${entityName} entity = this.getById(id);
return ${lowerFirstEntityName}Converter.toForm(entity);
return ${entityLowerCamel}Converter.toForm(entity);
}
/**
@@ -67,7 +67,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
*/
@Override
public boolean save${entityName}(${entityName}Form formData) {
${entityName} entity = ${lowerFirstEntityName}Converter.toEntity(formData);
${entityName} entity = ${entityLowerCamel}Converter.toEntity(formData);
return this.save(entity);
}
@@ -80,7 +80,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
*/
@Override
public boolean update${entityName}(Long id,${entityName}Form formData) {
${entityName} entity = ${lowerFirstEntityName}Converter.toEntity(formData);
${entityName} entity = ${entityLowerCamel}Converter.toEntity(formData);
return this.updateById(entity);
}

View File

@@ -22,7 +22,7 @@ import java.math.BigDecimal;
@Getter
@Setter
@Schema( description = "$!{businessName}视图对象")
public class ${entityName}VO implements Serializable {
public class ${entityName}Vo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;