为WrapperUtils中的方法增加了防空处理;规范了代码

master
ArgonarioD 2022-06-30 23:25:23 +08:00
parent f9804ef791
commit fc99117637
15 changed files with 91 additions and 99 deletions

View File

@ -31,18 +31,6 @@ public class WebConfig implements WebMvcConfigurer {
.excludePathPatterns("/staff/login") .excludePathPatterns("/staff/login")
.excludePathPatterns("/hello") .excludePathPatterns("/hello")
.excludePathPatterns("/error") .excludePathPatterns("/error")
.excludePathPatterns("/staff/timetest"); .excludePathPatterns("/swagger-ui/**");
} }
/*
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("token")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
*/
} }

View File

@ -1,17 +1,13 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller; package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project; import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.impl.ProjectServiceImpl;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseList; import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap; import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.HashMap;
@ -26,7 +22,7 @@ import java.util.Map;
public class ProjectController { public class ProjectController {
@Autowired @Autowired
private IProjectService projectServiceImpl; private IProjectService projectService;
@SneakyThrows @SneakyThrows
@GetMapping @GetMapping
@ -36,7 +32,7 @@ public class ProjectController {
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
Map<String, Object> paramMap Map<String, Object> paramMap
) { ) {
Page<ResultProject> page = projectServiceImpl.getOnePageProject(token, pageCurrent, pageSize, paramMap); Page<ResultProject> page = projectService.getOnePageProject(token, pageCurrent, pageSize, paramMap);
return ResponseList.ofSuccess("成功返回列表", page); return ResponseList.ofSuccess("成功返回列表", page);
} }
@ -44,7 +40,7 @@ public class ProjectController {
@GetMapping("/total") @GetMapping("/total")
public ResponseMap getProjectNumOfStaff(@RequestHeader("Token") String token) { public ResponseMap getProjectNumOfStaff(@RequestHeader("Token") String token) {
Map<String, Long> res = new HashMap<>(); Map<String, Long> res = new HashMap<>();
res.put("totalNum", projectServiceImpl.getAllProjectOfStaff(token)); res.put("totalNum", projectService.getAllProjectOfStaff(token));
return ResponseMap.ofSuccess("获得参与项目总数", res); return ResponseMap.ofSuccess("获得参与项目总数", res);
} }
@ -52,14 +48,26 @@ public class ProjectController {
@PostMapping("/complete") @PostMapping("/complete")
public ResponseMap completeProject(@RequestHeader("Token") String token, @RequestBody Map<String, Object> map) { public ResponseMap completeProject(@RequestHeader("Token") String token, @RequestBody Map<String, Object> map) {
Integer targetProjectId = (Integer) map.get("projectId"); Integer targetProjectId = (Integer) map.get("projectId");
projectServiceImpl.setProjectCompleted(token, targetProjectId); projectService.setProjectCompleted(token, targetProjectId);
return ResponseMap.ofSuccess("操作成功"); return ResponseMap.ofSuccess("操作成功");
} }
@SneakyThrows @SneakyThrows
@PostMapping("/create") @PostMapping
public ResponseMap createProject(@RequestHeader("Token") String token, @RequestBody Project project) { public ResponseMap createProject(@RequestHeader("Token") String token, @RequestBody Project project) {
projectServiceImpl.createProject(token, project); projectService.createProject(token, project);
return ResponseMap.ofSuccess("操作成功");
}
@SneakyThrows
@PutMapping("/{projectId}")
public ResponseMap updateProject(
@RequestHeader("Token") String token,
@PathVariable Integer projectId,
@RequestBody Project project
) {
project.setProjectId(projectId);
projectService.updateById(project);
return ResponseMap.ofSuccess("操作成功"); return ResponseMap.ofSuccess("操作成功");
} }
} }

View File

@ -3,7 +3,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectTypeService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectTypeService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseList; import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -16,7 +15,7 @@ import java.util.List;
* @since 2022/6/30 16:36 * @since 2022/6/30 16:36
*/ */
@RestController @RestController
@RequestMapping("/projectType") @RequestMapping("/project/type")
public class ProjectTypeController { public class ProjectTypeController {
@Autowired @Autowired
private IProjectTypeService projectTypeServiceImpl; private IProjectTypeService projectTypeServiceImpl;

View File

@ -2,14 +2,12 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff; import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException; import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
import cn.edu.hfut.rmdjzz.projectmanagement.service.impl.StaffServiceImpl; import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap; import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
/** /**
* @author * @author
* created at 2022/6/28 21:59 * created at 2022/6/28 21:59
@ -18,26 +16,21 @@ import java.time.LocalDateTime;
@RequestMapping("/staff") @RequestMapping("/staff")
public class StaffController { public class StaffController {
@Autowired @Autowired
private StaffServiceImpl staffServiceImpl; private IStaffService staffService;
@SneakyThrows @SneakyThrows
@PostMapping("/login") @PostMapping("/login")
public ResponseMap login(@RequestBody Staff staff) { public ResponseMap login(@RequestBody Staff staff) {
return staffServiceImpl.login(staff.getStaffUsername(), staff.getStaffPassword()); return staffService.login(staff.getStaffUsername(), staff.getStaffPassword());
} }
@SneakyThrows @SneakyThrows
@PostMapping("/logout") @PostMapping("/logout")
public ResponseMap logout(@RequestHeader("Token") String token) { public ResponseMap logout(@RequestHeader("Token") String token) {
if (staffServiceImpl.logout(token)) if (staffService.logout(token))
return ResponseMap.ofSuccess("操作成功"); return ResponseMap.ofSuccess("操作成功");
else { else {
throw new TokenException("操作失败"); throw new TokenException("操作失败");
} }
} }
@GetMapping("/timetest")
public LocalDateTime timeTest() {
return LocalDateTime.now();
}
} }

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
/** /**
@ -34,10 +35,11 @@ public class Project {
private String projectArea; private String projectArea;
private String projectCompany; private String projectCompany;
private String projectDescription; private String projectDescription;
private BigDecimal projectManMonth;
@TableField("is_completed") @TableField("is_completed")
private Boolean completed; private Boolean completed;
@TableField("is_deleted") @TableField("is_deleted")
@TableLogic @TableLogic
private Boolean isDeleted; private Boolean deleted;
private Integer projectCreator; private Integer projectCreator;
} }

View File

@ -1,10 +1,7 @@
package cn.edu.hfut.rmdjzz.projectmanagement.entity; package cn.edu.hfut.rmdjzz.projectmanagement.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDate; import java.time.LocalDate;
@ -22,14 +19,15 @@ public class ResultProject {
String projectImportance; String projectImportance;
String projectClassName; String projectClassName;
String projectSubclassName; String projectSubclassName;
Boolean IsDeleted; Boolean deleted;
Boolean IsCompleted; Boolean completed;
LocalDate projectCloseTime; LocalDate projectCloseTime;
Integer CompleteNum; Integer completeNum;
Integer TotalNum; Integer totalNum;
ResultProject() { ResultProject() {
CompleteNum = 50; completeNum = 50;
TotalNum = 100; totalNum = 100;
} }
// 带加的进度 Double projectProcess; // 带加的进度 Double projectProcess;
} }

View File

@ -1,6 +1,5 @@
package cn.edu.hfut.rmdjzz.projectmanagement.mapper; package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -6,11 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.Result;
import org.springframework.web.bind.annotation.RequestMapping; import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/** /**
* @author * @author
@ -49,8 +48,8 @@ public interface ProjectMapper extends BaseMapper<Project> {
@Result(column = "project_class_name", property = "projectClassName"), @Result(column = "project_class_name", property = "projectClassName"),
@Result(column = "project_subclass_name", property = "projectSubclassName"), @Result(column = "project_subclass_name", property = "projectSubclassName"),
@Result(column = "project_class_name", property = "projectClassName"), @Result(column = "project_class_name", property = "projectClassName"),
@Result(column = "is_completed", property = "IsCompleted"), @Result(column = "is_completed", property = "completed"),
@Result(column = "is_deleted", property = "IsDeleted"), @Result(column = "is_deleted", property = "deleted"),
@Result(column = "project_close_time", property = "projectCloseTime"), @Result(column = "project_close_time", property = "projectCloseTime"),
@Result(column = "project_creator", property = "projectCreator") @Result(column = "project_creator", property = "projectCreator")
}) })

View File

@ -1,6 +1,5 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service; package cn.edu.hfut.rmdjzz.projectmanagement.service;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
@ -9,6 +8,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
* created at 2022/6/30 21:36 * created at 2022/6/30 21:36
*/ */
public interface IProjectGroupService extends IService<ProjectGroup> { public interface IProjectGroupService extends IService<ProjectGroup> {
public Boolean addCreator(Integer projectId,Integer staffId); Boolean addCreator(Integer projectId, Integer staffId);
} }

View File

@ -4,7 +4,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException; import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException; import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;

View File

@ -1,11 +1,11 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl; package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project; import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException; import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException; import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper; import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils; import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils; import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
@ -13,10 +13,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Map; import java.util.Map;
@ -29,7 +27,8 @@ import java.util.Objects;
@Service @Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService { public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
@Autowired @Autowired
private ProjectGroupServiceImpl projectGroupServiceImpl; private IProjectGroupService projectGroupService;
@Override @Override
public Long getAllProjectOfStaff(String token) throws TokenException { public Long getAllProjectOfStaff(String token) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token); Integer staffId = TokenUtils.getStaffId(token);
@ -45,7 +44,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
) throws TokenException { ) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token); Integer staffId = TokenUtils.getStaffId(token);
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize); IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false)); IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params));
return (Page<ResultProject>) userPage; return (Page<ResultProject>) userPage;
} }
@ -59,9 +58,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
throw new BadRequestException("项目不存在"); throw new BadRequestException("项目不存在");
if (!Objects.equals(staffId, targetProject.getProjectCreator())) if (!Objects.equals(staffId, targetProject.getProjectCreator()))
throw new BadRequestException("用户请求非法"); throw new BadRequestException("用户请求非法");
if(targetProject.getIsCompleted()) if (targetProject.getCompleted())
throw new BadRequestException("该项目已结项"); throw new BadRequestException("该项目已结项");
targetProject.setIsCompleted(true); targetProject.setCompleted(true);
targetProject.setProjectCloseTime(LocalDate.now()); targetProject.setProjectCloseTime(LocalDate.now());
if (baseMapper.updateById(targetProject) == 1) if (baseMapper.updateById(targetProject) == 1)
return true; return true;
@ -71,21 +70,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
public Boolean createProject(String token, Project project) throws TokenException, BadRequestException { public Boolean createProject(String token, Project project) throws TokenException, BadRequestException {
project.setProjectId(null); project.setProjectId(null);
project.setIsCompleted(false); project.setCompleted(false);
project.setProjectCreator(TokenUtils.getStaffId(token)); project.setProjectCreator(TokenUtils.getStaffId(token));
project.setProjectCloseTime(null); project.setProjectCloseTime(null);
if (project.getExpectedCompletion() == null) { if (project.getExpectedCompletion() == null) {
project.setExpectedCompletion((short) 100); project.setExpectedCompletion((short) 100);
} } else if (project.getExpectedCompletion() < 0 || project.getExpectedCompletion() > 100 ||
else if(project.getExpectedCompletion()<0||project.getExpectedCompletion()>100||
project.getProjectStartTime() == null || project.getProjectEndTime() == null || project.getProjectStartTime() == null || project.getProjectEndTime() == null ||
project.getProjectStartTime().isAfter(project.getProjectEndTime()) project.getProjectStartTime().isAfter(project.getProjectEndTime())
) { ) {
throw new BadRequestException("参数错误"); throw new BadRequestException("参数错误");
} }
try { try {
if (baseMapper.insert(project) == 1) { if (baseMapper.insert(project) == 1) {
return projectGroupServiceImpl.addCreator(project.getProjectId(),TokenUtils.getStaffId(token)); return projectGroupService.addCreator(project.getProjectId(), TokenUtils.getStaffId(token));
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); System.out.println(e);

View File

@ -1,10 +1,7 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl; package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType; import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper; import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectTypeService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectTypeService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

View File

@ -31,6 +31,9 @@ public class WrapperUtils {
Map<String, Object> paramMap, boolean camel2Underline, boolean boolLeftAppendIs, boolean null2IsNull Map<String, Object> paramMap, boolean camel2Underline, boolean boolLeftAppendIs, boolean null2IsNull
) { ) {
QueryWrapper<T> wrapper = new QueryWrapper<>(); QueryWrapper<T> wrapper = new QueryWrapper<>();
if (paramMap == null || paramMap.isEmpty()) {
return wrapper;
}
paramMap.forEach((key, value) -> { paramMap.forEach((key, value) -> {
if (value == null) { if (value == null) {
if (null2IsNull) { if (null2IsNull) {

View File

@ -4,8 +4,10 @@ import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff; import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.impl.ProjectServiceImpl;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils; import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows; import lombok.SneakyThrows;
@ -63,4 +65,11 @@ public class MybatisPlusTests {
List<Project> projects = projectService.list(); List<Project> projects = projectService.list();
System.out.println(objectMapper.writeValueAsString(projects)); System.out.println(objectMapper.writeValueAsString(projects));
} }
@SneakyThrows
@Test
public void resultProjectTest() {
System.out.println(objectMapper.writeValueAsString(((ProjectServiceImpl) projectService).getBaseMapper()
.findMyProject(new Page<>(1, 5), 1, Wrappers.query())));
}
} }