为WrapperUtils中的方法增加了防空处理;规范了代码
parent
f9804ef791
commit
fc99117637
|
@ -31,18 +31,6 @@ public class WebConfig implements WebMvcConfigurer {
|
|||
.excludePathPatterns("/staff/login")
|
||||
.excludePathPatterns("/hello")
|
||||
.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("*");
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,17 +1,13 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||
|
||||
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.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.ResponseMap;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -26,7 +22,7 @@ import java.util.Map;
|
|||
public class ProjectController {
|
||||
|
||||
@Autowired
|
||||
private IProjectService projectServiceImpl;
|
||||
private IProjectService projectService;
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping
|
||||
|
@ -36,7 +32,7 @@ public class ProjectController {
|
|||
@RequestParam("pageSize") Integer pageSize,
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -44,22 +40,34 @@ public class ProjectController {
|
|||
@GetMapping("/total")
|
||||
public ResponseMap getProjectNumOfStaff(@RequestHeader("Token") String token) {
|
||||
Map<String, Long> res = new HashMap<>();
|
||||
res.put("totalNum", projectServiceImpl.getAllProjectOfStaff(token));
|
||||
res.put("totalNum", projectService.getAllProjectOfStaff(token));
|
||||
return ResponseMap.ofSuccess("获得参与项目总数", res);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@PostMapping("/complete")
|
||||
public ResponseMap completeProject(@RequestHeader("Token") String token,@RequestBody Map<String,Object> map){
|
||||
Integer targetProjectId=(Integer)map.get("projectId");
|
||||
projectServiceImpl.setProjectCompleted(token, targetProjectId);
|
||||
public ResponseMap completeProject(@RequestHeader("Token") String token, @RequestBody Map<String, Object> map) {
|
||||
Integer targetProjectId = (Integer) map.get("projectId");
|
||||
projectService.setProjectCompleted(token, targetProjectId);
|
||||
return ResponseMap.ofSuccess("操作成功");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@PostMapping("/create")
|
||||
public ResponseMap createProject(@RequestHeader("Token") String token,@RequestBody Project project){
|
||||
projectServiceImpl.createProject(token, project);
|
||||
@PostMapping
|
||||
public ResponseMap createProject(@RequestHeader("Token") String token, @RequestBody Project 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("操作成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.service.IProjectTypeService;
|
||||
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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -16,7 +15,7 @@ import java.util.List;
|
|||
* @since 2022/6/30 16:36
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/projectType")
|
||||
@RequestMapping("/project/type")
|
||||
public class ProjectTypeController {
|
||||
@Autowired
|
||||
private IProjectTypeService projectTypeServiceImpl;
|
||||
|
|
|
@ -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.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 lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author 张韬
|
||||
* created at 2022/6/28 21:59
|
||||
|
@ -18,26 +16,21 @@ import java.time.LocalDateTime;
|
|||
@RequestMapping("/staff")
|
||||
public class StaffController {
|
||||
@Autowired
|
||||
private StaffServiceImpl staffServiceImpl;
|
||||
private IStaffService staffService;
|
||||
|
||||
@SneakyThrows
|
||||
@PostMapping("/login")
|
||||
public ResponseMap login(@RequestBody Staff staff) {
|
||||
return staffServiceImpl.login(staff.getStaffUsername(), staff.getStaffPassword());
|
||||
return staffService.login(staff.getStaffUsername(), staff.getStaffPassword());
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@PostMapping("/logout")
|
||||
public ResponseMap logout(@RequestHeader("Token") String token) {
|
||||
if (staffServiceImpl.logout(token))
|
||||
if (staffService.logout(token))
|
||||
return ResponseMap.ofSuccess("操作成功");
|
||||
else {
|
||||
throw new TokenException("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/timetest")
|
||||
public LocalDateTime timeTest() {
|
||||
return LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
|
@ -34,10 +35,11 @@ public class Project {
|
|||
private String projectArea;
|
||||
private String projectCompany;
|
||||
private String projectDescription;
|
||||
private BigDecimal projectManMonth;
|
||||
@TableField("is_completed")
|
||||
private Boolean completed;
|
||||
@TableField("is_deleted")
|
||||
@TableLogic
|
||||
private Boolean isDeleted;
|
||||
private Boolean deleted;
|
||||
private Integer projectCreator;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
@ -22,14 +19,15 @@ public class ResultProject {
|
|||
String projectImportance;
|
||||
String projectClassName;
|
||||
String projectSubclassName;
|
||||
Boolean IsDeleted;
|
||||
Boolean IsCompleted;
|
||||
Boolean deleted;
|
||||
Boolean completed;
|
||||
LocalDate projectCloseTime;
|
||||
Integer CompleteNum;
|
||||
Integer TotalNum;
|
||||
Integer completeNum;
|
||||
Integer totalNum;
|
||||
|
||||
ResultProject() {
|
||||
CompleteNum = 50;
|
||||
TotalNum = 100;
|
||||
completeNum = 50;
|
||||
totalNum = 100;
|
||||
}
|
||||
// 带加的进度 Double projectProcess;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* @author 阳勇权
|
||||
|
@ -19,9 +18,9 @@ import java.util.List;
|
|||
public interface ProjectMapper extends BaseMapper<Project> {
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(*) FROM project WHERE project_id IN
|
||||
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})
|
||||
""")
|
||||
SELECT COUNT(*) FROM project WHERE project_id IN
|
||||
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})
|
||||
""")
|
||||
Long findProjectCount(@Param("id") Integer staffId);
|
||||
|
||||
@Select("""
|
||||
|
@ -49,8 +48,8 @@ public interface ProjectMapper extends BaseMapper<Project> {
|
|||
@Result(column = "project_class_name", property = "projectClassName"),
|
||||
@Result(column = "project_subclass_name", property = "projectSubclassName"),
|
||||
@Result(column = "project_class_name", property = "projectClassName"),
|
||||
@Result(column = "is_completed", property = "IsCompleted"),
|
||||
@Result(column = "is_deleted", property = "IsDeleted"),
|
||||
@Result(column = "is_completed", property = "completed"),
|
||||
@Result(column = "is_deleted", property = "deleted"),
|
||||
@Result(column = "project_close_time", property = "projectCloseTime"),
|
||||
@Result(column = "project_creator", property = "projectCreator")
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
@ -8,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @author 张韬
|
||||
* created at 2022/6/30 21:36
|
||||
*/
|
||||
public interface IProjectGroupService extends IService<ProjectGroup>{
|
||||
public Boolean addCreator(Integer projectId,Integer staffId);
|
||||
public interface IProjectGroupService extends IService<ProjectGroup> {
|
||||
Boolean addCreator(Integer projectId, Integer staffId);
|
||||
|
||||
}
|
|
@ -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.exception.BadRequestException;
|
||||
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.service.IService;
|
||||
|
||||
|
@ -18,9 +17,9 @@ public interface IProjectService extends IService<Project> {
|
|||
|
||||
Long getAllProjectOfStaff(String token) throws TokenException;
|
||||
|
||||
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
||||
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String, Object> params) throws TokenException;
|
||||
|
||||
Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException;
|
||||
|
||||
Boolean createProject(String token,Project project) throws TokenException, BadRequestException;
|
||||
Boolean createProject(String token, Project project) throws TokenException, BadRequestException;
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, ProjectGroup> implements IProjectGroupService {
|
||||
public Boolean addCreator(Integer projectId,Integer staffId){
|
||||
if(projectId==null||staffId==null)
|
||||
public Boolean addCreator(Integer projectId, Integer staffId) {
|
||||
if (projectId == null || staffId == null)
|
||||
return false;
|
||||
ProjectGroup projectGroup=new ProjectGroup();
|
||||
ProjectGroup projectGroup = new ProjectGroup();
|
||||
projectGroup.setProjectId(projectId);
|
||||
projectGroup.setStaffId(staffId);
|
||||
projectGroup.setProjectStaffPosition("负责人");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||
|
||||
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.exception.BadRequestException;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||
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.utils.TokenUtils;
|
||||
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.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
@ -29,7 +27,8 @@ import java.util.Objects;
|
|||
@Service
|
||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||
@Autowired
|
||||
private ProjectGroupServiceImpl projectGroupServiceImpl;
|
||||
private IProjectGroupService projectGroupService;
|
||||
|
||||
@Override
|
||||
public Long getAllProjectOfStaff(String token) throws TokenException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
|
@ -45,51 +44,51 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||
) throws TokenException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
Project project=new Project();
|
||||
Project project = new Project();
|
||||
project.setProjectId(projectId);
|
||||
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
||||
if(targetProject==null)
|
||||
if (targetProject == null)
|
||||
throw new BadRequestException("项目不存在");
|
||||
if(!Objects.equals(staffId, targetProject.getProjectCreator()))
|
||||
if (!Objects.equals(staffId, targetProject.getProjectCreator()))
|
||||
throw new BadRequestException("用户请求非法");
|
||||
if(targetProject.getIsCompleted())
|
||||
if (targetProject.getCompleted())
|
||||
throw new BadRequestException("该项目已结项");
|
||||
targetProject.setIsCompleted(true);
|
||||
targetProject.setCompleted(true);
|
||||
targetProject.setProjectCloseTime(LocalDate.now());
|
||||
if(baseMapper.updateById(targetProject)==1)
|
||||
if (baseMapper.updateById(targetProject) == 1)
|
||||
return true;
|
||||
throw new BadRequestException("操作失败");
|
||||
}
|
||||
|
||||
@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.setIsCompleted(false);
|
||||
project.setCompleted(false);
|
||||
project.setProjectCreator(TokenUtils.getStaffId(token));
|
||||
project.setProjectCloseTime(null);
|
||||
if(project.getExpectedCompletion()==null){
|
||||
if (project.getExpectedCompletion() == null) {
|
||||
project.setExpectedCompletion((short) 100);
|
||||
}
|
||||
else if(project.getExpectedCompletion()<0||project.getExpectedCompletion()>100||
|
||||
project.getProjectStartTime()==null||project.getProjectEndTime()==null||
|
||||
} else if (project.getExpectedCompletion() < 0 || project.getExpectedCompletion() > 100 ||
|
||||
project.getProjectStartTime() == null || project.getProjectEndTime() == null ||
|
||||
project.getProjectStartTime().isAfter(project.getProjectEndTime())
|
||||
){
|
||||
) {
|
||||
throw new BadRequestException("参数错误");
|
||||
}
|
||||
try{
|
||||
if(baseMapper.insert(project)==1){
|
||||
return projectGroupServiceImpl.addCreator(project.getProjectId(),TokenUtils.getStaffId(token));
|
||||
|
||||
try {
|
||||
if (baseMapper.insert(project) == 1) {
|
||||
return projectGroupService.addCreator(project.getProjectId(), TokenUtils.getStaffId(token));
|
||||
}
|
||||
}catch(Exception e){
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
throw new BadRequestException("新建失败");
|
||||
throw new BadRequestException("新建失败");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
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.mapper.ProjectMapper;
|
||||
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 com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -17,7 +14,7 @@ import java.util.List;
|
|||
* @since 2022/6/30 16:28
|
||||
*/
|
||||
@Service
|
||||
public class ProjectTypeServiceImpl extends ServiceImpl<ProjectTypeMapper, ProjectType> implements IProjectTypeService {
|
||||
public class ProjectTypeServiceImpl extends ServiceImpl<ProjectTypeMapper, ProjectType> implements IProjectTypeService {
|
||||
|
||||
@Override
|
||||
public List<ProjectType> findAllProjectType() {
|
||||
|
|
|
@ -23,14 +23,17 @@ public class WrapperUtils {
|
|||
* - 对于时间类({@link LocalDateTime}或{@link LocalDate}或{@link LocalTime}),
|
||||
* 会按照key的后缀处理,若为Start则处理为column >= value,End则处理为column <= value
|
||||
*
|
||||
* @param camel2Underline 若为真,则将key的小驼峰命名转为下划线命名风格
|
||||
* @param boolLeftAppendIs 若为真,则将value为boolean型的变量的key前添加IS
|
||||
* @param null2IsNull 若为真,将value为null的值在SQL中生成为IS NULL;否则值为null的参数不会在SQL中生成
|
||||
* @param camel2Underline 若为真,则将key的小驼峰命名转为下划线命名风格
|
||||
* @param boolLeftAppendIs 若为真,则将value为boolean型的变量的key前添加IS
|
||||
* @param null2IsNull 若为真,将value为null的值在SQL中生成为IS NULL;否则值为null的参数不会在SQL中生成
|
||||
*/
|
||||
public static <T> QueryWrapper<T> allEqAndTimeIntervalQueryWrapper(
|
||||
Map<String, Object> paramMap, boolean camel2Underline, boolean boolLeftAppendIs, boolean null2IsNull
|
||||
) {
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
if (paramMap == null || paramMap.isEmpty()) {
|
||||
return wrapper;
|
||||
}
|
||||
paramMap.forEach((key, value) -> {
|
||||
if (value == null) {
|
||||
if (null2IsNull) {
|
||||
|
|
|
@ -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.service.IProjectService;
|
||||
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.SneakyThrows;
|
||||
|
@ -63,4 +65,11 @@ public class MybatisPlusTests {
|
|||
List<Project> projects = projectService.list();
|
||||
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())));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue