项目明细调整
This commit is contained in:
@ -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);
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user