项目列表操作
parent
912bf97e3f
commit
5fcfe0a5bd
|
@ -1,7 +1,19 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||
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 佘语殊
|
||||
|
@ -11,4 +23,19 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RequestMapping("/project")
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Project {
|
|||
private String projectArea;
|
||||
private String projectCompany;
|
||||
private String projectDescription;
|
||||
private Boolean completed;
|
||||
private Boolean IsCompleted;
|
||||
@TableLogic
|
||||
private Boolean deleted;
|
||||
private Integer projectCreator;
|
||||
|
|
|
@ -6,6 +6,8 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author 阳勇权
|
||||
* @since 2022/6/29 20:45
|
||||
|
@ -19,6 +21,9 @@ public class ResultProject {
|
|||
Long contractAmount;
|
||||
String projectImportance;
|
||||
String projectClassName;
|
||||
String projectSubClassName;
|
||||
String projectSubclassName;
|
||||
Boolean IsDeleted;
|
||||
Boolean IsCompleted;
|
||||
LocalDate projectCloseTime;
|
||||
// 带加的进度 Double projectProcess;
|
||||
}
|
||||
|
|
|
@ -17,26 +17,34 @@ import java.util.List;
|
|||
* @since 2022/6/29 17:07
|
||||
*/
|
||||
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 * FROM project WHERE project_id IN
|
||||
(SELECT DISTINCT project_id FROM project_group)
|
||||
${ew.customSqlSegment};
|
||||
SELECT * FROM
|
||||
(SELECT project_id,
|
||||
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({
|
||||
@Result(column = "project_id", property = "projectId", id = true),
|
||||
@Result(column = "project_name", property = "projectName"),
|
||||
@Result(column = "contract_amount", property = "contractAmount"),
|
||||
@Result(column = "project_importance", property = "projectImportance"),
|
||||
@Result(column = "{id = project_class_id}", property = "projectClassName", javaType = String.class,
|
||||
one = @One(select = "cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper.findClassNameById")),
|
||||
@Result(column = "{id = project_subclass_id}", property = "projectSubClassName", javaType = String.class,
|
||||
one = @One(select = "cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper.findClassNameById"))
|
||||
@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 = "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);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ import java.util.Map;
|
|||
* @since 2022/6/29 17:08
|
||||
*/
|
||||
public interface IProjectService extends IService<Project> {
|
||||
IPage<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
||||
|
||||
Long getProjectTotalNum(String token) throws TokenException;
|
||||
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
||||
|
||||
Boolean setProjectCompleted(String token, Project project) throws TokenException;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ 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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -18,30 +19,20 @@ import java.util.Map;
|
|||
* @author 阳勇权
|
||||
* @since 2022/6/29 19:36
|
||||
*/
|
||||
@Service
|
||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||
|
||||
@Override
|
||||
public IPage<ResultProject> getOnePageProject(
|
||||
public Page<ResultProject> getOnePageProject(
|
||||
String token,
|
||||
Integer pageCurrent,
|
||||
Integer pageSize,
|
||||
Map<String, Object> params
|
||||
) throws TokenException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
|
||||
return baseMapper.findMyProject(new Page<>(pageCurrent, pageSize), staffId,
|
||||
//TODO: 应该要改成调用WrapperUtils.allEqAndTimeIntervalQueryWrapper方法
|
||||
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);
|
||||
Integer staffId = 2;
|
||||
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
|
||||
baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
|
||||
return (Page<ResultProject>) page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue