Revert "!6 fix: 代码生成字段和模板引用包缺失问题修复"

This reverts commit 4f6bd537d2.
This commit is contained in:
郝先瑞
2024-07-24 11:59:08 +00:00
committed by Gitee
parent 4f6bd537d2
commit 34d6f6e375
38 changed files with 136 additions and 1076 deletions

View File

@@ -3,41 +3,7 @@ generator:
## 模板配置
templateConfigs:
Controller:
templatePath: generator/controller.java.vm
packageName: controller
Service:
templatePath: generator/service.java.vm
packageName: service
ServiceImpl:
templatePath: generator/serviceImpl.java.vm
packageName: service.impl
Mapper:
templatePath: generator/mapper.java.vm
packageName: mapper
MapperXml:
templatePath: generator/mapper.xml.vm
packageName: mapper
extension: .xml
Query:
templatePath: generator/query.java.vm
packageName: model.query
Form:
templatePath: generator/form.java.vm
packageName: model.form
VO:
templatePath: generator/vo.java.vm
packageName: model.vo
Entity:
templatePath: generator/entity.java.vm
packageName: model.entity
API:
templatePath: generator/api.ts.vm
packageName: api
extension: .ts
VIEW:
templatePath: generator/index.vue.vm
packageName: views
extension: .vue
## 模板路径
templatePath: templates/generator/controller.java.vm
## 包名
packageName: controller

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.GenConfigMapper">
</mapper>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.GenFieldConfigMapper">
<resultMap id="BaseResultMap" type="com.youlai.system.model.entity.GenFieldConfig">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="configId" column="config_id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="showInList" column="show_in_list" jdbcType="TINYINT"/>
<result property="showInForm" column="show_in_form" jdbcType="TINYINT"/>
<result property="showInQuery" column="show_in_query" jdbcType="TINYINT"/>
<result property="formType" column="form_type" jdbcType="VARCHAR"/>
<result property="queryMethod" column="query_method" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,config_id,name,
type,description,show_in_list,
show_in_form,show_in_query,form_type,
query_method,create_time,update_time
</sql>
</mapper>

View File

@@ -1,121 +0,0 @@
import request from "@/utils/request";
const ${className.toUpperCase()}_BASE_URL = "/api/v1/${className.toLowerCase()}s";
class ${className}API {
/** 获取${className}分页数据 */
static getPage(queryParams?: ${className}PageQuery) {
return request<any, PageResult<${className}PageVO[]>>({
url: `${${className.toUpperCase()}_BASE_URL}/page`,
method: "get",
params: queryParams,
});
}
/** 获取${className}下拉数据源 */
static getOptions() {
return request<any, OptionType[]>({
url: `${${className.toUpperCase()}_BASE_URL}/options`,
method: "get",
});
}
/**
* 获取${className}的菜单ID集合
*
* @param ${className.toLowerCase()}Id ${className}ID
* @returns ${className}的菜单ID集合
*/
static get${className}MenuIds(${className.toLowerCase()}Id: number) {
return request<any, number[]>({
url: `${${className.toUpperCase()}_BASE_URL}/${${className.toLowerCase()}Id}/menuIds`,
method: "get",
});
}
/**
* 分配菜单权限
*
* @param ${className.toLowerCase()}Id ${className}ID
* @param data 菜单ID集合
*/
static update${className}Menus(${className.toLowerCase()}Id: number, data: number[]) {
return request({
url: `${${className.toUpperCase()}_BASE_URL}/${${className.toLowerCase()}Id}/menus`,
method: "put",
data: data,
});
}
/**
* 获取${className}表单数据
*
* @param id ${className}ID
* @returns ${className}表单数据
*/
static getFormData(id: number) {
return request<any, ${className}Form>({
url: `${${className.toUpperCase()}_BASE_URL}/${id}/form`,
method: "get",
});
}
/** 添加${className} */
static add(data: ${className}Form) {
return request({
url: `${${className.toUpperCase()}_BASE_URL}`,
method: "post",
data: data,
});
}
/**
* 更新${className}
*
* @param id ${className}ID
* @param data ${className}表单数据
*/
static update(id: number, data: ${className}Form) {
return request({
url: `${${className.toUpperCase()}_BASE_URL}/${id}`,
method: "put",
data: data,
});
}
/**
* 批量删除${className},多个以英文逗号(,)分割
*
* @param ids ${className}ID字符串多个以英文逗号(,)分割
*/
static deleteByIds(ids: string) {
return request({
url: `${${className.toUpperCase()}_BASE_URL}/${ids}`,
method: "delete",
});
}
}
export default ${className}API;
/** ${className}分页查询参数 */
export interface ${className}PageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
}
/** ${className}分页对象 */
export interface ${className}PageVO {
#foreach($field in $fields)
/** ${field.comment} */
${field.name}?: ${field.type};
#end
}
/** ${className}表单对象 */
export interface ${className}Form {
#foreach($field in $fields)
/** ${field.comment} */
${field.name}?: ${field.type};
#end
}

