项目模块初步完成

This commit is contained in:
chen-xin-zhi 2025-05-06 16:38:42 +08:00
parent 5038cebbfa
commit 2eb5ee1207
21 changed files with 1026 additions and 132 deletions

View File

@ -170,6 +170,10 @@ public class OperateLogAspect {
for (Object o : paramsArray) {
if (o != null) {
try {
// 排除掉 RequestFacade 类型的对象
if (o instanceof org.apache.catalina.connector.RequestFacade) {
continue; // 跳过该对象
}
Object jsonObj = JSON.toJSON(o);
params += jsonObj.toString() + " ";
} catch (Exception e) {

View File

@ -0,0 +1,146 @@
package com.greenorange.promotion.controller.project;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.project.ProjectAddRequest;
import com.greenorange.promotion.model.dto.project.ProjectQueryRequest;
import com.greenorange.promotion.model.dto.project.ProjectUpdateRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.vo.project.ProjectVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.project.ProjectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.model.dto.CommonRequest;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 项目 控制器
*/
@RestController
@RequestMapping("project")
@Slf4j
@Tag(name = "项目管理")
public class ProjectController {
@Resource
private ProjectService projectService;
@Resource
private CommonService commonService;
/**
* web端管理员添加项目
* @param projectAddRequest 项目添加请求体
* @return 是否添加成功
*/
@PostMapping("add")
@Operation(summary = "web端管理员添加项目", description = "参数项目添加请求体权限管理员方法名addProject")
public BaseResponse<Boolean> addProject(@Valid @RequestBody ProjectAddRequest projectAddRequest) {
Project project = commonService.copyProperties(projectAddRequest, Project.class);
projectService.save(project);
return ResultUtils.success(true);
}
/**
* web端管理员根据id修改项目信息
* @param projectUpdateRequest 项目更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员更新项目", description = "参数项目更新请求体权限管理员方法名updateProject")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目管理", content = "web端管理员根据id修改项目信息")
public BaseResponse<Boolean> updateProject(@Valid @RequestBody ProjectUpdateRequest projectUpdateRequest) {
Project project = commonService.copyProperties(projectUpdateRequest, Project.class);
projectService.updateById(project);
return ResultUtils.success(true);
}
/**
* web端管理员根据id删除项目
* @param commonRequest 项目删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员根据id删除项目", description = "参数项目删除请求体权限管理员方法名delProject")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目管理", content = "web端管理员根据id删除项目")
public BaseResponse<Boolean> delProject(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
projectService.removeById(id);
return ResultUtils.success(true);
}
/**
* web端管理员批量删除项目
* @param commonBatchRequest 项目批量删除请求体
* @return 是否删除成功
*/
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除项目", description = "参数项目批量删除请求体权限管理员方法名delBatchProject")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目管理", content = "web端管理员批量删除项目")
public BaseResponse<Boolean> delBatchProject(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
projectService.removeByIds(ids);
return ResultUtils.success(true);
}
/**
* web端管理员根据id查询项目
* @param commonRequest 项目查询请求体
* @return 项目信息
*/
@PostMapping("queryById")
@Operation(summary = "web端管理员根据id查询项目", description = "参数项目查询请求体权限管理员方法名queryProjectById")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目管理", content = "web端管理员根据id查询项目")
public BaseResponse<ProjectVO> queryProjectById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
Project project = projectService.getById(id);
ThrowUtils.throwIf(project == null, ErrorCode.OPERATION_ERROR, "当前项目不存在");
ProjectVO projectVO = commonService.copyProperties(project, ProjectVO.class);
return ResultUtils.success(projectVO);
}
/**
* Web端管理员分页查询项目
* @param projectQueryRequest 项目查询请求体
* @return 项目列表
*/
@PostMapping("page")
@Operation(summary = "Web端管理员分页查询项目", description = "参数项目查询请求体权限管理员方法名listProjectByPage")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目管理", content = "Web端管理员分页查询项目")
public BaseResponse<Page<ProjectVO>> listProjectByPage(@Valid @RequestBody ProjectQueryRequest projectQueryRequest) {
long current = projectQueryRequest.getCurrent();
long pageSize = projectQueryRequest.getPageSize();
QueryWrapper<Project> queryWrapper = projectService.getQueryWrapper(projectQueryRequest);
Page<Project> page = projectService.page(new Page<>(current, pageSize), queryWrapper);
List<Project> projectList = page.getRecords();
List<ProjectVO> projectVOList = commonService.convertList(projectList, ProjectVO.class);
Page<ProjectVO> voPage = new Page<>(current, pageSize);
voPage.setRecords(projectVOList);
voPage.setPages(page.getPages());
voPage.setTotal(page.getTotal());
return ResultUtils.success(voPage);
}
}

View File

@ -68,6 +68,7 @@ public class UserInfoController {
*/
@PostMapping("login")
@Operation(summary = "web端管理员登录", description = "参数用户登录请求体权限管理员boss, admin)方法名userInfoLogin")
@SysLog(title = "用户管理", content = "web端管理员登录")
public BaseResponse<String> userInfoLogin(@Valid @RequestBody UserInfoLoginRequest userInfoLoginRequest, HttpServletRequest request) {
String userAccount = userInfoLoginRequest.getUserAccount();
String userPassword = userInfoLoginRequest.getUserPassword();
@ -84,6 +85,7 @@ public class UserInfoController {
@PostMapping("logout")
@Operation(summary = "web端管理员退出登录", description = "参数JWT权限管理员boss, admin)方法名userInfoLogout")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户管理", content = "web端管理员退出登录")
public BaseResponse<Boolean> userInfoLogout(@RequestHeader("Authorization") String token) {
// 获取token的过期时间
DecodedJWT decodedJWT = jwtUtils.verify(token);
@ -112,12 +114,14 @@ public class UserInfoController {
/**
* web端管理员更新用户表
* web端管理员根据id修改用户信息
* @param userInfoUpdateRequest 用户表更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员更新用户", description = "参数用户表更新请求体权限管理员boss, admin)方法名updateUserInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户管理", content = "web端管理员根据id修改用户信息")
public BaseResponse<Boolean> updateUserInfo(@Valid @RequestBody UserInfoUpdateRequest userInfoUpdateRequest) {
UserInfo userInfo = commonService.copyProperties(userInfoUpdateRequest, UserInfo.class);
userInfoService.updateById(userInfo);
@ -126,12 +130,14 @@ public class UserInfoController {
/**
* web端管理员删除用户
* web端管理员根据id删除用户
* @param commonRequest 用户表删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员删除用户", description = "参数用户表删除请求体权限管理员boss, admin)方法名delUserInfo")
@Operation(summary = "web端管理员根据id删除用户", description = "参数用户表删除请求体权限管理员boss, admin)方法名delUserInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户管理", content = "web端管理员根据id删除用户表")
public BaseResponse<Boolean> delUserInfo(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
userInfoService.removeById(id);
@ -139,30 +145,27 @@ public class UserInfoController {
}
/**
* Web端管理员分页查看用户表
* @param userInfoQueryRequest 用户表查询请求体
* @return 用户表列表
* web端管理员批量删除用户
* @param commonBatchRequest 用户表批量删除请求体
* @return 是否删除成功
*/
@PostMapping("page")
@Operation(summary = "Web端管理员分页查看用户", description = "参数用户表查询请求体权限管理员boss, admin),方法名:listUserInfoByPage")
public BaseResponse<Page<UserInfoVO>> listUserInfoByPage(@Valid @RequestBody UserInfoQueryRequest userInfoQueryRequest) {
long current = userInfoQueryRequest.getCurrent();
long pageSize = userInfoQueryRequest.getPageSize();
QueryWrapper<UserInfo> queryWrapper = userInfoService.getQueryWrapper(userInfoQueryRequest);
Page<UserInfo> page = userInfoService.page(new Page<>(current, pageSize), queryWrapper);
List<UserInfo> userInfoList = page.getRecords();
List<UserInfoVO> userInfoVOList = commonService.convertList(userInfoList, UserInfoVO.class);
Page<UserInfoVO> voPage = new Page<>(current, pageSize);
voPage.setRecords(userInfoVOList);
voPage.setPages(page.getPages());
voPage.setTotal(page.getTotal());
return ResultUtils.success(voPage);
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除用户", description = "参数用户表批量删除请求体权限管理员boss, admin),方法名:delBatchUserInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户管理", content = "web端管理员批量删除用户表")
public BaseResponse<Boolean> delBatchUserInfo(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
userInfoService.removeByIds(ids);
return ResultUtils.success(true);
}
/**
* web端管理员根据id查询用户表
* web端管理员根据id查询用户
* @param commonRequest 用户表查询请求体
* @return 用户表信息
*/
@ -181,18 +184,28 @@ public class UserInfoController {
/**
* web端管理员批量删除用户表
* @param commonBatchRequest 用户表批量删除请求体
* @return 是否删除成功
* Web端管理员分页查询用户
* @param userInfoQueryRequest 用户表查询请求体
* @return 用户表列表
*/
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除用户", description = "参数用户表批量删除请求体权限管理员boss, admin),方法名:delBatchUserInfo")
public BaseResponse<Boolean> delBatchUserInfo(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
userInfoService.removeByIds(ids);
return ResultUtils.success(true);
@PostMapping("page")
@Operation(summary = "Web端管理员分页查询用户", description = "参数用户表查询请求体权限管理员boss, admin),方法名:listUserInfoByPage")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户管理", content = "Web端管理员分页查看用户")
public BaseResponse<Page<UserInfoVO>> listUserInfoByPage(@Valid @RequestBody UserInfoQueryRequest userInfoQueryRequest) {
long current = userInfoQueryRequest.getCurrent();
long pageSize = userInfoQueryRequest.getPageSize();
QueryWrapper<UserInfo> queryWrapper = userInfoService.getQueryWrapper(userInfoQueryRequest);
Page<UserInfo> page = userInfoService.page(new Page<>(current, pageSize), queryWrapper);
List<UserInfo> userInfoList = page.getRecords();
List<UserInfoVO> userInfoVOList = commonService.convertList(userInfoList, UserInfoVO.class);
Page<UserInfoVO> voPage = new Page<>(current, pageSize);
voPage.setRecords(userInfoVOList);
voPage.setPages(page.getPages());
voPage.setTotal(page.getTotal());
return ResultUtils.success(voPage);
}
}

View File

@ -24,12 +24,15 @@ public class Generator {
// 根路径
private static final String ROOT_PATH = "/src/main/java";
// 实体类属性名
private static final String ENTITY_NAME_LOWER = "project";
// 父包名
private static final String PARENT_PATH = "com.greenorange.promotion";
// 子包名
private static final String CONTROLLER_PACKAGE = "controller.user";
private static final String DTO_PACKAGE = "model.dto.user";
private static final String VO_PACKAGE = "model.vo.user";
private static final String CONTROLLER_PACKAGE = "controller." + ENTITY_NAME_LOWER;
private static final String DTO_PACKAGE = "model.dto." + ENTITY_NAME_LOWER;
private static final String VO_PACKAGE = "model.vo." + ENTITY_NAME_LOWER;
// 生成的文件后缀名
private static final String DTO_ADD_REQUEST = "AddRequest.java";
@ -48,11 +51,12 @@ public class Generator {
// 作者
private static final String AUTHOR = "chenxinzhi";
// 表注释
private static final String TABLE_COMMENT = "用户表";
private static final String TABLE_COMMENT = "项目";
// 实体类名
private static final String ENTITY_NAME = "UserInfo";
private static final String ENTITY_NAME = "Project";
// 表名
private static final String TABLE_NAME = "user_info";
private static final String TABLE_NAME = "project";
@ -91,6 +95,7 @@ public class Generator {
.injectionConfig(consumer -> {
Map<String, Object> customMap = new HashMap<>();
customMap.put("entityName", ENTITY_NAME); // 示例值
customMap.put("entityNameLower", ENTITY_NAME_LOWER);
customMap.put("entityComment", TABLE_COMMENT); // 示例值
customMap.put("parentPackage", PARENT_PATH);
customMap.put("controllerPackage", CONTROLLER_PACKAGE);

View File

@ -0,0 +1,18 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.Project;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表project(项目表)的数据库操作Mapper
* @createDate 2025-05-06 14:19:08
* @Entity com.greenorange.promotion.model.entity.Project
*/
public interface ProjectMapper extends BaseMapper<Project> {
}

View File

@ -0,0 +1,138 @@
package com.greenorange.promotion.model.dto.project;
import com.greenorange.promotion.annotation.EnumValue;
import com.greenorange.promotion.model.enums.ProjectStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目添加请求体
*/
@Data
@Schema(description = "项目添加请求体", requiredProperties = {
"projectName",
"projectImage",
"maxProjectPrice",
"minProjectPrice",
"projectDescription",
"settlementDesc",
"projectDesc",
"projectFlow",
"applyPromoCodeDesc",
"projectSettlementCycle",
"currentPromotionCount",
"maxPromoterCount",
"projectStatus",
"isShelves",
})
public class ProjectAddRequest implements Serializable {
/**
* 项目名称
*/
@NotBlank(message = "项目名称不能为空")
@Schema(description = "项目名称", example = "美团省钱包")
private String projectName;
/**
* 项目图片URL
*/
@NotBlank(message = "项目图片URL不能为空")
@Schema(description = "项目图片URL", example = "http://xxx.png")
private String projectImage;
/**
* 项目最高价格
*/
@DecimalMin(value = "0", message = "项目最低价格不能小于0")
@Schema(description = "项目最高价格", example = "30")
private BigDecimal maxProjectPrice;
/**
* 项目最低价格
*/
@DecimalMin(value = "0", message = "项目最低价格不能小于0")
@Schema(description = "项目最低价格", example = "10")
private BigDecimal minProjectPrice;
/**
* 项目简介
*/
@NotBlank(message = "项目简介不能为空")
@Schema(description = "项目简介", example = "不限制推广方式,禁止/恶意/夸大虚假宣传")
private String projectDescription;
/**
* 结算说明富文本
*/
@NotBlank(message = "结算说明(富文本)不能为空")
@Schema(description = "结算说明(富文本)", example = "富文本")
private String settlementDesc;
/**
* 项目说明富文本
*/
@NotBlank(message = "项目说明(富文本)不能为空")
@Schema(description = "项目说明(富文本)", example = "富文本")
private String projectDesc;
/**
* 项目流程富文本
*/
@NotBlank(message = "项目流程(富文本)不能为空")
@Schema(description = "项目流程(富文本)", example = "富文本")
private String projectFlow;
/**
* 申请推广码说明富文本
*/
@NotBlank(message = "申请推广码说明(富文本)不能为空")
@Schema(description = "申请推广码说明(富文本)", example = "富文本")
private String applyPromoCodeDesc;
/**
* 项目结算周期
*/
@Min(value = 1, message = "项目结算周期不能小于1")
@Schema(description = "项目结算周期", example = "2")
private Integer projectSettlementCycle;
/**
* 当前推广人数
*/
@Min(value = 1, message = "当前推广人数不能小于1")
@Schema(description = "当前推广人数", example = "150")
private Integer currentPromotionCount;
/**
* 最大推广人数
*/
@Min(value = 1, message = "当前推广人数不能小于1")
@Schema(description = "最大推广人数", example = "200")
private Integer maxPromoterCount;
/**
* 项目状态项目运行|人数已满|项目暂停
*/
@EnumValue(enumClass = ProjectStatusEnum.class)
@Schema(description = "项目状态", example = "项目运行")
private String projectStatus;
/**
* 是否上架
*/
@Schema(description = "是否上架", example = "true")
private Boolean isShelves;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,39 @@
package com.greenorange.promotion.model.dto.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import com.greenorange.promotion.common.PageRequest;
/**
* 项目查询请求体继承自分页请求 PageRequest
*/
@Data
@Schema(description = "项目查询请求体", requiredProperties = {"current", "pageSize"})
public class ProjectQueryRequest extends PageRequest implements Serializable {
/**
* 项目 ID
*/
@Schema(description = "项目 ID", example = "1")
@Min(value = 1L, message = "项目 ID不能小于1")
private Long id;
/**
* 项目名称
*/
@NotBlank(message = "项目名称不能为空")
@Schema(description = "项目名称", example = "美团省钱包")
private String projectName;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,143 @@
package com.greenorange.promotion.model.dto.project;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目更新请求体
*/
@Data
@Schema(description = "项目更新请求体", requiredProperties = {
"id",
"projectName",
"projectImage",
"maxProjectPrice",
"minProjectPrice",
"projectDescription",
"settlementDesc",
"projectDesc",
"projectFlow",
"applyPromoCodeDesc",
"projectSettlementCycle",
"currentPromotionCount",
"maxPromoterCount",
"projectStatus",
"isShelves",
})
public class ProjectUpdateRequest implements Serializable {
/**
* 项目ID
*/
@Min(value = 1L, message = "项目 ID不能小于1")
@TableId(type = IdType.AUTO)
@Schema(description = "项目ID", example = "美团省钱包")
private Long id;
/**
* 项目名称
*/
@NotBlank(message = "项目名称不能为空")
@Schema(description = "项目名称", example = "美团省钱包")
private String projectName;
/**
* 项目图片URL
*/
@NotBlank(message = "项目图片URL不能为空")
@Schema(description = "项目图片URL", example = "http://xxx.png")
private String projectImage;
/**
* 项目最高价格
*/
@DecimalMin(value = "0", message = "项目最低价格不能小于0")
@Schema(description = "项目最高价格", example = "30")
private BigDecimal maxProjectPrice;
/**
* 项目最低价格
*/
@DecimalMin(value = "0", message = "项目最低价格不能小于0")
@Schema(description = "项目最低价格", example = "10")
private BigDecimal minProjectPrice;
/**
* 项目简介
*/
@NotBlank(message = "项目简介不能为空")
@Schema(description = "项目简介", example = "不限制推广方式,禁止/恶意/夸大虚假宣传")
private String projectDescription;
/**
* 结算说明富文本
*/
@NotBlank(message = "结算说明(富文本)不能为空")
@Schema(description = "结算说明(富文本)", example = "富文本")
private String settlementDesc;
/**
* 项目说明富文本
*/
@NotBlank(message = "项目说明(富文本)不能为空")
@Schema(description = "项目说明(富文本)", example = "富文本")
private String projectDesc;
/**
* 项目流程富文本
*/
@NotBlank(message = "项目流程(富文本)不能为空")
@Schema(description = "项目流程(富文本)", example = "富文本")
private String projectFlow;
/**
* 申请推广码说明富文本
*/
@NotBlank(message = "申请推广码说明(富文本)不能为空")
@Schema(description = "申请推广码说明(富文本)", example = "富文本")
private String applyPromoCodeDesc;
/**
* 项目结算周期
*/
@Schema(description = "项目结算周期", example = "2")
private Integer projectSettlementCycle;
/**
* 当前推广人数
*/
@Schema(description = "当前推广人数", example = "150")
private Integer currentPromotionCount;
/**
* 最大推广人数
*/
@Schema(description = "最大推广人数", example = "200")
private Integer maxPromoterCount;
/**
* 项目状态项目运行|人数已满|项目暂停
*/
@NotBlank(message = "项目状态不能为空")
@Schema(description = "项目状态", example = "项目运行")
private String projectStatus;
/**
* 是否上架
*/
@Schema(description = "是否上架", example = "true")
private Boolean isShelves;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -66,7 +66,7 @@ public class UserInfoAddRequest implements Serializable {
* 用户角色
*/
@EnumValue(enumClass = UserRoleEnum.class)
@Schema(description = "用户角色", example = "USER")
@Schema(description = "用户角色", example = "user")
private String userRole;
/**

View File

@ -0,0 +1,112 @@
package com.greenorange.promotion.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 项目表
* @TableName project
*/
@TableName(value ="project")
@Data
public class Project implements Serializable {
/**
* 项目ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 项目名称
*/
private String projectName;
/**
* 项目图片URL
*/
private String projectImage;
/**
* 项目最高价格
*/
private BigDecimal maxProjectPrice;
/**
* 项目最低价格
*/
private BigDecimal minProjectPrice;
/**
* 项目简介
*/
private String projectDescription;
/**
* 结算说明富文本
*/
private String settlementDesc;
/**
* 项目说明富文本
*/
private String projectDesc;
/**
* 项目流程富文本
*/
private String projectFlow;
/**
* 申请推广码说明富文本
*/
private String applyPromoCodeDesc;
/**
* 项目结算周期
*/
private Integer projectSettlementCycle;
/**
* 当前推广人数
*/
private Integer currentPromotionCount;
/**
* 最大推广人数
*/
private Integer maxPromoterCount;
/**
* 项目状态项目运行|人数已满|项目暂停
*/
private String projectStatus;
/**
* 是否上架
*/
private Integer isShelves;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,48 @@
package com.greenorange.promotion.model.enums;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Getter
public enum ProjectStatusEnum {
RUNNING("项目运行", "running"),
FULL("人数已满", "full"),
PAUSED("项目暂停", "paused");
private final String text;
private final String value;
ProjectStatusEnum(String text, String value) {
this.text = text;
this.value = value;
}
/**
* 获取值列表
*/
public static List<String> getValues() {
return Arrays.stream(values())
.map(item -> item.value)
.collect(Collectors.toList());
}
/**
* 根据值获取枚举
*/
public static ProjectStatusEnum getEnumByValue(String value) {
if (StringUtils.isBlank(value)) {
return null;
}
for (ProjectStatusEnum status : ProjectStatusEnum.values()) {
if (status.value.equals(value)) {
return status;
}
}
return null;
}
}

View File

@ -2,7 +2,7 @@ package com.greenorange.promotion.model.enums;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.List;

View File

@ -0,0 +1,110 @@
package com.greenorange.promotion.model.vo.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目 视图对象
*/
@Data
@Schema(description = "项目 视图对象")
public class ProjectVO implements Serializable {
/**
* 项目 ID
*/
@Schema(description = "项目 ID", example = "1")
private Long id;
/**
* 项目名称
*/
@Schema(description = "项目名称", example = "美团省钱包")
private String projectName;
/**
* 项目图片URL
*/
@Schema(description = "项目图片URL", example = "http://xxx.png")
private String projectImage;
/**
* 项目最高价格
*/
@Schema(description = "项目最高价格", example = "30")
private BigDecimal maxProjectPrice;
/**
* 项目最低价格
*/
@Schema(description = "项目最低价格", example = "10")
private BigDecimal minProjectPrice;
/**
* 项目简介
*/
@Schema(description = "项目简介", example = "不限制推广方式,禁止/恶意/夸大虚假宣传")
private String projectDescription;
/**
* 结算说明富文本
*/
@Schema(description = "结算说明(富文本)", example = "富文本")
private String settlementDesc;
/**
* 项目说明富文本
*/
@Schema(description = "项目说明(富文本)", example = "富文本")
private String projectDesc;
/**
* 项目流程富文本
*/
@Schema(description = "项目流程(富文本)", example = "富文本")
private String projectFlow;
/**
* 申请推广码说明富文本
*/
@Schema(description = "申请推广码说明(富文本)", example = "富文本")
private String applyPromoCodeDesc;
/**
* 项目结算周期
*/
@Schema(description = "项目结算周期", example = "2")
private Integer projectSettlementCycle;
/**
* 当前推广人数
*/
@Schema(description = "当前推广人数", example = "150")
private Integer currentPromotionCount;
/**
* 最大推广人数
*/
@Schema(description = "最大推广人数", example = "200")
private Integer maxPromoterCount;
/**
* 项目状态项目运行|人数已满|项目暂停
*/
@Schema(description = "项目状态", example = "项目运行")
private String projectStatus;
/**
* 是否上架
*/
@Schema(description = "是否上架", example = "true")
private Boolean isShelves;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,20 @@
package com.greenorange.promotion.service.project;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.model.dto.project.ProjectQueryRequest;
import com.greenorange.promotion.model.entity.Project;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表project(项目表)的数据库操作Service
* @createDate 2025-05-06 14:19:08
*/
public interface ProjectService extends IService<Project> {
/**
* 获取查询条件
*/
QueryWrapper<Project> getQueryWrapper(ProjectQueryRequest projectQueryRequest);
}

View File

@ -0,0 +1,43 @@
package com.greenorange.promotion.service.project.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.constant.CommonConstant;
import com.greenorange.promotion.model.dto.project.ProjectQueryRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.entity.UserInfo;
import com.greenorange.promotion.service.project.ProjectService;
import com.greenorange.promotion.mapper.ProjectMapper;
import com.greenorange.promotion.utils.SqlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表project(项目表)的数据库操作Service实现
* @createDate 2025-05-06 14:19:08
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
implements ProjectService{
/**
* 获取查询条件
*/
@Override
public QueryWrapper<Project> getQueryWrapper(ProjectQueryRequest projectQueryRequest) {
Long id = projectQueryRequest.getId();
String projectName = projectQueryRequest.getProjectName();
String sortField = projectQueryRequest.getSortField();
String sortOrder = projectQueryRequest.getSortOrder();
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(id != null, "id", id);
queryWrapper.eq(StringUtils.isNotBlank(projectName), "projectName", projectName);
queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
return queryWrapper;
}
}

View File

@ -0,0 +1,36 @@
<?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="com.greenorange.promotion.mapper.ProjectMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.Project">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="projectName" column="projectName" jdbcType="VARCHAR"/>
<result property="projectImage" column="projectImage" jdbcType="VARCHAR"/>
<result property="maxProjectPrice" column="maxProjectPrice" jdbcType="DECIMAL"/>
<result property="minProjectPrice" column="minProjectPrice" jdbcType="DECIMAL"/>
<result property="projectDescription" column="projectDescription" jdbcType="VARCHAR"/>
<result property="settlementDesc" column="settlementDesc" jdbcType="VARCHAR"/>
<result property="projectDesc" column="projectDesc" jdbcType="VARCHAR"/>
<result property="projectFlow" column="projectFlow" jdbcType="VARCHAR"/>
<result property="applyPromoCodeDesc" column="applyPromoCodeDesc" jdbcType="VARCHAR"/>
<result property="projectSettlementCycle" column="projectSettlementCycle" jdbcType="INTEGER"/>
<result property="currentPromotionCount" column="currentPromotionCount" jdbcType="INTEGER"/>
<result property="maxPromoterCount" column="maxPromoterCount" jdbcType="INTEGER"/>
<result property="projectStatus" column="projectStatus" jdbcType="OTHER"/>
<result property="isShelves" column="isShelves" jdbcType="TINYINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,projectName,projectImage,
maxProjectPrice,minProjectPrice,projectDescription,
settlementDesc,projectDesc,projectFlow,
applyPromoCodeDesc,projectSettlementCycle,currentPromotionCount,
maxPromoterCount,projectStatus,isShelves,
isDelete,createTime,updateTime
</sql>
</mapper>

View File

@ -1,100 +1,82 @@
package ${parentPackage}.${controllerPackage};
import java.util.List;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.model.dto.CommonRequest;
import jakarta.validation.Valid;
/**
* ${entityComment} 控制器
*/
@RestController
@RequestMapping("${entityName}")
@RequestMapping("${tableName}")
@Slf4j
@Tag(name = "${entityComment}管理")
public class ${entityName}Controller {
@Resource
private ${entityName}Service ${entityName}Service;
private ${entityName}Service ${entityNameLower}Service;
@Resource
private CommonService commonService;
/**
* web端管理员添加${entityComment}
* @param ${entityName}AddRequest ${entityComment}添加请求体
* @param ${entityNameLower}AddRequest ${entityComment}添加请求体
* @return 是否添加成功
*/
@PostMapping("add")
@Operation(summary = "web端管理员添加${entityComment}", description = "参数:${entityComment}添加请求体权限管理员boss, admin)方法名add${entityName}")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> add${entityName}(@RequestBody ${entityName}AddRequest ${entityName}AddRequest) {
if (${entityName}AddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
${entityName} ${entityName} = new ${entityName}();
BeanUtils.copyProperties(${entityName}AddRequest, ${entityName});
boolean result = ${entityName}Service.save(${entityName});
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}添加失败");
@Operation(summary = "web端管理员添加${entityComment}", description = "参数:${entityComment}添加请求体权限管理员方法名add${entityName}")
public BaseResponse<Boolean> add${entityName}(@Valid @RequestBody ${entityName}AddRequest ${entityNameLower}AddRequest) {
${entityName} ${entityNameLower} = commonService.copyProperties(${entityNameLower}AddRequest, ${entityName}.class);
${entityNameLower}Service.save(${entityNameLower});
return ResultUtils.success(true);
}
/**
* web端管理员更新${entityComment}
* @param ${entityName}UpdateRequest ${entityComment}更新请求体
* web端管理员根据id修改${entityComment}信息
* @param ${entityNameLower}UpdateRequest ${entityComment}更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员更新${entityComment}", description = "参数:${entityComment}更新请求体权限管理员boss, admin)方法名update${entityName}")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> update${entityName}(@RequestBody ${entityName}UpdateRequest ${entityName}UpdateRequest) {
if (${entityName}UpdateRequest == null || ${entityName}UpdateRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
${entityName} ${entityName} = new ${entityName}();
BeanUtils.copyProperties(${entityName}UpdateRequest, ${entityName});
boolean result = ${entityName}Service.updateById(${entityName});
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}更新失败");
@Operation(summary = "web端管理员更新${entityComment}", description = "参数:${entityComment}更新请求体权限管理员方法名update${entityName}")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "${entityComment}管理", content = "web端管理员根据id修改${entityComment}信息")
public BaseResponse<Boolean> update${entityName}(@Valid @RequestBody ${entityName}UpdateRequest ${entityNameLower}UpdateRequest) {
${entityName} ${entityNameLower} = commonService.copyProperties(${entityNameLower}UpdateRequest, ${entityName}.class);
${entityNameLower}Service.updateById(${entityNameLower});
return ResultUtils.success(true);
}
/**
* web端管理员删除${entityComment}
* web端管理员根据id删除${entityComment}
* @param commonRequest ${entityComment}删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员删除${entityComment}", description = "参数:${entityComment}删除请求体权限管理员boss, admin)方法名del${entityName}")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> del${entityName}(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
@Operation(summary = "web端管理员根据id删除${entityComment}", description = "参数:${entityComment}删除请求体权限管理员方法名del${entityName}")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "${entityComment}管理", content = "web端管理员根据id删除${entityComment}")
public BaseResponse<Boolean> del${entityName}(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
boolean result = ${entityName}Service.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}删除失败");
${entityNameLower}Service.removeById(id);
return ResultUtils.success(true);
}
/**
* Web端管理员分页查看${entityComment}
* @param ${entityName}QueryRequest ${entityComment}查询请求体
* @return ${entityComment}列表
* web端管理员批量删除${entityComment}
* @param commonBatchRequest ${entityComment}批量删除请求体
* @return 是否删除成功
*/
@PostMapping("page")
@Operation(summary = "Web端管理员分页查看${entityComment}", description = "参数:${entityComment}查询请求体权限管理员boss, admin),方法名:list${entityName}ByPage")
public BaseResponse<Page<${entityName}VO>> list${entityName}ByPage(@RequestBody ${entityName}QueryRequest ${entityName}QueryRequest) {
if (${entityName}QueryRequest == null) throw new BusinessException(ErrorCode.PARAMS_ERROR);
long current = ${entityName}QueryRequest.getCurrent();
long pageSize = ${entityName}QueryRequest.getPageSize();
QueryWrapper<${entityName}> queryWrapper = ${entityName}Service.getQueryWrapper(${entityName}QueryRequest);
Page<${entityName}> page = ${entityName}Service.page(new Page<>(current, pageSize), queryWrapper);
List<${entityName}> ${entityName}List = page.getRecords();
List<${entityName}VO> ${entityName}VOList = commonService.convertList(${entityName}List, ${entityName}VO.class);
Page<${entityName}VO> voPage = new Page<>();
voPage.setRecords(${entityName}VOList);
voPage.setPages(page.getPages());
voPage.setCurrent(page.getCurrent());
voPage.setTotal(page.getTotal());
voPage.setSize(page.getSize());
return ResultUtils.success(voPage);
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除${entityComment}", description = "参数:${entityComment}批量删除请求体权限管理员方法名delBatch${entityName}")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "${entityComment}管理", content = "web端管理员批量删除${entityComment}")
public BaseResponse<Boolean> delBatch${entityName}(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
${entityNameLower}Service.removeByIds(ids);
return ResultUtils.success(true);
}
/**
@ -103,32 +85,37 @@ public class ${entityName}Controller {
* @return ${entityComment}信息
*/
@PostMapping("queryById")
@Operation(summary = "web端管理员根据id查询${entityComment}", description = "参数:${entityComment}查询请求体权限管理员boss, admin),方法名:query${entityName}ById")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<${entityName}VO> query${entityName}ById(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
${entityName} ${entityName} = ${entityName}Service.getById(commonRequest.getId());
ThrowUtils.throwIf(${entityName} == null, ErrorCode.NOT_FOUND, "${entityComment}未找到");
${entityName}VO ${entityName}VO = commonService.convert(${entityName}, ${entityName}VO.class);
return ResultUtils.success(${entityName}VO);
@Operation(summary = "web端管理员根据id查询${entityComment}", description = "参数:${entityComment}查询请求体权限管理员方法名query${entityName}ById")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "${entityComment}管理", content = "web端管理员根据id查询${entityComment}")
public BaseResponse<${entityName}VO> query${entityName}ById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
${entityName} ${entityNameLower} = ${entityNameLower}Service.getById(id);
ThrowUtils.throwIf(${entityNameLower} == null, ErrorCode.OPERATION_ERROR, "当前${entityComment}不存在");
${entityName}VO ${entityNameLower}VO = commonService.copyProperties(${entityNameLower}, ${entityName}VO.class);
return ResultUtils.success(${entityNameLower}VO);
}
/**
* web端管理员批量删除${entityComment}
* @param commonRequest ${entityComment}批量删除请求体
* @return 是否删除成功
* Web端管理员分页查询${entityComment}
* @param ${entityNameLower}QueryRequest ${entityComment}查询请求体
* @return ${entityComment}列表
*/
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除${entityComment}", description = "参数:${entityComment}批量删除请求体权限管理员boss, admin),方法名:delBatch${entityName}")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> delBatch${entityName}(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getIds() == null || commonRequest.getIds().isEmpty()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
boolean result = ${entityName}Service.removeByIds(commonRequest.getIds());
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}批量删除失败");
return ResultUtils.success(true);
@PostMapping("page")
@Operation(summary = "Web端管理员分页查询${entityComment}", description = "参数:${entityComment}查询请求体权限管理员方法名list${entityName}ByPage")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "${entityComment}管理", content = "Web端管理员分页查询${entityComment}")
public BaseResponse<Page<${entityName}VO>> list${entityName}ByPage(@Valid @RequestBody ${entityName}QueryRequest ${entityNameLower}QueryRequest) {
long current = ${entityNameLower}QueryRequest.getCurrent();
long pageSize = ${entityNameLower}QueryRequest.getPageSize();
QueryWrapper<${entityName}> queryWrapper = ${entityNameLower}Service.getQueryWrapper(${entityNameLower}QueryRequest);
Page<${entityName}> page = ${entityNameLower}Service.page(new Page<>(current, pageSize), queryWrapper);
List<${entityName}> ${entityNameLower}List = page.getRecords();
List<${entityName}VO> ${entityNameLower}VOList = commonService.convertList(${entityNameLower}List, ${entityName}VO.class);
Page<${entityName}VO> voPage = new Page<>(current, pageSize);
voPage.setRecords(${entityNameLower}VOList);
voPage.setPages(page.getPages());
voPage.setTotal(page.getTotal());
return ResultUtils.success(voPage);
}
}
}

View File

@ -1,6 +1,8 @@
package ${parentPackage}.${dtoPackage};
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
@ -10,7 +12,13 @@ import java.io.Serializable;
* ${entityComment}添加请求体
*/
@Data
@Schema(description = "${entityComment}添加请求体", requiredProperties = {"name", "categoryId", "price", "image", "period", "isShelves"})
@Schema(description = "${entityComment}添加请求体", requiredProperties = {
#foreach($field in ${table.fields})
#if(!$field.keyFlag && $field.propertyName != "id" && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
"${field.propertyName}",
#end
#end
})
public class ${entityName}AddRequest implements Serializable {
#foreach($field in ${table.fields})
@ -18,7 +26,13 @@ public class ${entityName}AddRequest implements Serializable {
/**
* ${field.comment}
*/
@Schema(description = "${field.comment}", example = "${field.example}")
#if($field.propertyType == "String")
@NotBlank(message = "${field.comment}不能为空")
#end
#if($field.propertyType == "Long")
@Min(value = 1L, message = "${field.comment} ID不能小于1")
#end
@Schema(description = "${field.comment}", example = "")
private ${field.propertyType} ${field.propertyName};
#end
@ -27,3 +41,4 @@ public class ${entityName}AddRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -1,10 +1,13 @@
package ${parentPackage}.${dtoPackage};
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import ${parentPackage}.common.PageRequest;
import com.greenorange.promotion.common.PageRequest;
/**
* ${entityComment}查询请求体,继承自分页请求 PageRequest
@ -17,6 +20,7 @@ public class ${entityName}QueryRequest extends PageRequest implements Serializab
* ${entityComment} ID
*/
@Schema(description = "${entityComment} ID", example = "1")
@Min(value = 1L, message = "${entityComment} ID不能小于1")
private Long id;
#foreach($field in ${table.fields})
@ -24,7 +28,10 @@ public class ${entityName}QueryRequest extends PageRequest implements Serializab
/**
* ${field.comment}
*/
@Schema(description = "${field.comment}", example = "${field.example}")
#if($field.propertyType == "String")
@NotBlank(message = "${field.comment}不能为空")
#end
@Schema(description = "${field.comment}", example = "")
private ${field.propertyType} ${field.propertyName};
#end
@ -33,3 +40,4 @@ public class ${entityName}QueryRequest extends PageRequest implements Serializab
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -1,6 +1,8 @@
package ${parentPackage}.${dtoPackage};
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
@ -10,21 +12,27 @@ import java.io.Serializable;
* ${entityComment}更新请求体
*/
@Data
@Schema(description = "${entityComment}更新请求体", requiredProperties = {"id", "name", "categoryId", "price", "image", "period", "isShelves"})
@Schema(description = "${entityComment}更新请求体", requiredProperties = {
#foreach($field in ${table.fields})
#if(!$field.keyFlag && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
"${field.propertyName}",
#end
#end
})
public class ${entityName}UpdateRequest implements Serializable {
/**
* ${entityComment} ID
*/
@Schema(description = "${entityComment} ID", example = "1")
private Long id;
#foreach($field in ${table.fields})
#if(!$field.keyFlag && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
/**
* ${field.comment}
*/
@Schema(description = "${field.comment}", example = "${field.example}")
#if($field.propertyType == "String")
@NotBlank(message = "${field.comment}不能为空")
#end
#if($field.propertyType == "Long")
@Min(value = 1L, message = "${field.comment} ID不能小于1")
#end
@Schema(description = "${field.comment}", example = "")
private ${field.propertyType} ${field.propertyName};
#end
@ -32,4 +40,4 @@ public class ${entityName}UpdateRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
}
}

View File

@ -5,6 +5,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* ${entityComment} 视图对象