refactor: 优化代码生成模板中的业务名称显示
- 在 API、控制器、转换器、实体、表单、Mapper 等文件中 - 将业务名称的显示使用 trim() 方法去除前后空格 - 优化代码注释和接口文档中的业务名称显示效果
This commit is contained in:
@@ -3,7 +3,7 @@ import request from "@/utils/request";
|
||||
const ${entityName.toUpperCase()}_BASE_URL = "/api/v1/${lowerFirstEntityName}s";
|
||||
|
||||
const ${entityName}API = {
|
||||
/** 获取${businessName}分页数据 */
|
||||
/** 获取${businessName.trim()}分页数据 */
|
||||
getPage(queryParams?: ${entityName}PageQuery) {
|
||||
return request<any, PageResult<${entityName}PageVO[]>>({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}/page`,
|
||||
@@ -12,7 +12,7 @@ const ${entityName}API = {
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取${businessName}表单数据
|
||||
* 获取${businessName.trim()}表单数据
|
||||
*
|
||||
* @param id ${entityName}ID
|
||||
* @returns ${entityName}表单数据
|
||||
@@ -24,7 +24,7 @@ const ${entityName}API = {
|
||||
});
|
||||
},
|
||||
|
||||
/** 添加${businessName}*/
|
||||
/** 添加${businessName.trim()}*/
|
||||
add(data: ${entityName}Form) {
|
||||
return request({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}`,
|
||||
@@ -34,7 +34,7 @@ const ${entityName}API = {
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新${businessName}
|
||||
* 更新${businessName.trim()}
|
||||
*
|
||||
* @param id ${entityName}ID
|
||||
* @param data ${entityName}表单数据
|
||||
@@ -48,9 +48,9 @@ const ${entityName}API = {
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量删除${businessName},多个以英文逗号(,)分割
|
||||
* 批量删除${businessName.trim()},多个以英文逗号(,)分割
|
||||
*
|
||||
* @param ids ${businessName}ID字符串,多个以英文逗号(,)分割
|
||||
* @param ids ${businessName.trim()}ID字符串,多个以英文逗号(,)分割
|
||||
*/
|
||||
deleteByIds(ids: string) {
|
||||
return request({
|
||||
@@ -62,7 +62,7 @@ const ${entityName}API = {
|
||||
|
||||
export default ${entityName}API;
|
||||
|
||||
/** ${businessName}分页查询参数 */
|
||||
/** ${businessName.trim()}分页查询参数 */
|
||||
export interface ${entityName}PageQuery extends PageQuery {
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInQuery)
|
||||
@@ -82,7 +82,7 @@ export interface ${entityName}PageQuery extends PageQuery {
|
||||
#end
|
||||
}
|
||||
|
||||
/** ${businessName}表单对象 */
|
||||
/** ${businessName.trim()}表单对象 */
|
||||
export interface ${entityName}Form {
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInForm)
|
||||
@@ -94,7 +94,7 @@ export interface ${entityName}Form {
|
||||
#end
|
||||
}
|
||||
|
||||
/** ${businessName}分页对象 */
|
||||
/** ${businessName.trim()}分页对象 */
|
||||
export interface ${entityName}PageVO {
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInList)
|
||||
|
||||
@@ -19,12 +19,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* $!{businessName}前端控制层
|
||||
* $!{businessName.trim()}前端控制层
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Tag(name = "${businessName}接口")
|
||||
@Tag(name = "${businessName.trim()}接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/${lowerFirstEntityName}s")
|
||||
@RequiredArgsConstructor
|
||||
@@ -32,7 +32,7 @@ public class ${entityName}Controller {
|
||||
|
||||
private final ${entityName}Service ${lowerFirstEntityName}Service;
|
||||
|
||||
@Operation(summary = "$!{businessName}分页列表")
|
||||
@Operation(summary = "$!{businessName.trim()}分页列表")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:query')")
|
||||
public PageResult<${entityName}VO> get${entityName}Page(${entityName}Query queryParams ) {
|
||||
@@ -40,7 +40,7 @@ public class ${entityName}Controller {
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增${businessName}")
|
||||
@Operation(summary = "新增${businessName.trim()}")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:add')")
|
||||
public Result<Void> save${entityName}(@RequestBody @Valid ${entityName}Form formData ) {
|
||||
@@ -48,32 +48,32 @@ public class ${entityName}Controller {
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取${businessName}表单数据")
|
||||
@Operation(summary = "获取${businessName.trim()}表单数据")
|
||||
@GetMapping("/{id}/form")
|
||||
@PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:edit')")
|
||||
public Result<${entityName}Form> get${entityName}Form(
|
||||
@Parameter(description = "$!{businessName}ID") @PathVariable Long id
|
||||
@Parameter(description = "$!{businessName.trim()}ID") @PathVariable Long id
|
||||
) {
|
||||
${entityName}Form formData = ${lowerFirstEntityName}Service.get${entityName}FormData(id);
|
||||
return Result.success(formData);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改${businessName}")
|
||||
@Operation(summary = "修改${businessName.trim()}")
|
||||
@PutMapping(value = "/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:edit')")
|
||||
public Result<Void> update${entityName}(
|
||||
@Parameter(description = "$!{businessName}ID") @PathVariable Long id,
|
||||
@Parameter(description = "$!{businessName.trim()}ID") @PathVariable Long id,
|
||||
@RequestBody @Validated ${entityName}Form formData
|
||||
) {
|
||||
boolean result = ${lowerFirstEntityName}Service.update${entityName}(id, formData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除${businessName}")
|
||||
@Operation(summary = "删除${businessName.trim()}")
|
||||
@DeleteMapping("/{ids}")
|
||||
@PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:delete')")
|
||||
public Result<Void> delete${entityName}s(
|
||||
@Parameter(description = "$!{businessName}ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
@Parameter(description = "$!{businessName.trim()}ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
) {
|
||||
boolean result = ${lowerFirstEntityName}Service.delete${entityName}s(ids);
|
||||
return Result.judge(result);
|
||||
|
||||
@@ -6,7 +6,7 @@ import ${packageName}.${moduleName}.model.entity.${entityName};
|
||||
import ${packageName}.${moduleName}.model.form.${entityName}Form;
|
||||
|
||||
/**
|
||||
* $!{businessName}对象转换器
|
||||
* $!{businessName.trim()}对象转换器
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
|
||||
@@ -12,14 +12,14 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.youlai.boot.common.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* $!{businessName}实体对象
|
||||
* $!{businessName.trim()}实体对象
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("${tableName}")
|
||||
@TableName("${tableName.trim()}")
|
||||
public class ${entityName} extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -16,14 +16,14 @@ import jakarta.validation.constraints.*;
|
||||
#end
|
||||
|
||||
/**
|
||||
* $!{businessName}表单对象
|
||||
* $!{businessName.trim()}表单对象
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "$!{businessName}表单对象")
|
||||
@Schema(description = "$!{businessName.trim()}表单对象")
|
||||
public class ${entityName}Form implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- $!{businessName}表单弹窗 -->
|
||||
<!-- $!{businessName.trim()}表单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="dialog.visible"
|
||||
:title="dialog.title"
|
||||
@@ -270,7 +270,7 @@
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
// $!{businessName}表格数据
|
||||
// $!{businessName.trim()}表格数据
|
||||
const pageData = ref<${entityName}PageVO[]>([]);
|
||||
|
||||
// 弹窗
|
||||
@@ -279,10 +279,10 @@
|
||||
visible: false,
|
||||
});
|
||||
|
||||
// $!{businessName}表单数据
|
||||
// $!{businessName.trim()}表单数据
|
||||
const formData = reactive<${entityName}Form>({});
|
||||
|
||||
// $!{businessName}表单校验规则
|
||||
// $!{businessName.trim()}表单校验规则
|
||||
const rules = reactive({
|
||||
#if($fieldConfigs)
|
||||
#foreach($fieldConfig in ${fieldConfigs})
|
||||
@@ -293,7 +293,7 @@
|
||||
#end
|
||||
});
|
||||
|
||||
/** 查询$!{businessName} */
|
||||
/** 查询$!{businessName.trim()} */
|
||||
function handleQuery() {
|
||||
loading.value = true;
|
||||
${entityName}API.getPage(queryParams)
|
||||
@@ -306,7 +306,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
/** 重置$!{businessName}查询 */
|
||||
/** 重置$!{businessName.trim()}查询 */
|
||||
function handleResetQuery() {
|
||||
queryFormRef.value!.resetFields();
|
||||
queryParams.pageNum = 1;
|
||||
@@ -318,20 +318,20 @@
|
||||
removeIds.value = selection.map((item: any) => item.id);
|
||||
}
|
||||
|
||||
/** 打开$!{businessName}弹窗 */
|
||||
/** 打开$!{businessName.trim()}弹窗 */
|
||||
function handleOpenDialog(id?: number) {
|
||||
dialog.visible = true;
|
||||
if (id) {
|
||||
dialog.title = "修改$!{businessName}";
|
||||
dialog.title = "修改$!{businessName.trim()}";
|
||||
${entityName}API.getFormData(id).then((data) => {
|
||||
Object.assign(formData, data);
|
||||
});
|
||||
} else {
|
||||
dialog.title = "新增$!{businessName}";
|
||||
dialog.title = "新增$!{businessName.trim()}";
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交$!{businessName}表单 */
|
||||
/** 提交$!{businessName.trim()}表单 */
|
||||
function handleSubmit() {
|
||||
dataFormRef.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
@@ -358,7 +358,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
/** 关闭$!{businessName}弹窗 */
|
||||
/** 关闭$!{businessName.trim()}弹窗 */
|
||||
function handleCloseDialog() {
|
||||
dialog.visible = false;
|
||||
dataFormRef.value.resetFields();
|
||||
@@ -366,7 +366,7 @@
|
||||
formData.id = undefined;
|
||||
}
|
||||
|
||||
/** 删除$!{businessName} */
|
||||
/** 删除$!{businessName.trim()} */
|
||||
function handleDelete(id?: number) {
|
||||
const ids = [id || removeIds.value].join(",");
|
||||
if (!ids) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import ${packageName}.${moduleName}.model.vo.${entityName}VO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* $!{businessName}Mapper接口
|
||||
* $!{businessName.trim()}Mapper接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
@@ -17,7 +17,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
|
||||
|
||||
/**
|
||||
* 获取${businessName}分页数据
|
||||
* 获取${businessName.trim()}分页数据
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryParams 查询参数
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${packageName}.${moduleName}.mapper.${entityName}Mapper">
|
||||
|
||||
<!-- 获取${businessName}分页列表 -->
|
||||
<!-- 获取${businessName.trim()}分页列表 -->
|
||||
<select id="get${entityName}Page" resultType="${packageName}.${moduleName}.model.vo.${entityName}VO">
|
||||
SELECT
|
||||
#if($fieldConfigs)
|
||||
|
||||
@@ -13,12 +13,12 @@ import java.math.BigDecimal;
|
||||
#end
|
||||
|
||||
/**
|
||||
* $!{businessName}分页查询对象
|
||||
* $!{businessName.trim()}分页查询对象
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Schema(description ="$!{businessName}查询对象")
|
||||
@Schema(description ="$!{businessName.trim()}查询对象")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ${entityName}Query extends BasePageQuery {
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* $!{businessName}服务类
|
||||
* $!{businessName.trim()}服务类
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
@@ -16,41 +16,41 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface ${entityName}Service extends IService<${entityName}> {
|
||||
|
||||
/**
|
||||
*$!{businessName}分页列表
|
||||
*$!{businessName.trim()}分页列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams);
|
||||
|
||||
/**
|
||||
* 获取${businessName}表单数据
|
||||
* 获取${businessName.trim()}表单数据
|
||||
*
|
||||
* @param id $!{businessName}ID
|
||||
* @param id $!{businessName.trim()}ID
|
||||
* @return
|
||||
*/
|
||||
${entityName}Form get${entityName}FormData(Long id);
|
||||
|
||||
/**
|
||||
* 新增${businessName}
|
||||
* 新增${businessName.trim()}
|
||||
*
|
||||
* @param formData $!{businessName}表单对象
|
||||
* @param formData $!{businessName.trim()}表单对象
|
||||
* @return
|
||||
*/
|
||||
boolean save${entityName}(${entityName}Form formData);
|
||||
|
||||
/**
|
||||
* 修改${businessName}
|
||||
* 修改${businessName.trim()}
|
||||
*
|
||||
* @param id $!{businessName}ID
|
||||
* @param formData $!{businessName}表单对象
|
||||
* @param id $!{businessName.trim()}ID
|
||||
* @param formData $!{businessName.trim()}表单对象
|
||||
* @return
|
||||
*/
|
||||
boolean update${entityName}(Long id, ${entityName}Form formData);
|
||||
|
||||
/**
|
||||
* 删除${businessName}
|
||||
* 删除${businessName.trim()}
|
||||
*
|
||||
* @param ids $!{businessName}ID,多个以英文逗号(,)分割
|
||||
* @param ids $!{businessName.trim()}ID,多个以英文逗号(,)分割
|
||||
* @return
|
||||
*/
|
||||
boolean delete${entityName}s(String ids);
|
||||
|
||||
@@ -21,7 +21,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* $!{businessName}服务实现类
|
||||
* $!{businessName.trim()}服务实现类
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
@@ -33,10 +33,10 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
||||
private final ${entityName}Converter ${lowerFirstEntityName}Converter;
|
||||
|
||||
/**
|
||||
* 获取${businessName}分页列表
|
||||
* 获取${businessName.trim()}分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return {@link IPage<${entityName}VO>} $!{businessName}分页列表
|
||||
* @return {@link IPage<${entityName}VO>} $!{businessName.trim()}分页列表
|
||||
*/
|
||||
@Override
|
||||
public IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams) {
|
||||
@@ -48,9 +48,9 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取${businessName}表单数据
|
||||
* 获取${businessName.trim()}表单数据
|
||||
*
|
||||
* @param id $!{businessName}ID
|
||||
* @param id $!{businessName.trim()}ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -60,9 +60,9 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${businessName}
|
||||
* 新增${businessName.trim()}
|
||||
*
|
||||
* @param formData $!{businessName}表单对象
|
||||
* @param formData $!{businessName.trim()}表单对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -72,10 +72,10 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新${businessName}
|
||||
* 更新${businessName.trim()}
|
||||
*
|
||||
* @param id $!{businessName}ID
|
||||
* @param formData $!{businessName}表单对象
|
||||
* @param id $!{businessName.trim()}ID
|
||||
* @param formData $!{businessName.trim()}表单对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -85,14 +85,14 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${businessName}
|
||||
* 删除${businessName.trim()}
|
||||
*
|
||||
* @param ids $!{businessName}ID,多个以英文逗号(,)分割
|
||||
* @param ids $!{businessName.trim()}ID,多个以英文逗号(,)分割
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean delete${entityName}s(String ids) {
|
||||
Assert.isTrue(StrUtil.isNotBlank(ids), "删除的${businessName}数据为空");
|
||||
Assert.isTrue(StrUtil.isNotBlank(ids), "删除的${businessName.trim()}数据为空");
|
||||
// 逻辑删除
|
||||
List<Long> idList = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
|
||||
@@ -14,14 +14,14 @@ import java.math.BigDecimal;
|
||||
#end
|
||||
|
||||
/**
|
||||
* $!{businessName}视图对象
|
||||
* $!{businessName.trim()}视图对象
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema( description = "$!{businessName}视图对象")
|
||||
@Schema( description = "$!{businessName.trim()}视图对象")
|
||||
public class ${entityName}VO implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
||||
Reference in New Issue
Block a user