项目明细调整
This commit is contained in:
parent
7c39a7634a
commit
093c8332e6
|
@ -0,0 +1,148 @@
|
|||
package com.greenorange.promotion.controller.userProject;
|
||||
|
||||
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.userProject.UserProjectAddRequest;
|
||||
import com.greenorange.promotion.model.dto.userProject.UserProjectQueryRequest;
|
||||
import com.greenorange.promotion.model.dto.userProject.UserProjectUpdateRequest;
|
||||
import com.greenorange.promotion.model.entity.UserProject;
|
||||
import com.greenorange.promotion.model.vo.userProject.UserProjectVO;
|
||||
import com.greenorange.promotion.service.common.CommonService;
|
||||
import com.greenorange.promotion.service.project.UserProjectService;
|
||||
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("userProject")
|
||||
@Slf4j
|
||||
@Tag(name = "用户项目管理")
|
||||
public class UserProjectController {
|
||||
|
||||
@Resource
|
||||
private UserProjectService userProjectService;
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
/**
|
||||
* web端管理员添加用户项目
|
||||
* @param userProjectAddRequest 用户项目添加请求体
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
@Operation(summary = "web端管理员添加用户项目", description = "参数:用户项目添加请求体,权限:管理员,方法名:addUserProject")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "用户项目管理", content = "web端管理员添加用户项目")
|
||||
public BaseResponse<Boolean> addUserProject(@Valid @RequestBody UserProjectAddRequest userProjectAddRequest) {
|
||||
UserProject userProject = commonService.copyProperties(userProjectAddRequest, UserProject.class);
|
||||
userProjectService.save(userProject);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id修改用户项目信息
|
||||
* @param userProjectUpdateRequest 用户项目更新请求体
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PostMapping("update")
|
||||
@Operation(summary = "web端管理员更新用户项目", description = "参数:用户项目更新请求体,权限:管理员,方法名:updateUserProject")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "用户项目管理", content = "web端管理员根据id修改用户项目信息")
|
||||
public BaseResponse<Boolean> updateUserProject(@Valid @RequestBody UserProjectUpdateRequest userProjectUpdateRequest) {
|
||||
UserProject userProject = commonService.copyProperties(userProjectUpdateRequest, UserProject.class);
|
||||
userProjectService.updateById(userProject);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id删除用户项目
|
||||
* @param commonRequest 用户项目删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
@Operation(summary = "web端管理员根据id删除用户项目", description = "参数:用户项目删除请求体,权限:管理员,方法名:delUserProject")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "用户项目管理", content = "web端管理员根据id删除用户项目")
|
||||
public BaseResponse<Boolean> delUserProject(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
userProjectService.removeById(id);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员批量删除用户项目
|
||||
* @param commonBatchRequest 用户项目批量删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delBatch")
|
||||
@Operation(summary = "web端管理员批量删除用户项目", description = "参数:用户项目批量删除请求体,权限:管理员,方法名:delBatchUserProject")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "用户项目管理", content = "web端管理员批量删除用户项目")
|
||||
public BaseResponse<Boolean> delBatchUserProject(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
|
||||
List<Long> ids = commonBatchRequest.getIds();
|
||||
userProjectService.removeByIds(ids);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询用户项目
|
||||
* @param commonRequest 用户项目查询请求体
|
||||
* @return 用户项目信息
|
||||
*/
|
||||
@PostMapping("queryById")
|
||||
@Operation(summary = "web端管理员根据id查询用户项目", description = "参数:用户项目查询请求体,权限:管理员,方法名:queryUserProjectById")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "用户项目管理", content = "web端管理员根据id查询用户项目")
|
||||
public BaseResponse<UserProjectVO> queryUserProjectById(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
UserProject userProject = userProjectService.getById(id);
|
||||
ThrowUtils.throwIf(userProject == null, ErrorCode.OPERATION_ERROR, "当前用户项目不存在");
|
||||
UserProjectVO userProjectVO = commonService.copyProperties(userProject, UserProjectVO.class);
|
||||
return ResultUtils.success(userProjectVO);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Web端管理员分页查询用户项目
|
||||
// * @param userProjectQueryRequest 用户项目查询请求体
|
||||
// * @return 用户项目列表
|
||||
// */
|
||||
// @PostMapping("page")
|
||||
// @Operation(summary = "Web端管理员分页查询用户项目", description = "参数:用户项目查询请求体,权限:管理员,方法名:listUserProjectByPage")
|
||||
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
// @SysLog(title = "用户项目管理", content = "Web端管理员分页查询用户项目")
|
||||
// public BaseResponse<Page<UserProjectVO>> listUserProjectByPage(@Valid @RequestBody UserProjectQueryRequest userProjectQueryRequest) {
|
||||
// long current = userProjectQueryRequest.getCurrent();
|
||||
// long pageSize = userProjectQueryRequest.getPageSize();
|
||||
// QueryWrapper<UserProject> queryWrapper = userProjectService.getQueryWrapper(userProjectQueryRequest);
|
||||
// Page<UserProject> page = userProjectService.page(new Page<>(current, pageSize), queryWrapper);
|
||||
// List<UserProject> userProjectList = page.getRecords();
|
||||
// List<UserProjectVO> userProjectVOList = commonService.convertList(userProjectList, UserProjectVO.class);
|
||||
// Page<UserProjectVO> voPage = new Page<>(current, pageSize);
|
||||
// voPage.setRecords(userProjectVOList);
|
||||
// voPage.setPages(page.getPages());
|
||||
// voPage.setTotal(page.getTotal());
|
||||
// return ResultUtils.success(voPage);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.greenorange.promotion.mapper;
|
||||
|
||||
import com.greenorange.promotion.model.entity.UserProject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【user_project(用户项目表)】的数据库操作Mapper
|
||||
* @createDate 2025-05-09 08:42:53
|
||||
* @Entity com.greenorange.promotion.model.entity.UserProject
|
||||
*/
|
||||
public interface UserProjectMapper extends BaseMapper<UserProject> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.greenorange.promotion.model.dto.userProject;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 用户项目添加请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户项目添加请求体", requiredProperties = {
|
||||
"projectId",
|
||||
"projectName",
|
||||
"projectImage",
|
||||
"projectSettlementCycle",
|
||||
"userId",
|
||||
})
|
||||
public class UserProjectAddRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "项目ID ID不能小于1")
|
||||
@Schema(description = "项目ID", example = "")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
@Schema(description = "项目名称", example = "")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目图片URL
|
||||
*/
|
||||
@NotBlank(message = "项目图片URL不能为空")
|
||||
@Schema(description = "项目图片URL", example = "")
|
||||
private String projectImage;
|
||||
|
||||
/**
|
||||
* 项目结算周期
|
||||
*/
|
||||
@Schema(description = "项目结算周期", example = "")
|
||||
private Integer projectSettlementCycle;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Min(value = 1L, message = "用户ID ID不能小于1")
|
||||
@Schema(description = "用户ID", example = "")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.greenorange.promotion.model.dto.userProject;
|
||||
|
||||
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 com.greenorange.promotion.common.PageRequest;
|
||||
|
||||
/**
|
||||
* 用户项目查询请求体,继承自分页请求 PageRequest
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户项目查询请求体", requiredProperties = {"current", "pageSize"})
|
||||
public class UserProjectQueryRequest extends PageRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 用户项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "用户项目ID ID不能小于1")
|
||||
@Schema(description = "用户项目ID", example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "项目ID ID不能小于1")
|
||||
@Schema(description = "项目ID", example = "")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
@Schema(description = "项目名称", example = "")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目图片URL
|
||||
*/
|
||||
@NotBlank(message = "项目图片URL不能为空")
|
||||
@Schema(description = "项目图片URL", example = "")
|
||||
private String projectImage;
|
||||
|
||||
/**
|
||||
* 项目结算周期
|
||||
*/
|
||||
@Schema(description = "项目结算周期", example = "")
|
||||
private Integer projectSettlementCycle;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Min(value = 1L, message = "用户ID ID不能小于1")
|
||||
@Schema(description = "用户ID", example = "")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.greenorange.promotion.model.dto.userProject;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 用户项目更新请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户项目更新请求体", requiredProperties = {
|
||||
"id",
|
||||
"projectId",
|
||||
"projectName",
|
||||
"projectImage",
|
||||
"projectSettlementCycle",
|
||||
"userId",
|
||||
})
|
||||
public class UserProjectUpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 用户项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "用户项目ID ID不能小于1")
|
||||
@Schema(description = "用户项目ID", example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "项目ID ID不能小于1")
|
||||
@Schema(description = "项目ID", example = "")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
@Schema(description = "项目名称", example = "")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目图片URL
|
||||
*/
|
||||
@NotBlank(message = "项目图片URL不能为空")
|
||||
@Schema(description = "项目图片URL", example = "")
|
||||
private String projectImage;
|
||||
|
||||
/**
|
||||
* 项目结算周期
|
||||
*/
|
||||
@Schema(description = "项目结算周期", example = "")
|
||||
private Integer projectSettlementCycle;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Min(value = 1L, message = "用户ID ID不能小于1")
|
||||
@Schema(description = "用户ID", example = "")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
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.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户项目表
|
||||
* @TableName user_project
|
||||
*/
|
||||
@TableName(value ="user_project")
|
||||
@Data
|
||||
public class UserProject implements Serializable {
|
||||
/**
|
||||
* 用户项目ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目图片URL
|
||||
*/
|
||||
private String projectImage;
|
||||
|
||||
/**
|
||||
* 项目结算周期
|
||||
*/
|
||||
private Integer projectSettlementCycle;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.greenorange.promotion.model.vo.userProject;
|
||||
|
||||
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 UserProjectVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 用户项目ID
|
||||
*/
|
||||
@Schema(description = "用户项目ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Schema(description = "项目ID", example = "${field.example}")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@Schema(description = "项目名称", example = "${field.example}")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目图片URL
|
||||
*/
|
||||
@Schema(description = "项目图片URL", example = "${field.example}")
|
||||
private String projectImage;
|
||||
|
||||
/**
|
||||
* 项目结算周期
|
||||
*/
|
||||
@Schema(description = "项目结算周期", example = "${field.example}")
|
||||
private Integer projectSettlementCycle;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID", example = "${field.example}")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.greenorange.promotion.service.project;
|
||||
|
||||
import com.greenorange.promotion.model.entity.UserProject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【user_project(用户项目表)】的数据库操作Service
|
||||
* @createDate 2025-05-09 08:42:53
|
||||
*/
|
||||
public interface UserProjectService extends IService<UserProject> {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.greenorange.promotion.service.project.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.greenorange.promotion.model.entity.UserProject;
|
||||
import com.greenorange.promotion.service.project.UserProjectService;
|
||||
import com.greenorange.promotion.mapper.UserProjectMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【user_project(用户项目表)】的数据库操作Service实现
|
||||
* @createDate 2025-05-09 08:42:53
|
||||
*/
|
||||
@Service
|
||||
public class UserProjectServiceImpl extends ServiceImpl<UserProjectMapper, UserProject>
|
||||
implements UserProjectService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
24
src/main/resources/mapper/UserProjectMapper.xml
Normal file
24
src/main/resources/mapper/UserProjectMapper.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?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.UserProjectMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.UserProject">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="projectId" column="projectId" jdbcType="BIGINT"/>
|
||||
<result property="projectName" column="projectName" jdbcType="VARCHAR"/>
|
||||
<result property="projectImage" column="projectImage" jdbcType="VARCHAR"/>
|
||||
<result property="projectSettlementCycle" column="projectSettlementCycle" jdbcType="INTEGER"/>
|
||||
<result property="userId" column="userId" jdbcType="BIGINT"/>
|
||||
<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,projectId,projectName,
|
||||
projectImage,projectSettlementCycle,userId,
|
||||
isDelete,createTime,updateTime
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user