项目模块初步完成

This commit is contained in:
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;
}
}