refactor: 更新统计分析接口路径,调整查询参数和返回对象类型
This commit is contained in:
@@ -20,7 +20,7 @@ import java.time.LocalDate;
|
|||||||
*/
|
*/
|
||||||
@Tag(name = "11.统计分析")
|
@Tag(name = "11.统计分析")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/statistics")
|
@RequestMapping("/api/v1/statistics")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class StatisticsController {
|
public class StatisticsController {
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
* ${entityName} $!{businessName}类型定义
|
* ${entityName} $!{businessName}类型定义
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** $!{businessName}分页查询参数 */
|
import type { BaseQueryParams } from "./common";
|
||||||
export interface ${entityName}PageQuery extends PageQuery {
|
|
||||||
|
/** $!{businessName}查询参数 */
|
||||||
|
export interface ${entityName}QueryParams extends BaseQueryParams {
|
||||||
#foreach($fieldConfig in $fieldConfigs)
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
#if($fieldConfig.isShowInQuery)
|
#if($fieldConfig.isShowInQuery)
|
||||||
#if("$!fieldConfig.fieldComment" != "")
|
#if("$!fieldConfig.fieldComment" != "")
|
||||||
@@ -34,8 +36,11 @@ export interface ${entityName}Form {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
/** $!{businessName}分页对象 */
|
/** $!{businessName}详情对象 */
|
||||||
export interface ${entityName}PageVo {
|
export type ${entityName}Detail = ${entityName}Item & ${entityName}Form;
|
||||||
|
|
||||||
|
/** $!{businessName}列表项 */
|
||||||
|
export interface ${entityName}Item {
|
||||||
#foreach($fieldConfig in $fieldConfigs)
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
#if($fieldConfig.isShowInList)
|
#if($fieldConfig.isShowInList)
|
||||||
#if("$!fieldConfig.fieldComment" != "")
|
#if("$!fieldConfig.fieldComment" != "")
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import type { ${entityName}Form, ${entityName}PageQuery, ${entityName}PageVo } from "@/api/types";
|
import type { ${entityName}Form, ${entityName}QueryParams, ${entityName}Item } from "@/types/api";
|
||||||
|
|
||||||
const ${entityUpperSnake}_BASE_URL = "/api/v1/${entityKebab}";
|
const ${entityUpperSnake}_BASE_URL = "/api/v1/${entityKebab}";
|
||||||
|
|
||||||
const ${entityName}API = {
|
const ${entityName}API = {
|
||||||
/** 获取${businessName}分页数据 */
|
/** 获取${businessName}分页数据 */
|
||||||
getPage(queryParams?: ${entityName}PageQuery) {
|
getPage(queryParams?: ${entityName}QueryParams) {
|
||||||
return request<any, PageResult<${entityName}PageVo[]>>({
|
return request<any, PageResult<${entityName}Item>>({
|
||||||
url: `${${entityUpperSnake}_BASE_URL}/page`,
|
url: `${${entityUpperSnake}_BASE_URL}`,
|
||||||
method: "get",
|
method: "get",
|
||||||
params: queryParams,
|
params: queryParams,
|
||||||
});
|
});
|
||||||
@@ -18,7 +18,7 @@ const ${entityName}API = {
|
|||||||
* @param id ${businessName}ID
|
* @param id ${businessName}ID
|
||||||
* @returns ${businessName}表单数据
|
* @returns ${businessName}表单数据
|
||||||
*/
|
*/
|
||||||
getFormData(id: number) {
|
getFormData(id: string) {
|
||||||
return request<any, ${entityName}Form>({
|
return request<any, ${entityName}Form>({
|
||||||
url: `${${entityUpperSnake}_BASE_URL}/${id}/form`,
|
url: `${${entityUpperSnake}_BASE_URL}/${id}/form`,
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class ${entityName}Controller {
|
|||||||
private final ${entityName}Service ${entityLowerCamel}Service;
|
private final ${entityName}Service ${entityLowerCamel}Service;
|
||||||
|
|
||||||
@Operation(summary = "$!{businessName}分页列表")
|
@Operation(summary = "$!{businessName}分页列表")
|
||||||
@GetMapping("/page")
|
@GetMapping
|
||||||
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:query')")
|
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:query')")
|
||||||
public PageResult<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams ) {
|
public PageResult<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams ) {
|
||||||
IPage<${entityName}Vo> result = ${entityLowerCamel}Service.get${entityName}Page(queryParams);
|
IPage<${entityName}Vo> result = ${entityLowerCamel}Service.get${entityName}Page(queryParams);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container h-full flex flex-1 flex-col">
|
<div class="app-container h-full flex flex-1 flex-col">
|
||||||
<!-- 搜索 -->
|
<!-- 搜索 -->
|
||||||
<page-search
|
<PageSearch
|
||||||
ref="searchRef"
|
ref="searchRef"
|
||||||
:search-config="searchConfig"
|
:search-config="searchConfig"
|
||||||
@query-click="handleQueryClick"
|
@query-click="handleQueryClick"
|
||||||
@@ -14,10 +14,10 @@
|
|||||||
</template>
|
</template>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</page-search>
|
</PageSearch>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<page-content
|
<PageContent
|
||||||
ref="contentRef"
|
ref="contentRef"
|
||||||
:content-config="contentConfig"
|
:content-config="contentConfig"
|
||||||
@add-click="handleAddClick"
|
@add-click="handleAddClick"
|
||||||
@@ -34,10 +34,10 @@
|
|||||||
</template>
|
</template>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</page-content>
|
</PageContent>
|
||||||
|
|
||||||
<!-- 新增 -->
|
<!-- 新增 -->
|
||||||
<page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
|
<PageModal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
|
||||||
#foreach($fieldConfig in $fieldConfigs)
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<template #$fieldConfig.fieldName="scope">
|
<template #$fieldConfig.fieldName="scope">
|
||||||
@@ -45,10 +45,10 @@
|
|||||||
</template>
|
</template>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</page-modal>
|
</PageModal>
|
||||||
|
|
||||||
<!-- 编辑 -->
|
<!-- 编辑 -->
|
||||||
<page-modal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick">
|
<PageModal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick">
|
||||||
#foreach($fieldConfig in $fieldConfigs)
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<template #$fieldConfig.fieldName="scope">
|
<template #$fieldConfig.fieldName="scope">
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
</template>
|
</template>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</page-modal>
|
</PageModal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
defineOptions({ name: "$entityName" });
|
defineOptions({ name: "$entityName" });
|
||||||
|
|
||||||
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
||||||
import type { ${entityName}Form, ${entityName}PageQuery } from "@/api/types";
|
import type { ${entityName}Form, ${entityName}QueryParams } from "@/types/api";
|
||||||
import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
|
import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
|
||||||
import usePage from "@/components/CURD/usePage";
|
import usePage from "@/components/CURD/usePage";
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ const searchConfig: ISearchConfig = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 列表配置
|
// 列表配置
|
||||||
const contentConfig: IContentConfig<${entityName}PageQuery> = reactive({
|
const contentConfig: IContentConfig<${entityName}QueryParams> = reactive({
|
||||||
// 权限前缀
|
// 权限前缀
|
||||||
permPrefix: "${moduleName}:${entityKebab}",
|
permPrefix: "${moduleName}:${entityKebab}",
|
||||||
table: {
|
table: {
|
||||||
@@ -151,8 +151,8 @@ const contentConfig: IContentConfig<${entityName}PageQuery> = reactive({
|
|||||||
// 数据解析函数
|
// 数据解析函数
|
||||||
parseData(res: any) {
|
parseData(res: any) {
|
||||||
return {
|
return {
|
||||||
total: res.total,
|
total: res?.page?.total ?? 0,
|
||||||
list: res.list,
|
list: res?.data ?? [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// 分页配置
|
// 分页配置
|
||||||
@@ -358,7 +358,7 @@ const editModalConfig: IModalConfig<${entityName}Form> = reactive({
|
|||||||
const handleOperateClick = (data: IObject) => {
|
const handleOperateClick = (data: IObject) => {
|
||||||
if (data.name === "edit") {
|
if (data.name === "edit") {
|
||||||
handleEditClick(data.row, async () => {
|
handleEditClick(data.row, async () => {
|
||||||
return await ${entityName}API.getFormData(data.row.id);
|
return await ${entityName}API.getFormData(String(data.row.id));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
link
|
link
|
||||||
icon="edit"
|
icon="edit"
|
||||||
@click="handleOpenDialog(scope.row.id)"
|
@click="handleOpenDialog(String(scope.row.id))"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
link
|
link
|
||||||
icon="delete"
|
icon="delete"
|
||||||
@click="handleDelete(scope.row.id)"
|
@click="handleDelete(String(scope.row.id))"
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -274,22 +274,22 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
import ${entityName}API from "@/api/${moduleName}/${entityKebab}";
|
||||||
import type { ${entityName}PageVo, ${entityName}Form, ${entityName}PageQuery } from "@/api/types";
|
import type { ${entityName}Item, ${entityName}Form, ${entityName}QueryParams } from "@/types/api";
|
||||||
|
|
||||||
const queryFormRef = ref();
|
const queryFormRef = ref();
|
||||||
const dataFormRef = ref();
|
const dataFormRef = ref();
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const removeIds = ref<number[]>([]);
|
const removeIds = ref<string[]>([]);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
|
||||||
const queryParams = reactive<${entityName}PageQuery>({
|
const queryParams = reactive<${entityName}QueryParams>({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
// $!{businessName}表格数据
|
// $!{businessName}表格数据
|
||||||
const pageData = ref<${entityName}PageVo[]>([]);
|
const pageData = ref<${entityName}Item[]>([]);
|
||||||
|
|
||||||
// 弹窗
|
// 弹窗
|
||||||
const dialog = reactive({
|
const dialog = reactive({
|
||||||
@@ -315,9 +315,9 @@
|
|||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
${entityName}API.getPage(queryParams)
|
${entityName}API.getPage(queryParams)
|
||||||
.then((data) => {
|
.then((res) => {
|
||||||
pageData.value = data.list;
|
pageData.value = res.data;
|
||||||
total.value = data.total;
|
total.value = res.page?.total ?? 0;
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@@ -333,11 +333,11 @@
|
|||||||
|
|
||||||
/** 行复选框选中记录选中ID集合 */
|
/** 行复选框选中记录选中ID集合 */
|
||||||
function handleSelectionChange(selection: any) {
|
function handleSelectionChange(selection: any) {
|
||||||
removeIds.value = selection.map((item: any) => item.id);
|
removeIds.value = selection.map((item: any) => String(item.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 打开$!{businessName}弹窗 */
|
/** 打开$!{businessName}弹窗 */
|
||||||
function handleOpenDialog(id?: number) {
|
function handleOpenDialog(id?: string) {
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (id) {
|
if (id) {
|
||||||
dialog.title = "修改$!{businessName}";
|
dialog.title = "修改$!{businessName}";
|
||||||
@@ -385,7 +385,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 删除$!{businessName} */
|
/** 删除$!{businessName} */
|
||||||
function handleDelete(id?: number) {
|
function handleDelete(id?: string) {
|
||||||
const ids = [id || removeIds.value].join(",");
|
const ids = [id || removeIds.value].join(",");
|
||||||
if (!ids) {
|
if (!ids) {
|
||||||
ElMessage.warning("请勾选删除项");
|
ElMessage.warning("请勾选删除项");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<mapper namespace="${packageName}.${moduleName}.mapper.${entityName}Mapper">
|
<mapper namespace="${packageName}.${moduleName}.mapper.${entityName}Mapper">
|
||||||
|
|
||||||
<!-- 获取${businessName}分页列表 -->
|
<!-- 获取${businessName}分页列表 -->
|
||||||
<select id="get${entityName}Page" resultType="${packageName}.${moduleName}.model.vo.${entityName}VO">
|
<select id="get${entityName}Page" resultType="${packageName}.${moduleName}.model.vo.${entityName}Vo">
|
||||||
SELECT
|
SELECT
|
||||||
#if($fieldConfigs)
|
#if($fieldConfigs)
|
||||||
#set ($fields = [])
|
#set ($fields = [])
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.math.BigDecimal;
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{businessName}分页查询对象
|
* $!{businessName}查询对象
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams) {
|
public IPage<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams) {
|
||||||
Page<${entityName}Vo> pageVo = this.baseMapper.get${entityName}Page(
|
Page<${entityName}Vo> pageResult = this.baseMapper.get${entityName}Page(
|
||||||
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||||
queryParams
|
queryParams
|
||||||
);
|
);
|
||||||
return pageVo;
|
return pageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user