View File

@@ -7,8 +7,8 @@ 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.system.common.result.PageResult;
import com.youlai.system.common.result.Result;
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;
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
/**
* $!{tableComment}前端控制
* $!{tableComment} 前端控制
*
* @author ${author}
* @since ${date}
@@ -44,7 +44,7 @@ public class ${entityName}Controller {
return Result.judge(result);
}
@Operation(summary = "获取$!{tableComment}表单数据")
@Operation(summary = "$!{tableComment}表单数据")
@GetMapping("/{id}/form")
public Result<${entityName}Form> get${entityName}Form(
@Parameter(description = "$!{tableComment}ID") @PathVariable Long id

View File

@@ -6,7 +6,7 @@ import ${package}.model.entity.${entityName};
import ${package}.model.form.${entityName}Form;
/**
* $!{tableComment}对象转换器
* $!{tableComment}转换器
*
* @author ${author}
* @since ${date}

View File

@@ -23,14 +23,13 @@ import com.youlai.system.common.base.BaseEntity;
public class ${entityName} extends BaseEntity {
private static final long serialVersionUID = 1L;
#if($fieldConfigs)
#foreach($fieldConfig in ${fieldConfigs})
#if("$!fieldConfig.fieldComment" != "")
#foreach($field in ${table.fields})
#if("$!field.comment" != "")
/**
* ${fieldConfig.fieldComment}
* ${field.comment}
*/
#end
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
#end
#end
private ${field.propertyType} ${field.propertyName};
#end
}

View File

