Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/entity/Project.java
master
ArgonarioD 2022-06-30 17:46:42 +08:00
commit 50850e8e5a
5 changed files with 64 additions and 35 deletions

View File

@ -1,7 +1,19 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller; package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import org.springframework.web.bind.annotation.RequestMapping; import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import org.springframework.web.bind.annotation.RestController; 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.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author * @author
@ -11,4 +23,19 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/project") @RequestMapping("/project")
public class ProjectController { public class ProjectController {
@Autowired
private IProjectService projectServiceImpl;
@SneakyThrows
@GetMapping
public ResponseMap getProjectListOfStaff(
@RequestHeader("Token") String token,
@RequestParam("pageCurrent") Integer pageCurrent,
@RequestParam("pageSize") Integer pageSize,
Map<String, Object> paramMap
) {
Page<ResultProject> page = projectServiceImpl.getOnePageProject(token, pageCurrent, pageSize, paramMap);
return ResponseMap.ofSuccess("返回列表", page);
}
} }

View File

@ -6,6 +6,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.time.LocalDate;
/** /**
* @author * @author
* @since 2022/6/29 20:45 * @since 2022/6/29 20:45
@ -19,6 +21,9 @@ public class ResultProject {
Long contractAmount; Long contractAmount;
String projectImportance; String projectImportance;
String projectClassName; String projectClassName;
String projectSubClassName; String projectSubclassName;
Boolean IsDeleted;
Boolean IsCompleted;
LocalDate projectCloseTime;
// 带加的进度 Double projectProcess; // 带加的进度 Double projectProcess;
} }

View File

@ -17,26 +17,34 @@ import java.util.List;
* @since 2022/6/29 17:07 * @since 2022/6/29 17:07
*/ */
public interface ProjectMapper extends BaseMapper<Project> { 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});
""")
Long getProjectTotalNum(@Param("id") Integer staffId);
@Select(""" @Select("""
SELECT * FROM project WHERE project_id IN SELECT * FROM
(SELECT DISTINCT project_id FROM project_group) (SELECT project_id,
${ew.customSqlSegment}; project_name,
contract_amount,
project_importance,
pt1.project_class_name as project_class_name,
pt2.project_class_name as project_subclass_name,
is_completed,
is_deleted,
project_close_time
FROM project join project_type pt1 on project.project_class_id = pt1.project_class_id
join project_type pt2 on project.project_subclass_id = pt2.project_class_id
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})) AS T
${ew.customSqlSegment}
""") """)
@Results({ @Results({
@Result(column = "project_id", property = "projectId", id = true), @Result(column = "project_id", property = "projectId", id = true),
@Result(column = "project_name", property = "projectName"), @Result(column = "project_name", property = "projectName"),
@Result(column = "contract_amount", property = "contractAmount"), @Result(column = "contract_amount", property = "contractAmount"),
@Result(column = "project_importance", property = "projectImportance"), @Result(column = "project_importance", property = "projectImportance"),
@Result(column = "{id = project_class_id}", property = "projectClassName", javaType = String.class, @Result(column = "project_class_name", property = "projectClassName"),
one = @One(select = "cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper.findClassNameById")), @Result(column = "project_subclass_name", property = "projectSubclassName"),
@Result(column = "{id = project_subclass_id}", property = "projectSubClassName", javaType = String.class, @Result(column = "project_class_name", property = "projectClassName"),
one = @One(select = "cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper.findClassNameById")) @Result(column = "is_completed", property = "IsCompleted"),
@Result(column = "is_deleted", property = "IsDeleted"),
@Result(column = "project_close_time", property = "projectCloseTime")
}) })
IPage<ResultProject> findMyProject(IPage<ResultProject> pg, @Param("id") Integer staffId,@Param(Constants.WRAPPER) Wrapper<Project> wrapper); IPage<ResultProject> findMyProject(IPage<ResultProject> pg, @Param("id") Integer staff_id, @Param(Constants.WRAPPER) Wrapper<Project> wrapper);
} }

View File

@ -14,9 +14,7 @@ import java.util.Map;
* @since 2022/6/29 17:08 * @since 2022/6/29 17:08
*/ */
public interface IProjectService extends IService<Project> { public interface IProjectService extends IService<Project> {
IPage<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;
Long getProjectTotalNum(String token) throws TokenException;
Boolean setProjectCompleted(String token, Project project) throws TokenException; Boolean setProjectCompleted(String token, Project project) throws TokenException;

View File

@ -11,6 +11,7 @@ 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 org.springframework.stereotype.Service;
import java.util.Map; import java.util.Map;
@ -18,30 +19,20 @@ import java.util.Map;
* @author * @author
* @since 2022/6/29 19:36 * @since 2022/6/29 19:36
*/ */
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService { public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
@Override @Override
public IPage<ResultProject> getOnePageProject( public Page<ResultProject> getOnePageProject(
String token, String token,
Integer pageCurrent, Integer pageCurrent,
Integer pageSize, Integer pageSize,
Map<String, Object> params Map<String, Object> params
) throws TokenException { ) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token); Integer staffId = 2;
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
return baseMapper.findMyProject(new Page<>(pageCurrent, pageSize), staffId, baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
//TODO: 应该要改成调用WrapperUtils.allEqAndTimeIntervalQueryWrapper方法 return (Page<ResultProject>) page;
Wrappers.<Project>query()
.allEq(WrapperUtils.getMapWithoutTime(params))
//.lambda()
//.between(params.get("projectStartTimeStart")!=null,Project::getProjectStartTime,)
);
}
@Override
public Long getProjectTotalNum(String token) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token);
return baseMapper.getProjectTotalNum(staffId);
} }
@Override @Override