feat(shop): 添加优惠券管理和用户优惠券管理功能

- 新增 ShopCoupon 和 ShopUserCoupon 实体类
- 实现优惠券和用户优惠券的 CRUD 操作
- 添加分页查询、批量操作等接口
- 集成权限控制和操作日志记录refactor(shop): 重构Shop模块的实体类和映射文件

- 更新了多个实体类的创建时间和修改时间字段类型,从Date改为LocalDateTime
- 优化了部分实体类的属性结构,移除了不必要的字段
- 更新了多个Mapper接口的作者信息
- 为ShopUserRefereeController添加了权限控制注解
This commit is contained in:
2025-08-11 23:57:23 +08:00
parent 735f9b6f90
commit cce8c76c86
66 changed files with 257 additions and 156 deletions

View File

@@ -200,6 +200,9 @@ public class ShopGenerator {
map.put("authAnnotation", AUTH_ANNOTATION);
map.put("logAnnotation", LOG_ANNOTATION);
map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX);
// 添加项目类型标识,用于模板中的条件判断
map.put("isUniApp", false); // Vue 项目
map.put("isVueAdmin", true); // 后台管理项目
this.setMap(map);
}
};
@@ -228,7 +231,9 @@ public class ShopGenerator {
+ tableInfo.getEntityPath() + "/" + "index.ts";
}
});
focList.add(new FileOutConfig() {
// UniApp 使用专门的模板
String uniappTemplatePath = TEMPLATES_DIR + "/index.ts.uniapp.btl";
focList.add(new FileOutConfig(uniappTemplatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
@@ -246,7 +251,9 @@ public class ShopGenerator {
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
}
});
focList.add(new FileOutConfig(templatePath) {
// UniApp 使用专门的 model 模板
String uniappModelTemplatePath = TEMPLATES_DIR + "/model.ts.uniapp.btl";
focList.add(new FileOutConfig(uniappModelTemplatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE

View File

@@ -1,14 +1,13 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api/index';
import type { ApiResult, PageResult } from '@/api';
import type { ${entity}, ${entity}Param } from './model';
import { MODULES_API_URL } from '@/config/setting';
/**
* 分页查询${table.comment!}
*/
export async function page${entity}(params: ${entity}Param) {
const res = await request.get<ApiResult<PageResult<${entity}>>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}/page',
'/${package.ModuleName}/${controllerMappingHyphen}/page',
{
params
}
@@ -24,7 +23,7 @@ export async function page${entity}(params: ${entity}Param) {
*/
export async function list${entity}(params?: ${entity}Param) {
const res = await request.get<ApiResult<${entity}[]>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}',
'/${package.ModuleName}/${controllerMappingHyphen}',
{
params
}
@@ -40,7 +39,7 @@ export async function list${entity}(params?: ${entity}Param) {
*/
export async function add${entity}(data: ${entity}) {
const res = await request.post<ApiResult<unknown>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}',
'/${package.ModuleName}/${controllerMappingHyphen}',
data
);
if (res.data.code === 0) {
@@ -54,7 +53,7 @@ export async function add${entity}(data: ${entity}) {
*/
export async function update${entity}(data: ${entity}) {
const res = await request.put<ApiResult<unknown>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}',
'/${package.ModuleName}/${controllerMappingHyphen}',
data
);
if (res.data.code === 0) {
@@ -68,7 +67,7 @@ export async function update${entity}(data: ${entity}) {
*/
export async function remove${entity}(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}/' + id
'/${package.ModuleName}/${controllerMappingHyphen}/' + id
);
if (res.data.code === 0) {
return res.data.message;
@@ -81,7 +80,7 @@ export async function remove${entity}(id?: number) {
*/
export async function removeBatch${entity}(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}/batch',
'/${package.ModuleName}/${controllerMappingHyphen}/batch',
{
data
}
@@ -97,7 +96,7 @@ export async function removeBatch${entity}(data: (number | undefined)[]) {
*/
export async function get${entity}(id: number) {
const res = await request.get<ApiResult<${entity}>>(
MODULES_API_URL + '/${package.ModuleName}/${controllerMappingHyphen}/' + id
'/${package.ModuleName}/${controllerMappingHyphen}/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;

View File

@@ -0,0 +1,101 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api/index';
import type { ${entity}, ${entity}Param } from './model';
/**
* 分页查询${table.comment!}
*/
export async function page${entity}(params: ${entity}Param) {
const res = await request.get<ApiResult<PageResult<${entity}>>>(
'/${package.ModuleName}/${controllerMappingHyphen}/page',
params
);
if (res.code === 0) {
return res.data;
}
return Promise.reject(new Error(res.message));
}
/**
* 查询${table.comment!}列表
*/
export async function list${entity}(params?: ${entity}Param) {
const res = await request.get<ApiResult<${entity}[]>>(
'/${package.ModuleName}/${controllerMappingHyphen}',
params
);
if (res.code === 0 && res.data) {
return res.data;
}
return Promise.reject(new Error(res.message));
}
/**
* 添加${table.comment!}
*/
export async function add${entity}(data: ${entity}) {
const res = await request.post<ApiResult<unknown>>(
'/${package.ModuleName}/${controllerMappingHyphen}',
data
);
if (res.code === 0) {
return res.message;
}
return Promise.reject(new Error(res.message));
}
/**
* 修改${table.comment!}
*/
export async function update${entity}(data: ${entity}) {
const res = await request.put<ApiResult<unknown>>(
'/${package.ModuleName}/${controllerMappingHyphen}',
data
);
if (res.code === 0) {
return res.message;
}
return Promise.reject(new Error(res.message));
}
/**
* 删除${table.comment!}
*/
export async function remove${entity}(id?: number) {
const res = await request.del<ApiResult<unknown>>(
'/${package.ModuleName}/${controllerMappingHyphen}/' + id
);
if (res.code === 0) {
return res.message;
}
return Promise.reject(new Error(res.message));
}
/**
* 批量删除${table.comment!}
*/
export async function removeBatch${entity}(data: (number | undefined)[]) {
const res = await request.del<ApiResult<unknown>>(
'/${package.ModuleName}/${controllerMappingHyphen}/batch',
{
data
}
);
if (res.code === 0) {
return res.message;
}
return Promise.reject(new Error(res.message));
}
/**
* 根据id查询${table.comment!}
*/
export async function get${entity}(id: number) {
const res = await request.get<ApiResult<${entity}>>(
'/${package.ModuleName}/${controllerMappingHyphen}/' + id
);
if (res.code === 0 && res.data) {
return res.data;
}
return Promise.reject(new Error(res.message));
}

View File

@@ -1,4 +1,4 @@
import type { PageParam } from '@/api/index';
import type { PageParam } from '@/api';
/**
* ${table.comment!}

View File

@@ -0,0 +1,43 @@
import type { PageParam } from '@/api/index';
/**
* ${table.comment!}
*/
export interface ${entity} {
<% /** -----------BEGIN 字段循环遍历----------- **/ %>
<% for(field in table.fields) { %>
<%
var keyPropertyName;
if(field.keyFlag) {
keyPropertyName = field.propertyName;
}
%>
<% /* 主键 */ %>
<% if(field.keyFlag) { %>
<% /* 普通字段 */ %>
<% } else if(isNotEmpty(field.fill)) { %>
<% if(field.convert){ %>
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
<% }else{ %>
@TableField(fill = FieldFill.${field.fill})
<% } %>
<% } else if(field.convert) { %>
@TableField("${field.annotationColumnName}")
<% } %>
// ${field.comment}
${field.propertyName}?: <% if(field.propertyType == 'Integer') { %>number<% }else{ %>string<% } %>;
<% } %>
<% /** -----------END 字段循环遍历----------- **/ %>
}
/**
* ${table.comment!}搜索条件
*/
export interface ${entity}Param extends PageParam {
<% for(field in table.fields) { %>
<% if(field.keyFlag) { %>
${field.propertyName}?: number;
<% } %>
<% } %>
keywords?: string;
}