refactor: 更新统计分析接口路径,调整查询参数和返回对象类型

This commit is contained in:
Ray.Hao
2026-01-09 11:47:12 +08:00
parent f1d8d689b7
commit 1e7d024269
9 changed files with 45 additions and 40 deletions

View File

@@ -20,7 +20,7 @@ import java.time.LocalDate;
*/
@Tag(name = "11.统计分析")
@RestController
@RequestMapping("/statistics")
@RequestMapping("/api/v1/statistics")
@RequiredArgsConstructor
public class StatisticsController {

View File

@@ -2,8 +2,10 @@
* ${entityName} $!{businessName}类型定义
*/
/** $!{businessName}分页查询参数 */
export interface ${entityName}PageQuery extends PageQuery {
import type { BaseQueryParams } from "./common";
/** $!{businessName}查询参数 */
export interface ${entityName}QueryParams extends BaseQueryParams {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInQuery)
#if("$!fieldConfig.fieldComment" != "")
@@ -34,8 +36,11 @@ export interface ${entityName}Form {
#end
}
/** $!{businessName}分页对象 */
export interface ${entityName}PageVo {
/** $!{businessName}详情对象 */
export type ${entityName}Detail = ${entityName}Item & ${entityName}Form;
/** $!{businessName}列表项 */
export interface ${entityName}Item {
#foreach($fieldConfig in $fieldConfigs)
#if($fieldConfig.isShowInList)
#if("$!fieldConfig.fieldComment" != "")

View File

@@ -1,13 +1,13 @@
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 ${entityName}API = {
/** 获取${businessName}分页数据 */
getPage(queryParams?: ${entityName}PageQuery) {
return request<any, PageResult<${entityName}PageVo[]>>({
url: `${${entityUpperSnake}_BASE_URL}/page`,
getPage(queryParams?: ${entityName}QueryParams) {
return request<any, PageResult<${entityName}Item>>({
url: `${${entityUpperSnake}_BASE_URL}`,
method: "get",
params: queryParams,
});
@@ -18,7 +18,7 @@ const ${entityName}API = {
* @param id ${businessName}ID
* @returns ${businessName}表单数据
*/
getFormData(id: number) {
getFormData(id: string) {
return request<any, ${entityName}Form>({
url: `${${entityUpperSnake}_BASE_URL}/${id}/form`,
method: "get",

View File

@@ -33,7 +33,7 @@ public class ${entityName}Controller {
private final ${entityName}Service ${entityLowerCamel}Service;
@Operation(summary = "$!{businessName}分页列表")
@GetMapping("/page")
@GetMapping
@PreAuthorize("@ss.hasPerm('${moduleName}:${entityKebab}:query')")
public PageResult<${entityName}Vo> get${entityName}Page(${entityName}Query queryParams ) {
IPage<${entityName}Vo> result = ${entityLowerCamel}Service.get${entityName}Page(queryParams);

View File

@@ -1,7 +1,7 @@
<template>
<div class="app-container h-full flex flex-1 flex-col">
<!-- 搜索 -->
<page-search
<PageSearch
ref="searchRef"
:search-config="searchConfig"
@query-click="handleQueryClick"
@@ -14,10 +14,10 @@
</template>
#end
#end
</page-search>
</PageSearch>
<!-- 列表 -->
<page-content
<PageContent
ref="contentRef"
:content-config="contentConfig"
@add-click="handleAddClick"
@@ -34,10 +34,10 @@
</template>
#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)
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
<template #$fieldConfig.fieldName="scope">
@@ -45,10 +45,10 @@
</template>
#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)
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
<template #$fieldConfig.fieldName="scope">
@@ -56,7 +56,7 @@
</template>
#end
#end
</page-modal>
</PageModal>
</div>
</template>
@@ -64,7 +64,7 @@
defineOptions({ name: "$entityName" });
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 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}",
table: {
@@ -151,8 +151,8 @@ const contentConfig: IContentConfig<${entityName}PageQuery> = reactive({
// 数据解析函数
parseData(res: any) {
return {
total: res.total,
list: res.list,
total: res?.page?.total ?? 0,
list: res?.data ?? [],
};
},
// 分页配置
@@ -358,7 +358,7 @@ const editModalConfig: IModalConfig<${entityName}Form> = reactive({
const handleOperateClick = (data: IObject) => {
if (data.name === "edit") {
handleEditClick(data.row, async () => {
return await ${entityName}API.getFormData(data.row.id);
return await ${entityName}API.getFormData(String(data.row.id));
});
}
};

View File

@@ -148,7 +148,7 @@
size="small"
link
icon="edit"
@click="handleOpenDialog(scope.row.id)"
@click="handleOpenDialog(String(scope.row.id))"
>
编辑
</el-button>
@@ -158,7 +158,7 @@
size="small"
link
icon="delete"
@click="handleDelete(scope.row.id)"
@click="handleDelete(String(scope.row.id))"
>
删除
</el-button>
@@ -274,22 +274,22 @@
});
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 dataFormRef = ref();
const loading = ref(false);
const removeIds = ref<number[]>([]);
const removeIds = ref<string[]>([]);
const total = ref(0);
const queryParams = reactive<${entityName}PageQuery>({
const queryParams = reactive<${entityName}QueryParams>({
pageNum: 1,
pageSize: 10,
});
// $!{businessName}表格数据
const pageData = ref<${entityName}PageVo[]>([]);
const pageData = ref<${entityName}Item[]>([]);
// 弹窗
const dialog = reactive({
@@ -315,9 +315,9 @@
function handleQuery() {
loading.value = true;
${entityName}API.getPage(queryParams)
.then((data) => {
pageData.value = data.list;
total.value = data.total;
.then((res) => {
pageData.value = res.data;
total.value = res.page?.total ?? 0;
})
.finally(() => {
loading.value = false;
@@ -333,11 +333,11 @@
/** 行复选框选中记录选中ID集合 */
function handleSelectionChange(selection: any) {
removeIds.value = selection.map((item: any) => item.id);
removeIds.value = selection.map((item: any) => String(item.id));
}
/** 打开$!{businessName}弹窗 */
function handleOpenDialog(id?: number) {
function handleOpenDialog(id?: string) {
dialog.visible = true;
if (id) {
dialog.title = "修改$!{businessName}";
@@ -385,7 +385,7 @@
}
/** 删除$!{businessName} */
function handleDelete(id?: number) {
function handleDelete(id?: string) {
const ids = [id || removeIds.value].join(",");
if (!ids) {
ElMessage.warning("请勾选删除项");

View File

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

View File

@@ -13,7 +13,7 @@ import java.math.BigDecimal;
#end
/**
* $!{businessName}分页查询对象
* $!{businessName}查询对象
*
* @author ${author}
* @since ${date}

View File

@@ -40,11 +40,11 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
*/
@Override
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()),
queryParams
);
return pageVo;
return pageResult;
}
/**