Browse Source
- 新增 ShopCoupon 和 ShopUserCoupon 实体类 - 实现优惠券和用户优惠券的 CRUD 操作 - 添加分页查询、批量操作等接口 - 集成权限控制和操作日志记录refactor(shop): 重构Shop模块的实体类和映射文件 - 更新了多个实体类的创建时间和修改时间字段类型,从Date改为LocalDateTime - 优化了部分实体类的属性结构,移除了不必要的字段 - 更新了多个Mapper接口的作者信息 - 为ShopUserRefereeController添加了权限控制注解main
66 changed files with 257 additions and 156 deletions
@ -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)); |
||||
|
} |
@ -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; |
||||
|
} |
Loading…
Reference in new issue