项目模块初步完成
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user