fix(codegen): 修复前端模板语法与对齐问题
This commit is contained in:
@@ -4,7 +4,17 @@ import ${packageName}.common.base.BaseQuery;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
#if($fieldConfigs)
|
||||
#set ($hasDateBetween = false)
|
||||
#foreach($fieldConfig in ${fieldConfigs})
|
||||
#if(($fieldConfig.formType.name() == "DATE" || $fieldConfig.formType.name() == "DATE_TIME") && $fieldConfig.queryType.name() == "BETWEEN")
|
||||
#set ($hasDateBetween = true)
|
||||
#end
|
||||
#end
|
||||
#if($hasDateBetween)
|
||||
import java.util.List;
|
||||
#end
|
||||
#end
|
||||
#if(${hasLocalDateTime})
|
||||
import java.time.LocalDateTime;
|
||||
#end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInQuery == 1 && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<template #$fieldConfig.fieldName="scope">
|
||||
<Dict v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||
<DictSelect v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||
</template>
|
||||
#end
|
||||
#end
|
||||
@@ -30,7 +30,7 @@
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInList == 1 && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<template #$fieldConfig.fieldName="scope">
|
||||
<DictLabel v-model="scope.row[scope.prop]" code="$fieldConfig.dictType" />
|
||||
<DictTag v-model="scope.row[scope.prop]" code="$fieldConfig.dictType" />
|
||||
</template>
|
||||
#end
|
||||
#end
|
||||
@@ -41,7 +41,7 @@
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType.name() != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<template #$fieldConfig.fieldName="scope">
|
||||
<Dict v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||
<DictSelect v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||
</template>
|
||||
#end
|
||||
#end
|
||||
@@ -52,7 +52,7 @@
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType.name() != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<template #$fieldConfig.fieldName="scope">
|
||||
<Dict v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||
<DictSelect v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||
</template>
|
||||
#end
|
||||
#end
|
||||
@@ -61,7 +61,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineOptions({ name: "$entityName" });
|
||||
defineOptions({
|
||||
name: "$entityName",
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
||||
import usePage from "@/components/CURD/usePage";
|
||||
@@ -183,7 +186,7 @@ const contentConfig = reactive({
|
||||
{
|
||||
label: "操作",
|
||||
prop: "operation",
|
||||
width: 220,
|
||||
width: 180,
|
||||
templet: "tool",
|
||||
operat: ["edit", "delete"],
|
||||
},
|
||||
|
||||
@@ -1,63 +1,64 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<!-- 搜索 -->
|
||||
<el-card class="page-search" shadow="never">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="auto">
|
||||
<el-form ref="queryFormRef" :model="params" :inline="true">
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInQuery == 1)
|
||||
<el-form-item label="$fieldConfig.fieldComment" prop="$fieldConfig.fieldName">
|
||||
#if($fieldConfig.formType.name() == "INPUT")
|
||||
<el-input
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
placeholder="$fieldConfig.fieldComment"
|
||||
clearable
|
||||
@keyup.enter="handleQuery()"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "SELECT")
|
||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<DictSelect v-model="queryParams.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
<DictSelect v-model="params.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-select v-model="queryParams.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||
<el-select v-model="params.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||
<el-option :key="1" :value="1" label="选项一"/>
|
||||
<el-option :key="2" :value="2" label="选项二"/>
|
||||
</el-select>
|
||||
#end
|
||||
#elseif($fieldConfig.formType.name() == "RADIO")
|
||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<DictSelect v-model="queryParams.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
||||
<DictSelect v-model="params.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-radio-group v-model="queryParams.$fieldConfig.fieldName">
|
||||
<el-radio-group v-model="params.$fieldConfig.fieldName">
|
||||
<el-radio :key="1" :value="1">选项一</el-radio>
|
||||
<el-radio :key="2" :value="2">选项二</el-radio>
|
||||
</el-radio-group>
|
||||
#end
|
||||
#elseif($fieldConfig.formType.name() == "CHECK_BOX")
|
||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<DictSelect v-model="queryParams.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
||||
<DictSelect v-model="params.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-checkbox-group v-model="queryParams.$fieldConfig.fieldName">
|
||||
<el-checkbox-group v-model="params.$fieldConfig.fieldName">
|
||||
<el-checkbox :key="1" :label="1">选项一</el-checkbox>
|
||||
<el-checkbox :key="2" :label="2">选项二</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
#end
|
||||
#elseif($fieldConfig.formType.name() == "INPUT_NUMBER")
|
||||
<el-input-number
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
placeholder="$fieldConfig.fieldComment"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "SWITCH")
|
||||
<el-switch
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "TEXT_AREA")
|
||||
<el-input type="textarea"
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
placeholder="$fieldConfig.fieldComment"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "DATE_TIME")
|
||||
<el-date-picker
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
#if($fieldConfig.queryType.name() == "BETWEEN")
|
||||
type="daterange"
|
||||
range-separator="~"
|
||||
@@ -72,7 +73,7 @@
|
||||
#elseif($fieldConfig.formType.name() == "DATE")
|
||||
<el-date-picker
|
||||
class="!w-[240px]"
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
#if($fieldConfig.queryType.name() == "BETWEEN")
|
||||
type="daterange"
|
||||
range-separator="~"
|
||||
@@ -89,39 +90,51 @@
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="refresh" @click="handleResetQuery">重置</el-button>
|
||||
<el-button type="primary" @click="handleQuery">搜索</el-button>
|
||||
<el-button @click="handleResetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="page-content" shadow="never">
|
||||
<!-- 表格 -->
|
||||
<el-card ref="tableWrapperRef" class="page-content" shadow="never">
|
||||
<div class="page-toolbar">
|
||||
<div class="page-toolbar__left">
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${entityKebab}:create']"
|
||||
type="success"
|
||||
icon="plus"
|
||||
type="primary"
|
||||
@click="handleCreateClick()"
|
||||
>新增</el-button>
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${entityKebab}:delete']"
|
||||
type="danger"
|
||||
:disabled="!hasSelection"
|
||||
icon="delete"
|
||||
@click="handleDelete()"
|
||||
@click="handleBatchDelete()"
|
||||
>删除</el-button>
|
||||
</div>
|
||||
<div class="page-toolbar__right">
|
||||
<el-tooltip content="刷新" placement="top">
|
||||
<el-button class="page-icon-btn" @click="fetchData">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="全屏" placement="top">
|
||||
<el-button class="page-icon-btn" @click="toggleFullscreen">
|
||||
<el-icon><FullScreen /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-table-wrapper">
|
||||
<el-table
|
||||
ref="dataTableRef"
|
||||
v-loading="loading"
|
||||
:data="pageData"
|
||||
class="page-table"
|
||||
:data="list"
|
||||
height="100%"
|
||||
border
|
||||
stripe
|
||||
highlight-current-row
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
@@ -144,14 +157,13 @@
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-table-column fixed="right" label="操作" width="220">
|
||||
<el-table-column fixed="right" label="操作" width="180">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${entityKebab}:update']"
|
||||
type="primary"
|
||||
size="small"
|
||||
link
|
||||
icon="edit"
|
||||
@click="handleEditClick(String(scope.row.id))"
|
||||
>
|
||||
编辑
|
||||
@@ -161,7 +173,6 @@
|
||||
type="danger"
|
||||
size="small"
|
||||
link
|
||||
icon="delete"
|
||||
@click="handleDelete(String(scope.row.id))"
|
||||
>
|
||||
删除
|
||||
@@ -169,23 +180,23 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="page-pagination">
|
||||
<pagination
|
||||
v-if="total > 0"
|
||||
v-model:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="fetchList"
|
||||
v-model:page="params.pageNum"
|
||||
v-model:limit="params.pageSize"
|
||||
class="page-pagination"
|
||||
@pagination="fetchData"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- $!{businessName}表单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="dialog.visible"
|
||||
:title="dialog.title"
|
||||
width="500px"
|
||||
width="600px"
|
||||
@close="closeDialog"
|
||||
>
|
||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="100px">
|
||||
@@ -265,8 +276,8 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSubmit()">确定</el-button>
|
||||
<el-button @click="closeDialog()">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -274,9 +285,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { useFullscreen } from "@vueuse/core";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { useTableSelection } from "@/composables";
|
||||
import { FullScreen, Refresh } from "@element-plus/icons-vue";
|
||||
import { usePageTable, useTableSelection } from "@/composables";
|
||||
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
||||
|
||||
defineOptions({
|
||||
@@ -286,17 +298,22 @@
|
||||
|
||||
const queryFormRef = ref();
|
||||
const dataFormRef = ref();
|
||||
const tableWrapperRef = ref(null);
|
||||
const { toggle: toggleFullscreen } = useFullscreen(tableWrapperRef);
|
||||
|
||||
const loading = ref(false);
|
||||
const total = ref(0);
|
||||
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const initialFormData = reactive({});
|
||||
|
||||
// $!{businessName}表格数据
|
||||
const pageData = ref([]);
|
||||
const { loading, list, total, params, fetchData, handleQuery, handleResetQuery } = usePageTable({
|
||||
initialParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
request: ${entityName}API.getPage,
|
||||
onBeforeReset: () => queryFormRef.value?.resetFields(),
|
||||
});
|
||||
|
||||
const { selectedIds, hasSelection, handleSelectionChange } = useTableSelection();
|
||||
|
||||
const dialog = reactive({
|
||||
title: "",
|
||||
@@ -317,112 +334,114 @@
|
||||
#end
|
||||
});
|
||||
|
||||
const { selectedIds, hasSelection, handleSelectionChange } = useTableSelection();
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await ${entityName}API.getPage(queryParams);
|
||||
pageData.value = data.list;
|
||||
total.value = data.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询$!{businessName} */
|
||||
function handleQuery() {
|
||||
queryParams.pageNum = 1;
|
||||
fetchList();
|
||||
}
|
||||
|
||||
/** 重置$!{businessName}查询 */
|
||||
function handleResetQuery() {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开表单弹窗
|
||||
*/
|
||||
function openDialog() {
|
||||
dialog.visible = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗并重置表单
|
||||
*/
|
||||
function closeDialog() {
|
||||
dialog.visible = false;
|
||||
resetForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置表单
|
||||
*/
|
||||
function resetForm() {
|
||||
dataFormRef.value?.resetFields();
|
||||
dataFormRef.value?.clearValidate();
|
||||
formData.id = undefined;
|
||||
Object.keys(formData).forEach((key) => {
|
||||
delete formData[key];
|
||||
});
|
||||
Object.assign(formData, initialFormData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开新增弹窗
|
||||
*/
|
||||
async function handleCreateClick() {
|
||||
dialog.title = "新增$!{businessName}";
|
||||
openDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑弹窗并回填数据
|
||||
*/
|
||||
async function handleEditClick(id) {
|
||||
dialog.title = "修改$!{businessName}";
|
||||
${entityName}API.getFormData(id).then((data) => {
|
||||
const data = await ${entityName}API.getFormData(id);
|
||||
Object.assign(formData, data);
|
||||
openDialog();
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交$!{businessName}表单 */
|
||||
function handleSubmit() {
|
||||
dataFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
/**
|
||||
* 提交$!{businessName}表单
|
||||
*/
|
||||
async function handleSubmit() {
|
||||
const valid = await dataFormRef.value?.validate().then(
|
||||
() => true,
|
||||
() => false
|
||||
);
|
||||
if (!valid) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const id = formData.id;
|
||||
if (id) {
|
||||
${entityName}API.update(id, formData)
|
||||
.then(() => {
|
||||
await ${entityName}API.update(id, formData);
|
||||
ElMessage.success("修改成功");
|
||||
closeDialog();
|
||||
handleResetQuery();
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
} else {
|
||||
${entityName}API.create(formData)
|
||||
.then(() => {
|
||||
await ${entityName}API.create(formData);
|
||||
ElMessage.success("新增成功");
|
||||
}
|
||||
closeDialog();
|
||||
handleResetQuery();
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除$!{businessName} */
|
||||
function handleDelete(id) {
|
||||
const ids = [id || selectedIds.value].join(",");
|
||||
/**
|
||||
* 批量删除$!{businessName}
|
||||
*/
|
||||
function handleBatchDelete() {
|
||||
handleDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除$!{businessName}
|
||||
*/
|
||||
async function handleDelete(id) {
|
||||
const ids = id || selectedIds.value.join(",");
|
||||
if (!ids) {
|
||||
ElMessage.warning("请勾选删除项");
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
|
||||
try {
|
||||
await ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(
|
||||
() => {
|
||||
});
|
||||
} catch {
|
||||
ElMessage.info("已取消删除");
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
${entityName}API.deleteByIds(ids)
|
||||
.then(() => {
|
||||
try {
|
||||
await ${entityName}API.deleteByIds(ids);
|
||||
ElMessage.success("删除成功");
|
||||
handleResetQuery();
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
},
|
||||
() => {
|
||||
ElMessage.info("已取消删除");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface ${entityName}QueryParams extends BaseQueryParams {
|
||||
|
||||
/** $!{businessName}表单对象 */
|
||||
export interface ${entityName}Form {
|
||||
id?: number;
|
||||
id?: string;
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInForm)
|
||||
#if("$!fieldConfig.fieldComment" != "")
|
||||
|
||||
@@ -7,30 +7,20 @@ const ${entityUpperSnake}_BASE_URL = "/api/v1/${entityKebab}";
|
||||
const ${entityName}API = {
|
||||
/** 获取${businessName}分页数据 */
|
||||
getPage(queryParams?: ${entityName}QueryParams) {
|
||||
return request<any, PageResult<${entityName}Item>>({
|
||||
return request<unknown, PageResult<${entityName}Item>>({
|
||||
url: `${${entityUpperSnake}_BASE_URL}`,
|
||||
method: "get",
|
||||
params: queryParams,
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取${businessName}表单数据
|
||||
*
|
||||
* @param id ${businessName}ID
|
||||
* @returns ${businessName}表单数据
|
||||
*/
|
||||
/** 获取${businessName}表单数据 */
|
||||
getFormData(id: string) {
|
||||
return request<any, ${entityName}Form>({
|
||||
return request<unknown, ${entityName}Form>({
|
||||
url: `${${entityUpperSnake}_BASE_URL}/${id}/form`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 添加${businessName}
|
||||
*
|
||||
* @param data ${businessName}表单数据
|
||||
*/
|
||||
/** 新增${businessName} */
|
||||
create(data: ${entityName}Form) {
|
||||
return request({
|
||||
url: `${${entityUpperSnake}_BASE_URL}`,
|
||||
@@ -38,13 +28,7 @@ const ${entityName}API = {
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新${businessName}
|
||||
*
|
||||
* @param id ${businessName}ID
|
||||
* @param data ${businessName}表单数据
|
||||
*/
|
||||
/** 更新${businessName} */
|
||||
update(id: string, data: ${entityName}Form) {
|
||||
return request({
|
||||
url: `${${entityUpperSnake}_BASE_URL}/${id}`,
|
||||
@@ -52,12 +36,7 @@ const ${entityName}API = {
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量删除${businessName},多个以英文逗号(,)分割
|
||||
*
|
||||
* @param ids ${businessName}ID字符串,多个以英文逗号(,)分割
|
||||
*/
|
||||
/** 批量删除${businessName},多个以英文逗号(,)分割 */
|
||||
deleteByIds(ids: string) {
|
||||
return request({
|
||||
url: `${${entityUpperSnake}_BASE_URL}/${ids}`,
|
||||
|
||||
@@ -61,11 +61,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: "$entityName" });
|
||||
defineOptions({
|
||||
name: "$entityName",
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
||||
import type { ${entityName}Form, ${entityName}QueryParams } from "@/api/${moduleName}/${entityKebab}";
|
||||
import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
|
||||
import type { IObject, IOperateData, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
|
||||
import usePage from "@/components/CURD/usePage";
|
||||
|
||||
// 组合式 CRUD
|
||||
@@ -185,7 +188,7 @@ const contentConfig: IContentConfig<${entityName}QueryParams> = reactive({
|
||||
{
|
||||
label: "操作",
|
||||
prop: "operation",
|
||||
width: 220,
|
||||
width: 180,
|
||||
templet: "tool",
|
||||
operat: ["edit", "delete"],
|
||||
},
|
||||
@@ -355,7 +358,7 @@ const editModalConfig: IModalConfig<${entityName}Form> = reactive({
|
||||
});
|
||||
|
||||
// 处理操作按钮点击
|
||||
const handleOperateClick = (data: IObject) => {
|
||||
const handleOperateClick = (data: IOperateData) => {
|
||||
if (data.name === "edit") {
|
||||
handleEditClick(data.row, async () => {
|
||||
return await ${entityName}API.getFormData(String(data.row.id));
|
||||
|
||||
@@ -1,63 +1,64 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<!-- 搜索 -->
|
||||
<el-card class="page-search" shadow="never">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="auto">
|
||||
<el-form ref="queryFormRef" :model="params" :inline="true">
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInQuery == 1)
|
||||
<el-form-item label="$fieldConfig.fieldComment" prop="$fieldConfig.fieldName">
|
||||
#if($fieldConfig.formType.name() == "INPUT")
|
||||
<el-input
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
placeholder="$fieldConfig.fieldComment"
|
||||
clearable
|
||||
@keyup.enter="handleQuery()"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "SELECT")
|
||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<DictSelect v-model="queryParams.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
<DictSelect v-model="params.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-select v-model="queryParams.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||
<el-select v-model="params.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||
<el-option :key="1" :value="1" label="选项一"/>
|
||||
<el-option :key="2" :value="2" label="选项二"/>
|
||||
</el-select>
|
||||
#end
|
||||
#elseif($fieldConfig.formType.name() == "RADIO")
|
||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<DictSelect v-model="queryParams.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
||||
<DictSelect v-model="params.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-radio-group v-model="queryParams.$fieldConfig.fieldName">
|
||||
<el-radio-group v-model="params.$fieldConfig.fieldName">
|
||||
<el-radio :key="1" :value="1">选项一</el-radio>
|
||||
<el-radio :key="2" :value="2">选项二</el-radio>
|
||||
</el-radio-group>
|
||||
#end
|
||||
#elseif($fieldConfig.formType.name() == "CHECK_BOX")
|
||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||
<DictSelect v-model="queryParams.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
||||
<DictSelect v-model="params.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-checkbox-group v-model="queryParams.$fieldConfig.fieldName">
|
||||
<el-checkbox-group v-model="params.$fieldConfig.fieldName">
|
||||
<el-checkbox :key="1" :label="1">选项一</el-checkbox>
|
||||
<el-checkbox :key="2" :label="2">选项二</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
#end
|
||||
#elseif($fieldConfig.formType.name() == "INPUT_NUMBER")
|
||||
<el-input-number
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
placeholder="$fieldConfig.fieldComment"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "SWITCH")
|
||||
<el-switch
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "TEXT_AREA")
|
||||
<el-input type="textarea"
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
placeholder="$fieldConfig.fieldComment"
|
||||
/>
|
||||
#elseif($fieldConfig.formType.name() == "DATE_TIME")
|
||||
<el-date-picker
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
#if($fieldConfig.queryType.name() == "BETWEEN")
|
||||
type="daterange"
|
||||
range-separator="~"
|
||||
@@ -72,7 +73,7 @@
|
||||
#elseif($fieldConfig.formType.name() == "DATE")
|
||||
<el-date-picker
|
||||
class="!w-[240px]"
|
||||
v-model="queryParams.$fieldConfig.fieldName"
|
||||
v-model="params.$fieldConfig.fieldName"
|
||||
#if($fieldConfig.queryType.name() == "BETWEEN")
|
||||
type="daterange"
|
||||
range-separator="~"
|
||||
@@ -89,39 +90,51 @@
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="refresh" @click="handleResetQuery">重置</el-button>
|
||||
<el-button type="primary" @click="handleQuery">搜索</el-button>
|
||||
<el-button @click="handleResetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="page-content" shadow="never">
|
||||
<!-- 表格 -->
|
||||
<el-card ref="tableWrapperRef" class="page-content" shadow="never">
|
||||
<div class="page-toolbar">
|
||||
<div class="page-toolbar__left">
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${entityKebab}:create']"
|
||||
type="success"
|
||||
icon="plus"
|
||||
type="primary"
|
||||
@click="handleCreateClick()"
|
||||
>新增</el-button>
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${entityKebab}:delete']"
|
||||
type="danger"
|
||||
:disabled="!hasSelection"
|
||||
icon="delete"
|
||||
@click="handleDelete()"
|
||||
@click="handleBatchDelete()"
|
||||
>删除</el-button>
|
||||
</div>
|
||||
<div class="page-toolbar__right">
|
||||
<el-tooltip content="刷新" placement="top">
|
||||
<el-button class="page-icon-btn" @click="fetchData">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="全屏" placement="top">
|
||||
<el-button class="page-icon-btn" @click="toggleFullscreen">
|
||||
<el-icon><FullScreen /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-table-wrapper">
|
||||
<el-table
|
||||
ref="dataTableRef"
|
||||
v-loading="loading"
|
||||
:data="pageData"
|
||||
class="page-table"
|
||||
:data="list"
|
||||
height="100%"
|
||||
border
|
||||
stripe
|
||||
highlight-current-row
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
@@ -144,14 +157,13 @@
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-table-column fixed="right" label="操作" width="220">
|
||||
<el-table-column fixed="right" label="操作" width="180">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${entityKebab}:update']"
|
||||
type="primary"
|
||||
size="small"
|
||||
link
|
||||
icon="edit"
|
||||
@click="handleEditClick(String(scope.row.id))"
|
||||
>
|
||||
编辑
|
||||
@@ -161,7 +173,6 @@
|
||||
type="danger"
|
||||
size="small"
|
||||
link
|
||||
icon="delete"
|
||||
@click="handleDelete(String(scope.row.id))"
|
||||
>
|
||||
删除
|
||||
@@ -169,23 +180,23 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="page-pagination">
|
||||
<pagination
|
||||
v-if="total > 0"
|
||||
v-model:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="fetchList"
|
||||
v-model:page="params.pageNum"
|
||||
v-model:limit="params.pageSize"
|
||||
class="page-pagination"
|
||||
@pagination="fetchData"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- $!{businessName}表单弹窗 -->
|
||||
<!-- 表单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="dialog.visible"
|
||||
:title="dialog.title"
|
||||
width="500px"
|
||||
width="600px"
|
||||
@close="closeDialog"
|
||||
>
|
||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="100px">
|
||||
@@ -265,8 +276,8 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSubmit()">确定</el-button>
|
||||
<el-button @click="closeDialog()">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -274,9 +285,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from "element-plus";
|
||||
import { useTableSelection } from "@/composables";
|
||||
import { useFullscreen } from "@vueuse/core";
|
||||
import {
|
||||
ElMessage,
|
||||
ElMessageBox,
|
||||
type FormInstance,
|
||||
type FormRules,
|
||||
} from "element-plus";
|
||||
import { FullScreen, Refresh } from "@element-plus/icons-vue";
|
||||
import { usePageTable, useTableSelection } from "@/composables";
|
||||
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
||||
import type { ${entityName}Item, ${entityName}Form, ${entityName}QueryParams } from "@/api/${moduleName}/${entityKebab}";
|
||||
|
||||
@@ -287,17 +304,26 @@
|
||||
|
||||
const queryFormRef = ref<FormInstance>();
|
||||
const dataFormRef = ref<FormInstance>();
|
||||
const tableWrapperRef = ref<HTMLElement | null>(null);
|
||||
const { toggle: toggleFullscreen } = useFullscreen(tableWrapperRef);
|
||||
|
||||
const loading = ref(false);
|
||||
const total = ref(0);
|
||||
|
||||
const queryParams = reactive<${entityName}QueryParams>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
} as ${entityName}QueryParams);
|
||||
const initialFormData = reactive({} as ${entityName}Form);
|
||||
Object.assign(initialFormData, {} as ${entityName}Form);
|
||||
|
||||
// $!{businessName}表格数据
|
||||
const pageData = ref<${entityName}Item[]>([]);
|
||||
const { loading, list, total, params, fetchData, handleQuery, handleResetQuery } = usePageTable<
|
||||
${entityName}Item,
|
||||
${entityName}QueryParams
|
||||
>({
|
||||
initialParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
} as ${entityName}QueryParams,
|
||||
request: ${entityName}API.getPage,
|
||||
onBeforeReset: () => queryFormRef.value?.resetFields(),
|
||||
});
|
||||
|
||||
const { selectedIds, hasSelection, handleSelectionChange } = useTableSelection<${entityName}Item>();
|
||||
|
||||
// 弹窗
|
||||
const dialog = reactive({
|
||||
@@ -319,112 +345,114 @@
|
||||
#end
|
||||
};
|
||||
|
||||
const { selectedIds, hasSelection, handleSelectionChange } = useTableSelection<${entityName}Item>();
|
||||
|
||||
async function fetchList(): Promise<void> {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await ${entityName}API.getPage(queryParams);
|
||||
pageData.value = data.list;
|
||||
total.value = data.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询$!{businessName} */
|
||||
function handleQuery(): void {
|
||||
queryParams.pageNum = 1;
|
||||
fetchList();
|
||||
}
|
||||
|
||||
/** 重置$!{businessName}查询 */
|
||||
function handleResetQuery() {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开表单弹窗
|
||||
*/
|
||||
function openDialog(): void {
|
||||
dialog.visible = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗并重置表单
|
||||
*/
|
||||
function closeDialog(): void {
|
||||
dialog.visible = false;
|
||||
resetForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置表单
|
||||
*/
|
||||
function resetForm(): void {
|
||||
dataFormRef.value?.resetFields();
|
||||
dataFormRef.value?.clearValidate();
|
||||
formData.id = undefined;
|
||||
Object.keys(formData).forEach((key) => {
|
||||
delete (formData as Record<string, unknown>)[key];
|
||||
});
|
||||
Object.assign(formData, initialFormData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开新增弹窗
|
||||
*/
|
||||
async function handleCreateClick(): Promise<void> {
|
||||
dialog.title = "新增$!{businessName}";
|
||||
openDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑弹窗并回填数据
|
||||
*/
|
||||
async function handleEditClick(id: string): Promise<void> {
|
||||
dialog.title = "修改$!{businessName}";
|
||||
${entityName}API.getFormData(id).then((data) => {
|
||||
const data = await ${entityName}API.getFormData(id);
|
||||
Object.assign(formData, data);
|
||||
openDialog();
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交$!{businessName}表单 */
|
||||
function handleSubmit() {
|
||||
dataFormRef.value?.validate((valid: any) => {
|
||||
if (valid) {
|
||||
/**
|
||||
* 提交$!{businessName}表单
|
||||
*/
|
||||
async function handleSubmit(): Promise<void> {
|
||||
const valid = await dataFormRef.value?.validate().then(
|
||||
() => true,
|
||||
() => false
|
||||
);
|
||||
if (!valid) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const id = formData.id;
|
||||
if (id) {
|
||||
${entityName}API.update(id, formData)
|
||||
.then(() => {
|
||||
await ${entityName}API.update(id, formData);
|
||||
ElMessage.success("修改成功");
|
||||
closeDialog();
|
||||
handleResetQuery();
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
} else {
|
||||
${entityName}API.create(formData)
|
||||
.then(() => {
|
||||
await ${entityName}API.create(formData);
|
||||
ElMessage.success("新增成功");
|
||||
}
|
||||
closeDialog();
|
||||
handleResetQuery();
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除$!{businessName} */
|
||||
function handleDelete(id?: string) {
|
||||
const ids = [id || selectedIds.value].join(",");
|
||||
/**
|
||||
* 批量删除$!{businessName}
|
||||
*/
|
||||
function handleBatchDelete(): void {
|
||||
handleDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除$!{businessName}
|
||||
*/
|
||||
async function handleDelete(id?: string): Promise<void> {
|
||||
const ids = id || selectedIds.value.join(",");
|
||||
if (!ids) {
|
||||
ElMessage.warning("请勾选删除项");
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
|
||||
try {
|
||||
await ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(
|
||||
() => {
|
||||
});
|
||||
} catch {
|
||||
ElMessage.info("已取消删除");
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
${entityName}API.deleteByIds(ids)
|
||||
.then(() => {
|
||||
try {
|
||||
await ${entityName}API.deleteByIds(ids);
|
||||
ElMessage.success("删除成功");
|
||||
handleResetQuery();
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
},
|
||||
() => {
|
||||
ElMessage.info("已取消删除");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -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 toForm(${entity} entity);
|
||||
|
||||
@InheritInverseConfiguration(name = "toForm")
|
||||
${entity} toEntity(${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.toForm(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增$!{table.comment}
|
||||
*
|
||||
* @param formData $!{table.comment}表单对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean save${entity}(${entity}Form formData) {
|
||||
// 实体转换 form->entity
|
||||
${entity} entity = ${firstCharLowerCaseEntity}Converter.toEntity(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.toEntity(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