@@ -1,4 +1,4 @@
package ${package}.${subPackage};
package ${package}.model.form;
import java.io.Serial;
import java.io.Serializable;
@@ -11,12 +11,10 @@ import java.time.LocalDateTime;
#if(${hasBigDecimal})
import java.math.BigDecimal;
#end
#if(${hasRequiredField})
import jakarta.validation.constraints.*;
#end
/**
* $!{tableComment}表单对象
* $!{tableComment} 表单对象
*
* @author ${author}
* @since ${date}
@@ -30,22 +28,10 @@ public class ${entityName}Form implements Serializable {
private static final long serialVersionUID = 1L;
## ---------- BEGIN 字段循环遍历 ----------
#if($fieldConfigs)
#foreach($fieldConfig in ${fieldConfigs})
#if($fieldConfig.showInForm)
#if($fieldConfig.isRequired)
#if($fieldConfig.fieldType == 'String')
@NotBlank(message = "$fieldConfig.fieldComment不能为空")
#else
@NotNull(message = "$fieldConfig.fieldComment不能为空")
#end
#end
#if("$!fieldConfig.fieldComment" != "")
@Schema(description = "${fieldConfig.fieldComment}")
#end
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
#end
#foreach($field in ${fields})
#if("$!field.comment" != "")
@Schema(description = "${field.comment}")
#end
private ${field.propertyType} ${field.propertyName};
#end
}

View File

@@ -1,178 +0,0 @@
<template>
<div class="app-container">
<div class="search-container">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item prop="keywords" label="关键字">
<el-input
v-model="queryParams.keywords"
placeholder="${className}名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">
<i-ep-search />
搜索
</el-button>
<el-button @click="handleResetQuery">
<i-ep-refresh />
重置
</el-button>
</el-form-item>
</el-form>
</div>
<el-card shadow="never" class="table-container">
<template #header>
<el-button type="success" @click="handleOpenDialog()">
<i-ep-plus />
新增
</el-button>
<el-button
type="danger"
:disabled="ids.length === 0"
@click="handleDelete()"
>
<i-ep-delete />
删除
</el-button>
</template>
<el-table
ref="dataTableRef"
v-loading="loading"
:data="${className.toLowerCase()}List"
highlight-current-row
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
#foreach($field in $fields)
<el-table-column label="${field.comment}" prop="${field.name}" min-width="100" />
#end
<el-table-column fixed="right" label="操作" width="220">
<template #default="scope">
<el-button
type="primary"
size="small"
link
@click="handleOpenDialog(scope.row.id)"
>
<i-ep-edit />
编辑
</el-button>
<el-button
type="danger"
size="small"
link
@click="handleDelete(scope.row.id)"
>
<i-ep-delete />
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-if="total > 0"
v-model:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="handleQuery"
/>
</el-card>
<!-- ${className}表单弹窗 -->
<el-dialog
v-model="dialog.visible"
:title="dialog.title"
width="500px"
@close="handleCloseDialog"
>
<el-form
ref="${className.toLowerCase()}FormRef"
:model="formData"
:rules="rules"
label-width="100px"
>
#foreach($field in $fields)
<el-form-item label="${field.comment}" prop="${field.name}">
<el-input v-model="formData.${field.name}" placeholder="请输入${field.comment}" />
</el-form-item>
#end
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="handleSubmit">确 定</el-button>
<el-button @click="handleCloseDialog">取 消</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
defineOptions({
name: "${className}",
inheritAttrs: false,
});
import ${className}API, { ${className}PageVO, ${className}Form, ${className}PageQuery } from "@/api/${className.toLowerCase()}";
const queryFormRef = ref(ElForm);
const ${className.toLowerCase()}FormRef = ref(ElForm);
const loading = ref(false);
const ids = ref<number[]>([]);
const total = ref(0);
const queryParams = reactive<${className}PageQuery>({
pageNum: 1,
pageSize: 10,
});
// ${className}表格数据
const ${className.toLowerCase()}List = ref<${className}PageVO[]>();
// 弹窗
const dialog = reactive({
title: "",
visible: false,
});
// ${className}表单
const formData = reactive<${className}Form>({});
const rules = reactive({
#foreach($field in $fields)
${field.name}: [{ required: true, message: "请输入${field.comment}", trigger: "blur" }],
#end
});
/** 查询 */
function handleQuery() {
loading.value = true;
${className}API.getPage(queryParams)
.then((data) => {
${className.toLowerCase()}List.value = data.list;
total.value = data.total;
})
.finally(() => {
loading.value = false;
});
}
/** 重置查询 */
function handleResetQuery() {
queryFormRef.value.resetFields();
queryParams.pageNum = 1;
handleQuery();
}
/** 行复选框选中记录选中ID集合 */
function handleSelectionChange(selection: any) {
ids.value = selection.map((item: any

View File

@@ -7,7 +7,7 @@ import ${package}.model.query.${entityName}Query;
import org.apache.ibatis.annotations.Mapper;
/**
* $!{tableComment}Mapper接口
* $!{tableComment} 数据库访问层
*
* @author ${author}
* @since ${date}

View File

@@ -3,7 +3,7 @@
<mapper namespace="${package}.mapper.${entityName}Mapper">
<!-- 获取${tableComment}分页列表 -->
<select id="get${entityName}Page" resultType="${package}.model.vo.${entityName}VO">
<select id="listPaged${entityName}s" resultType="${package}.model.entity.${entityName}">
SELECT
*
FROM

View File

@@ -11,6 +11,7 @@ import java.time.LocalDateTime;
import java.math.BigDecimal;
#end
/**
* $!{tableComment}分页查询对象
*
@@ -23,14 +24,11 @@ import java.math.BigDecimal;
public class ${entityName}Query extends BasePageQuery {
private static final long serialVersionUID = 1L;
#if($fieldConfigs)
#foreach($fieldConfig in ${fieldConfigs})
#if($fieldConfig.showInQuery)
#if("$!fieldConfig.fieldComment" != "")
@Schema(description = "${field.fieldComment}")
#end
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
#end
#foreach($field in ${fields})
#if("$!field.comment" != "")
@Schema(description = "${field.comment}")
#end
private ${field.propertyType} ${field.propertyName};
#end
}

View File

@@ -6,15 +6,15 @@ 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}服务类
* $!{tableComment} 服务类
*
* @author ${author}
* @since ${date}
*/
public interface ${entityName}Service extends IService<${entityName}> {
/**
*$!{tableComment}分页列表
*
@@ -22,6 +22,7 @@ public interface ${entityName}Service extends IService<${entityName}> {
*/
IPage<${entityName}VO> get${entityName}Page(${entityName}Query queryParams);
/**
* 获取$!{tableComment}表单数据
*
@@ -30,6 +31,7 @@ public interface ${entityName}Service extends IService<${entityName}> {
*/
${entityName}Form get${entityName}FormData(Long id);
/**
* 新增$!{tableComment}
*
@@ -47,6 +49,7 @@ public interface ${entityName}Service extends IService<${entityName}> {
*/
boolean update${entityName}(Long id, ${entityName}Form formData);
/**
* 删除$!{tableComment}
*

View File

@@ -28,7 +28,7 @@ import cn.hutool.core.util.StrUtil;
*/
@Service
@RequiredArgsConstructor
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {
public class ${table.serviceImplName} extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {
private final ${entityName}Converter ${lowerFirstEntityName}Converter;
@@ -88,7 +88,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
* 删除$!{tableComment}
*
* @param ids $!{tableComment}ID多个以英文逗号(,)分割
* @return
* @return true|false
*/
@Override
public boolean delete${entityName}s(String ids) {

View File

@@ -14,7 +14,7 @@ import java.math.BigDecimal;
#end
/**
* $!{tableComment}图对象
* $!{tableComment} 图对象
*
* @author ${author}
* @since ${date}
@@ -27,12 +27,11 @@ public class ${entityName}VO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
#if($fieldConfigs)
#foreach($fieldConfig in ${fieldConfigs})
#if("$!fieldConfig.fieldComment" != "")
@Schema(description = "${fieldConfig.fieldComment}")
#end
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
#foreach($field in ${fields})
#if("$!field.comment" != "")
@Schema(description = "${field.comment}")
#end
private ${field.propertyType} ${field.propertyName};
#end
}