新增以及更改了部分与全局权限有关的代码(未完成|未测试),规范了部分代码(未完成)
parent
2ed153ca93
commit
a7c55ae318
|
@ -13,5 +13,5 @@ import java.lang.annotation.*;
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Target({ElementType.FIELD})
|
@Target({ElementType.FIELD})
|
||||||
public @interface DoNotDeserialize {
|
public @interface DoNotSerialize {
|
||||||
}
|
}
|
|
@ -1,11 +1,12 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IAnnouncementService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IAnnouncementService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
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.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
|
@ -29,9 +30,9 @@ public class AnnouncementController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseList<AnnouncementDto> getAnnouncementList(@RequestHeader("Token") String token, @PathVariable Integer projectId) {
|
public ResponseList<AnnouncementDTO> getAnnouncementList(@RequestHeader("Token") String token, @PathVariable Integer projectId) {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
return ResponseList.ofSuccess("查询成功", announcementService.getAnnouncementList(projectId));
|
return ResponseList.ofSuccess("查询成功", announcementService.getAnnouncementList(projectId));
|
||||||
}
|
}
|
||||||
|
@ -44,7 +45,7 @@ public class AnnouncementController {
|
||||||
@PathVariable Long announcementId
|
@PathVariable Long announcementId
|
||||||
) {
|
) {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
return ResponseMap.ofSuccess("查询成功", announcementService.getAnnouncementById(announcementId));
|
return ResponseMap.ofSuccess("查询成功", announcementService.getAnnouncementById(announcementId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
|
@ -34,13 +34,13 @@ public class ProjectController {
|
||||||
@Operation(summary = "根据Token获取该员工的ProjectList")
|
@Operation(summary = "根据Token获取该员工的ProjectList")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseList<ProjectDto> getProjectListOfStaff(
|
public ResponseList<ProjectDTO> getProjectListOfStaff(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@Valid RequestPage page,
|
@Valid RequestPage page,
|
||||||
@Parameter(description = "参数列表见Project实体类,时间可以用xxxxStart与xxxxEnd来确定区间"
|
@Parameter(description = "参数列表见Project实体类,时间可以用xxxxStart与xxxxEnd来确定区间"
|
||||||
, required = true) @RequestParam("paramMap") Map<String, Object> paramMap
|
, required = true) @RequestParam("paramMap") Map<String, Object> paramMap
|
||||||
) {
|
) {
|
||||||
Page<ProjectDto> result = projectService.getOnePageProject(token, page, paramMap);
|
Page<ProjectDTO> result = projectService.getOnePageProject(token, page, paramMap);
|
||||||
return ResponseList.ofSuccess("成功返回列表", result);
|
return ResponseList.ofSuccess("成功返回列表", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class ProjectController {
|
||||||
@GetMapping("/count")
|
@GetMapping("/count")
|
||||||
public ResponseMap getProjectNumOfStaff(@RequestHeader("Token") String token) {
|
public ResponseMap getProjectNumOfStaff(@RequestHeader("Token") String token) {
|
||||||
return ResponseMap.ofSuccess("查询成功")
|
return ResponseMap.ofSuccess("查询成功")
|
||||||
.put("totalNum", projectService.getAllProjectOfStaff(token));
|
.put("totalNum", projectService.countMyProjects(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVo;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
|
@ -40,13 +40,13 @@ public class ProjectGroupController {
|
||||||
@Operation(description = "传入合法page参数时分页查询,否则拉取整个列表")
|
@Operation(description = "传入合法page参数时分页查询,否则拉取整个列表")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseList<ProjectGroupDto> getGroupMembers(
|
public ResponseList<ProjectGroupDTO> getGroupMembers(
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
RequestPage page
|
RequestPage page
|
||||||
) {
|
) {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (validateUtils.validate(page).isEmpty()) {
|
if (validateUtils.validate(page).isEmpty()) {
|
||||||
return ResponseList.ofSuccess("查询成功", projectGroupService.pageProjectMembers(page, projectId));
|
return ResponseList.ofSuccess("查询成功", projectGroupService.pageProjectMembers(page, projectId));
|
||||||
|
@ -63,7 +63,7 @@ public class ProjectGroupController {
|
||||||
@PathVariable Integer staffId
|
@PathVariable Integer staffId
|
||||||
) {
|
) {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
return ResponseMap.ofSuccess("查询成功", projectGroupService.getOne(
|
return ResponseMap.ofSuccess("查询成功", projectGroupService.getOne(
|
||||||
Wrappers.<ProjectGroup>lambdaQuery()
|
Wrappers.<ProjectGroup>lambdaQuery()
|
||||||
|
@ -78,7 +78,7 @@ public class ProjectGroupController {
|
||||||
public ResponseMap addGroupMember(
|
public ResponseMap addGroupMember(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@RequestBody GroupPositionVo groupPosition
|
@RequestBody GroupPositionVO groupPosition
|
||||||
) {
|
) {
|
||||||
projectGroupService.insertNewMember(token, projectId, groupPosition.getStaffId(), groupPosition.getPositions());
|
projectGroupService.insertNewMember(token, projectId, groupPosition.getStaffId(), groupPosition.getPositions());
|
||||||
return ResponseMap.ofSuccess("创建成功");
|
return ResponseMap.ofSuccess("创建成功");
|
||||||
|
@ -91,7 +91,7 @@ public class ProjectGroupController {
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@PathVariable Integer staffId,
|
@PathVariable Integer staffId,
|
||||||
@Parameter(description = "不需要在body中传递staffId,用path传递") @RequestBody GroupPositionVo groupPosition
|
@Parameter(description = "不需要在body中传递staffId,用path传递") @RequestBody GroupPositionVO groupPosition
|
||||||
) {
|
) {
|
||||||
projectGroupService.updateStaffPositions(token, staffId, projectId, groupPosition.getPositions());
|
projectGroupService.updateStaffPositions(token, staffId, projectId, groupPosition.getPositions());
|
||||||
return ResponseMap.ofSuccess("更新成功");
|
return ResponseMap.ofSuccess("更新成功");
|
||||||
|
@ -108,7 +108,7 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping("/{staffId}/stats")
|
@GetMapping("/{staffId}/stats")
|
||||||
public ResponseList<StaffProcessDto> getProjectProcessOfStaff(
|
public ResponseList<StaffProcessDTO> getProjectProcessOfStaff(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@PathVariable Integer staffId
|
@PathVariable Integer staffId
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
||||||
|
@ -26,12 +26,12 @@ public class TaskController {
|
||||||
private IProjectService projectService;
|
private IProjectService projectService;
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping("/{fatherId}/subtask")
|
@GetMapping("/{fatherId}/subtask")
|
||||||
public ResponseList<TaskDto> getSubTaskList(
|
public ResponseList<TaskDTO> getSubTaskList(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable("projectId") Integer projectId,
|
@PathVariable("projectId") Integer projectId,
|
||||||
@PathVariable("fatherId") Long fatherId
|
@PathVariable("fatherId") Long fatherId
|
||||||
) {
|
) {
|
||||||
List<TaskDto> result = taskService.getSubTaskList(token, projectId, fatherId);
|
List<TaskDTO> result = taskService.getSubTaskList(token, projectId, fatherId);
|
||||||
return ResponseList.ofSuccess("查询成功", result);
|
return ResponseList.ofSuccess("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
||||||
|
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.DoNotSerialize;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -13,9 +14,11 @@ public class Staff {
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Integer staffId;
|
private Integer staffId;
|
||||||
private String staffUsername;
|
private String staffUsername;
|
||||||
private String staffPassword;
|
|
||||||
private String staffFullname;
|
private String staffFullname;
|
||||||
private String staffGender;
|
private String staffGender;
|
||||||
|
@DoNotSerialize
|
||||||
|
private String staffPassword;
|
||||||
|
@DoNotSerialize
|
||||||
private String staffSalt;
|
private String staffSalt;
|
||||||
private Integer staffLevel;
|
private Integer staffGlobalLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.time.LocalDateTime;
|
||||||
* @since 2022/7/7 11:33
|
* @since 2022/7/7 11:33
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class AnnouncementDto {
|
public class AnnouncementDTO {
|
||||||
private Long announcementId;
|
private Long announcementId;
|
||||||
private Integer announcementPublisherId;
|
private Integer announcementPublisherId;
|
||||||
private String announcementPublisherName;
|
private String announcementPublisherName;
|
|
@ -14,7 +14,7 @@ import java.time.LocalDate;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ProjectDto {
|
public class ProjectDTO {
|
||||||
@TableId
|
@TableId
|
||||||
Integer projectId;
|
Integer projectId;
|
||||||
String projectName;
|
String projectName;
|
|
@ -8,7 +8,7 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ProjectGroupDto {
|
public class ProjectGroupDTO {
|
||||||
Integer staffId;
|
Integer staffId;
|
||||||
String staffUsername;
|
String staffUsername;
|
||||||
String staffFullname;
|
String staffFullname;
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
||||||
* @since 2022/7/7 11:42
|
* @since 2022/7/7 11:42
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ProjectProcessDto {
|
public class ProjectProcessDTO {
|
||||||
Integer projectId;
|
Integer projectId;
|
||||||
Long completeNum;
|
Long completeNum;
|
||||||
Long totalNum;
|
Long totalNum;
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
||||||
* @since 2022/7/7 10:28
|
* @since 2022/7/7 10:28
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class StaffProcessDto {
|
public class StaffProcessDTO {
|
||||||
String taskType;
|
String taskType;
|
||||||
Long completeNum;
|
Long completeNum;
|
||||||
Long totalNum;
|
Long totalNum;
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||||
* @since 2022/7/6 10:25
|
* @since 2022/7/6 10:25
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class TaskDto {
|
public class TaskDTO {
|
||||||
private Long taskId;
|
private Long taskId;
|
||||||
private String taskName;
|
private String taskName;
|
||||||
private Integer taskProjectId;
|
private Integer taskProjectId;
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
||||||
* @since 2022/7/7 0:27
|
* @since 2022/7/7 0:27
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class GroupPositionVo {
|
public class GroupPositionVO {
|
||||||
private Integer staffId;
|
private Integer staffId;
|
||||||
private String positions;
|
private String positions;
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||||
* @since 2022/7/7 11:26
|
* @since 2022/7/7 11:26
|
||||||
*/
|
*/
|
||||||
public interface AnnouncementMapper extends BaseMapper<Announcement> {
|
public interface AnnouncementMapper extends BaseMapper<Announcement> {
|
||||||
List<AnnouncementDto> selectAnnouncementList(@Param("projectId") Integer projectId);
|
List<AnnouncementDTO> selectAnnouncementList(@Param("projectId") Integer projectId);
|
||||||
|
|
||||||
AnnouncementDto selectAnnouncementById(@Param("announcementId") Long announcementId);
|
AnnouncementDTO selectAnnouncementById(@Param("announcementId") Long announcementId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDTO;
|
||||||
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.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -21,12 +21,12 @@ public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
|
||||||
FROM project_group inner join staff
|
FROM project_group inner join staff
|
||||||
ON project_group.staff_id = staff.staff_id AND project_group.project_id = #{projectId}
|
ON project_group.staff_id = staff.staff_id AND project_group.project_id = #{projectId}
|
||||||
""")
|
""")
|
||||||
Page<ProjectGroupDto> selectMembersByPage(IPage<ProjectDto> pg, @Param("projectId") Integer projectId);
|
Page<ProjectGroupDTO> selectMembersByPage(IPage<ProjectDTO> pg, @Param("projectId") Integer projectId);
|
||||||
|
|
||||||
@Select("""
|
@Select("""
|
||||||
SELECT staff.staff_id, staff_username, staff_fullname, project_staff_position, project_access_level
|
SELECT staff.staff_id, staff_username, staff_fullname, project_staff_position, project_access_level
|
||||||
FROM project_group inner join staff
|
FROM project_group inner join staff
|
||||||
ON project_group.staff_id = staff.staff_id AND project_group.project_id = #{projectId}
|
ON project_group.staff_id = staff.staff_id AND project_group.project_id = #{projectId}
|
||||||
""")
|
""")
|
||||||
List<ProjectGroupDto> selectMembersByList(@Param("projectId") Integer projectId);
|
List<ProjectGroupDTO> selectMembersByList(@Param("projectId") Integer projectId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
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.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDTO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
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 io.swagger.v3.oas.models.security.SecurityScheme;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
@ -18,12 +17,11 @@ import org.apache.ibatis.annotations.Select;
|
||||||
public interface ProjectMapper extends BaseMapper<Project> {
|
public interface ProjectMapper extends BaseMapper<Project> {
|
||||||
|
|
||||||
@Select("""
|
@Select("""
|
||||||
SELECT COUNT(*) FROM project WHERE project_id IN
|
SELECT COUNT(project_id) FROM project_group WHERE staff_id = #{staffId};
|
||||||
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{staffId})
|
|
||||||
""")
|
""")
|
||||||
Long findProjectCount(@Param("staffId") Integer staffId);
|
Long selectMyProjectCount(@Param("staffId") Integer staffId);
|
||||||
|
|
||||||
ProjectProcessDto findProjectProcess(@Param("projectId") Integer projectId);
|
ProjectProcessDTO selectProjectProcess(@Param("projectId") Integer projectId);
|
||||||
|
|
||||||
IPage<ProjectDto> findMyProject(IPage<ProjectDto> pg, @Param("staffId") Integer staff_id, @Param(Constants.WRAPPER) Wrapper<Project> wrapper);
|
IPage<ProjectDTO> selectMyProject(IPage<ProjectDTO> pg, @Param("staffId") Integer staff_id, @Param(Constants.WRAPPER) Wrapper<Project> wrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
* created at 2022/7/4 14:52
|
* created at 2022/7/4 14:52
|
||||||
*/
|
*/
|
||||||
public interface TaskMapper extends BaseMapper<Task> {
|
public interface TaskMapper extends BaseMapper<Task> {
|
||||||
List<TaskDto> selectSubTaskList(@Param("projectId") Integer projectId, @Param("fatherId") Long fatherId);
|
List<TaskDTO> selectSubTaskList(@Param("projectId") Integer projectId, @Param("fatherId") Long fatherId);
|
||||||
|
|
||||||
List<StaffProcessDto> selectProjectProcessOfStaff(@Param("projectId") Integer projectId, @Param("staffId") Integer staffId);
|
List<StaffProcessDTO> selectProjectProcessOfStaff(@Param("projectId") Integer projectId, @Param("staffId") Integer staffId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -14,9 +14,9 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface IAnnouncementService extends IService<Announcement> {
|
public interface IAnnouncementService extends IService<Announcement> {
|
||||||
|
|
||||||
List<AnnouncementDto> getAnnouncementList(Integer projectId);
|
List<AnnouncementDTO> getAnnouncementList(Integer projectId);
|
||||||
|
|
||||||
AnnouncementDto getAnnouncementById(Long announcementId);
|
AnnouncementDTO getAnnouncementById(Long announcementId);
|
||||||
|
|
||||||
Boolean updateAnnouncement(String token, Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException;
|
Boolean updateAnnouncement(String token, Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -15,6 +15,12 @@ import java.util.Map;
|
||||||
* 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> {
|
||||||
|
|
||||||
|
String UNABLE_TO_ACCESS = "无该项目访问权限";
|
||||||
|
|
||||||
|
String POSITION_1 = "项目经理";
|
||||||
|
String POSITION_2 = "项目主管";
|
||||||
|
|
||||||
Boolean addCreator(Integer projectId, Integer staffId);
|
Boolean addCreator(Integer projectId, Integer staffId);
|
||||||
|
|
||||||
void insertNewMember(String token, Integer projectId, Integer staffId, String positions) throws ForbiddenException;
|
void insertNewMember(String token, Integer projectId, Integer staffId, String positions) throws ForbiddenException;
|
||||||
|
@ -22,11 +28,16 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
|
||||||
void updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException;
|
void updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 如果不存在就返回0,否则返回AccessLevel
|
* @return 如果不存在就返回0,否则返回AccessLevel;对于全局权限为1的用户,直接返回1
|
||||||
*/
|
*/
|
||||||
Integer getProjectAccessLevel(String token, Integer projectId);
|
Integer getProjectAccessLevel(String token, Integer projectId);
|
||||||
|
|
||||||
Integer getProjectAccessLevel(Integer staffId, Integer projectId);
|
Integer getProjectAccessLevel(Integer staffId, Integer staffGlobalLevel, Integer projectId);
|
||||||
|
|
||||||
|
|
||||||
|
Integer getProjectAccessLevelIgnoreGlobalLevel(String token, Integer projectId);
|
||||||
|
|
||||||
|
Integer getProjectAccessLevelIgnoreGlobalLevel(Integer staffId, Integer projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比较token持有者与目标id在项目中的权限等级大小关系,一般用于当token持有者对目标id的某条目做危险操作时判断用
|
* 比较token持有者与目标id在项目中的权限等级大小关系,一般用于当token持有者对目标id的某条目做危险操作时判断用
|
||||||
|
@ -37,9 +48,9 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
|
||||||
*/
|
*/
|
||||||
Integer compareProjectAccessLevel(Integer projectId, String token, Integer targetId);
|
Integer compareProjectAccessLevel(Integer projectId, String token, Integer targetId);
|
||||||
|
|
||||||
Page<ProjectGroupDto> pageProjectMembers(RequestPage page, Integer projectId);
|
Page<ProjectGroupDTO> pageProjectMembers(RequestPage page, Integer projectId);
|
||||||
|
|
||||||
List<ProjectGroupDto> listProjectMembers(Integer projectId);
|
List<ProjectGroupDTO> listProjectMembers(Integer projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计小组中各岗位数量
|
* 统计小组中各岗位数量
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
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.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
|
@ -17,17 +17,17 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface IProjectService extends IService<Project> {
|
public interface IProjectService extends IService<Project> {
|
||||||
|
|
||||||
Long getAllProjectOfStaff(String token);
|
Long countMyProjects(String token);
|
||||||
|
|
||||||
ProjectProcessDto getProjectProcess(String token, Integer projectId) throws ForbiddenException;
|
ProjectProcessDTO getProjectProcess(String token, Integer projectId) throws ForbiddenException, BadRequestException;
|
||||||
|
|
||||||
Page<ProjectDto> getOnePageProject(String token, RequestPage page, Map<String, Object> params);
|
Page<ProjectDTO> getOnePageProject(String token, RequestPage page, Map<String, Object> params);
|
||||||
|
|
||||||
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException;
|
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException;
|
||||||
|
|
||||||
Boolean createProject(String token, Project project) throws BadRequestException;
|
Boolean createProject(String token, Project project) throws BadRequestException, ForbiddenException;
|
||||||
|
|
||||||
Boolean checkOpenStatus(Integer projectId);
|
Boolean checkOpenStatus(Integer projectId);
|
||||||
|
|
||||||
Boolean updateProject(String token, Project project) throws BadRequestException;
|
Boolean updateProject(String token, Project project) throws BadRequestException, ForbiddenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -16,5 +17,5 @@ public interface IStaffService extends IService<Staff> {
|
||||||
|
|
||||||
Boolean logout(String token) throws TokenException;
|
Boolean logout(String token) throws TokenException;
|
||||||
|
|
||||||
Integer multiImport(String token, MultipartFile file) throws BadRequestException;
|
Integer multiImport(String token, MultipartFile file) throws BadRequestException, ForbiddenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||||
* created at 2022/7/4 14:49
|
* created at 2022/7/4 14:49
|
||||||
*/
|
*/
|
||||||
public interface ITaskService extends IService<Task> {
|
public interface ITaskService extends IService<Task> {
|
||||||
List<TaskDto> getSubTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException, ForbiddenException;
|
List<TaskDTO> getSubTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException, ForbiddenException;
|
||||||
|
|
||||||
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException;
|
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException;
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ public interface ITaskService extends IService<Task> {
|
||||||
|
|
||||||
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||||
|
|
||||||
List<StaffProcessDto> getProjectProcessOfStaff(String token, Integer projectId) throws BadRequestException, ForbiddenException;
|
List<StaffProcessDTO> getProjectProcessOfStaff(String token, Integer projectId) throws BadRequestException, ForbiddenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 1:all rights 2:father holder 3:current holder 0:no right
|
* @return 1:all rights 2:father holder 3:current holder 0:no right
|
||||||
*/
|
*/
|
||||||
Integer getHolderLevel(Integer staffId, Long taskId);
|
Integer getHolderLevel(Integer staffId, Integer staffGlobalLevel, Long taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 1:all rights 2:father holder 3:current holder 0:no right
|
* @return 1:all rights 2:father holder 3:current holder 0:no right
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.AnnouncementMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.AnnouncementMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IAnnouncementService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IAnnouncementService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
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;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -27,21 +27,20 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
|
||||||
private IProjectGroupService projectGroupService;
|
private IProjectGroupService projectGroupService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AnnouncementDto> getAnnouncementList(Integer projectId) {
|
public List<AnnouncementDTO> getAnnouncementList(Integer projectId) {
|
||||||
return baseMapper.selectAnnouncementList(projectId);
|
return baseMapper.selectAnnouncementList(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnouncementDto getAnnouncementById(Long announcementId) {
|
public AnnouncementDTO getAnnouncementById(Long announcementId) {
|
||||||
return baseMapper.selectAnnouncementById(announcementId);
|
return baseMapper.selectAnnouncementById(announcementId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateAnnouncement(String token, Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException {
|
public Boolean updateAnnouncement(String token, Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
|
||||||
Integer accessLevel = projectGroupService.getProjectAccessLevel(staffId, projectId);
|
|
||||||
if (accessLevel == 0) {
|
if (accessLevel == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (accessLevel > 2) {
|
if (accessLevel > 2) {
|
||||||
throw new ForbiddenException("无权修改该公告");
|
throw new ForbiddenException("无权修改该公告");
|
||||||
|
@ -58,10 +57,9 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteAnnouncement(String token, Integer projectId, Long announcementId) throws ForbiddenException, BadRequestException {
|
public Boolean deleteAnnouncement(String token, Integer projectId, Long announcementId) throws ForbiddenException, BadRequestException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
|
||||||
Integer accessLevel = projectGroupService.getProjectAccessLevel(staffId, projectId);
|
|
||||||
if (accessLevel == 0) {
|
if (accessLevel == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (accessLevel > 2) {
|
if (accessLevel > 2) {
|
||||||
throw new ForbiddenException("无权修改该公告");
|
throw new ForbiddenException("无权修改该公告");
|
||||||
|
|
|
@ -1,10 +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.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
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.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
@ -29,7 +30,7 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
ProjectGroup projectGroup = new ProjectGroup();
|
ProjectGroup projectGroup = new ProjectGroup();
|
||||||
projectGroup.setProjectId(projectId);
|
projectGroup.setProjectId(projectId);
|
||||||
projectGroup.setStaffId(staffId);
|
projectGroup.setStaffId(staffId);
|
||||||
projectGroup.setProjectStaffPosition("项目经理");
|
projectGroup.setProjectStaffPosition(POSITION_1);
|
||||||
projectGroup.setProjectAccessLevel(1);
|
projectGroup.setProjectAccessLevel(1);
|
||||||
return baseMapper.insert(projectGroup) == 1;
|
return baseMapper.insert(projectGroup) == 1;
|
||||||
}
|
}
|
||||||
|
@ -40,17 +41,17 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
int targetLevel = 3;
|
int targetLevel = 3;
|
||||||
|
|
||||||
if (accessLevel == 0) {
|
if (accessLevel == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (accessLevel > 2) {
|
if (accessLevel > 2) {
|
||||||
throw new ForbiddenException("无新增成员权限");
|
throw new ForbiddenException("无新增成员权限");
|
||||||
}
|
}
|
||||||
String[] positionArray = positions.split(",");
|
String[] positionArray = positions.split(",");
|
||||||
for (String position : positionArray) {
|
for (String position : positionArray) {
|
||||||
if (position.equals("项目经理")) {
|
if (position.equals(POSITION_1)) {
|
||||||
throw new ForbiddenException("不能授予他人项目经理职位");
|
throw new ForbiddenException("不能授予他人项目经理职位");
|
||||||
}
|
}
|
||||||
if (position.equals("项目主管")) {
|
if (position.equals(POSITION_2)) {
|
||||||
if (accessLevel != 1) {
|
if (accessLevel != 1) {
|
||||||
throw new ForbiddenException("无授予项目主管职位权限");
|
throw new ForbiddenException("无授予项目主管职位权限");
|
||||||
}
|
}
|
||||||
|
@ -64,20 +65,20 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
@Override
|
@Override
|
||||||
public void updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException {
|
public void updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException {
|
||||||
int accessLevel = getProjectAccessLevel(token, projectId);
|
int accessLevel = getProjectAccessLevel(token, projectId);
|
||||||
int targetLevel = getProjectAccessLevel(targetId, projectId);
|
int targetLevel = getProjectAccessLevel(targetId, 2, projectId); //假定目标的全局level为2,防止get时出现问题
|
||||||
|
|
||||||
if (accessLevel == 0) {
|
if (accessLevel == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (accessLevel > 2 || accessLevel >= targetLevel) {
|
if (accessLevel > 2 || accessLevel >= targetLevel) {
|
||||||
throw new ForbiddenException("无更改此人职位权限");
|
throw new ForbiddenException("无更改此人职位权限");
|
||||||
}
|
}
|
||||||
String[] positionArray = positions.split(",");
|
String[] positionArray = positions.split(",");
|
||||||
for (String position : positionArray) {
|
for (String position : positionArray) {
|
||||||
if (position.equals("项目经理")) {
|
if (position.equals(POSITION_1)) {
|
||||||
throw new ForbiddenException("不能授予他人项目经理职位");
|
throw new ForbiddenException("不能授予他人项目经理职位");
|
||||||
}
|
}
|
||||||
if (position.equals("项目主管") && accessLevel != 1) {
|
if (position.equals(POSITION_2) && accessLevel != 1) {
|
||||||
throw new ForbiddenException("无授予项目主管职位权限");
|
throw new ForbiddenException("无授予项目主管职位权限");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,13 +95,30 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
@Override
|
@Override
|
||||||
public Integer getProjectAccessLevel(String token, Integer projectId) {
|
public Integer getProjectAccessLevel(String token, Integer projectId) {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
return getProjectAccessLevel(staffId, projectId);
|
Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
|
||||||
|
return getProjectAccessLevel(staffId, staffGlobalLevel, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getProjectAccessLevel(Integer staffId, Integer projectId) {
|
public Integer getProjectAccessLevel(Integer staffId, Integer staffGlobalLevel, Integer projectId) {
|
||||||
|
//对全局权限做特判
|
||||||
|
if (staffGlobalLevel == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return getProjectAccessLevelIgnoreGlobalLevel(staffId, projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getProjectAccessLevelIgnoreGlobalLevel(String token, Integer projectId) {
|
||||||
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
|
return getProjectAccessLevelIgnoreGlobalLevel(staffId, projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getProjectAccessLevelIgnoreGlobalLevel(Integer staffId, Integer projectId) {
|
||||||
try {
|
try {
|
||||||
ProjectGroup projectGroup = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery()
|
ProjectGroup projectGroup = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery()
|
||||||
|
.select(ProjectGroup::getProjectAccessLevel)
|
||||||
.eq(ProjectGroup::getStaffId, staffId)
|
.eq(ProjectGroup::getStaffId, staffId)
|
||||||
.eq(ProjectGroup::getProjectId, projectId)
|
.eq(ProjectGroup::getProjectId, projectId)
|
||||||
);
|
);
|
||||||
|
@ -114,32 +132,23 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer compareProjectAccessLevel(Integer projectId, String token, Integer targetId) {
|
public Integer compareProjectAccessLevel(Integer projectId, String token, Integer targetId) {
|
||||||
Integer targetLevel = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery()
|
return Integer.compare(getProjectAccessLevel(token, projectId), getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId));
|
||||||
.select(ProjectGroup::getProjectAccessLevel)
|
|
||||||
.eq(ProjectGroup::getStaffId, targetId)
|
|
||||||
.eq(ProjectGroup::getProjectId, projectId)
|
|
||||||
).getProjectAccessLevel();
|
|
||||||
|
|
||||||
if (targetLevel == null) {
|
|
||||||
targetLevel = 0;
|
|
||||||
}
|
|
||||||
return Integer.compare(getProjectAccessLevel(token, projectId), targetLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectGroupDto> pageProjectMembers(RequestPage page, Integer projectId) {
|
public Page<ProjectGroupDTO> pageProjectMembers(RequestPage page, Integer projectId) {
|
||||||
return baseMapper.selectMembersByPage(page.getPage(), projectId);
|
return baseMapper.selectMembersByPage(page.getPage(), projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProjectGroupDto> listProjectMembers(Integer projectId) {
|
public List<ProjectGroupDTO> listProjectMembers(Integer projectId) {
|
||||||
return baseMapper.selectMembersByList(projectId);
|
return baseMapper.selectMembersByList(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Integer> collectStatsForGroupPositions(String token, Integer projectId) throws ForbiddenException {
|
public Map<String, Integer> collectStatsForGroupPositions(String token, Integer projectId) throws ForbiddenException {
|
||||||
if (getProjectAccessLevel(token, projectId) == 0) {
|
if (getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
Map<String, Integer> res = new HashMap<>();
|
Map<String, Integer> res = new HashMap<>();
|
||||||
List<ProjectGroup> infos = baseMapper.selectList(
|
List<ProjectGroup> infos = baseMapper.selectList(
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
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.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||||
|
@ -12,7 +12,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -29,32 +28,36 @@ 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 IProjectGroupService projectGroupService;
|
private IProjectGroupService projectGroupService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getAllProjectOfStaff(String token) {
|
public Long countMyProjects(String token) {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
return baseMapper.findProjectCount(staffId);
|
return baseMapper.selectMyProjectCount(staffId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectProcessDto getProjectProcess(String token, Integer projectId) throws ForbiddenException {
|
public ProjectProcessDTO getProjectProcess(String token, Integer projectId) throws ForbiddenException, BadRequestException {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无查看权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
return baseMapper.findProjectProcess(projectId);
|
if (Objects.equals(projectId, 0)) {
|
||||||
|
throw new BadRequestException("参数非法");
|
||||||
|
}
|
||||||
|
return baseMapper.selectProjectProcess(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectDto> getOnePageProject(
|
public Page<ProjectDTO> getOnePageProject(
|
||||||
String token,
|
String token,
|
||||||
RequestPage page,
|
RequestPage page,
|
||||||
Map<String, Object> params
|
Map<String, Object> params
|
||||||
) {
|
) {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
IPage<ProjectDto> userPage = baseMapper.findMyProject(page.getPage(), staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params));
|
IPage<ProjectDTO> userPage = baseMapper.selectMyProject(page.getPage(), staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params));
|
||||||
return (Page<ProjectDto>) userPage;
|
return (Page<ProjectDTO>) userPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,7 +69,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
if (targetProject == null)
|
if (targetProject == null)
|
||||||
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.getCompleted())
|
if (targetProject.getCompleted())
|
||||||
throw new BadRequestException("该项目已结项");
|
throw new BadRequestException("该项目已结项");
|
||||||
targetProject.setCompleted(true);
|
targetProject.setCompleted(true);
|
||||||
|
@ -76,9 +79,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
throw new BadRequestException("操作失败");
|
throw new BadRequestException("操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: 时间线判断?
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean createProject(String token, Project project) throws BadRequestException {
|
public Boolean createProject(String token, Project project) throws BadRequestException, ForbiddenException {
|
||||||
|
Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
|
||||||
|
if (staffGlobalLevel == 0 || staffGlobalLevel > 2) {
|
||||||
|
throw new ForbiddenException("无该操作权限");
|
||||||
|
}
|
||||||
project.setProjectId(null);
|
project.setProjectId(null);
|
||||||
project.setCompleted(false);
|
project.setCompleted(false);
|
||||||
project.setProjectCreatedTime(null);
|
project.setProjectCreatedTime(null);
|
||||||
|
@ -111,10 +117,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
return project != null && !project.getCompleted();
|
return project != null && !project.getCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean updateProject(String token, Project project) throws BadRequestException {
|
public Boolean updateProject(String token, Project project) throws BadRequestException, ForbiddenException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
if (!staffId.equals(project.getProjectCreator())) {
|
if (!staffId.equals(project.getProjectCreator()) && TokenUtils.getStaffGlobalLevel(token) != 1) {
|
||||||
throw new BadRequestException("无权操作");
|
throw new ForbiddenException("无该操作权限");
|
||||||
}
|
}
|
||||||
Project rawProject = baseMapper.selectById(project.getProjectId());
|
Project rawProject = baseMapper.selectById(project.getProjectId());
|
||||||
if (!project.checkModification(rawProject)) {
|
if (!project.checkModification(rawProject)) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
||||||
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.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.StaffMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.StaffMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
|
@ -10,12 +10,8 @@ import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
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;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.jetbrains.annotations.Contract;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -40,7 +36,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
private RedisTemplate<Object, Object> redisTemplate;
|
private RedisTemplate<Object, Object> redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseMap login(String staffUsername, String password) throws BadRequestException, TokenException {
|
public ResponseMap login(String staffUsername, String password) throws BadRequestException {
|
||||||
if (staffUsername == null || staffUsername.trim().length() == 0)
|
if (staffUsername == null || staffUsername.trim().length() == 0)
|
||||||
throw new BadRequestException("用户名为空");
|
throw new BadRequestException("用户名为空");
|
||||||
else if (!staffUsername.equals(staffUsername.replaceAll("[^a-zA-Z0-9]", "")))
|
else if (!staffUsername.equals(staffUsername.replaceAll("[^a-zA-Z0-9]", "")))
|
||||||
|
@ -54,21 +50,18 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
password = DigestUtils.md5DigestAsHex((password + staff.getStaffSalt()).getBytes());
|
password = DigestUtils.md5DigestAsHex((password + staff.getStaffSalt()).getBytes());
|
||||||
if (!staff.getStaffPassword().equals(password))
|
if (!staff.getStaffPassword().equals(password))
|
||||||
throw new BadRequestException("密码错误");
|
throw new BadRequestException("密码错误");
|
||||||
String token = TokenUtils.getToken(staff.getStaffUsername(), staff.getStaffId(), tokenDuration);
|
String token = TokenUtils.getToken(staff.getStaffUsername(), staff.getStaffId(), staff.getStaffGlobalLevel(), tokenDuration);
|
||||||
redisTemplate.opsForValue().set(
|
redisTemplate.opsForValue().set(
|
||||||
Objects.<Integer>requireNonNull(TokenUtils.getStaffId(token)),
|
Objects.<Integer>requireNonNull(TokenUtils.getStaffId(token)),
|
||||||
token,
|
token,
|
||||||
Objects.requireNonNull(TokenUtils.getDuration(token)), TimeUnit.SECONDS
|
Objects.requireNonNull(TokenUtils.getDuration(token)), TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
return ResponseMap.ofSuccess("ok")
|
return ResponseMap.ofSuccess("ok", staff)
|
||||||
.put("Token", token)
|
.put("Token", token);
|
||||||
.put("staffUsername", staffUsername)
|
|
||||||
.put("staffFullname", staff.getStaffFullname())
|
|
||||||
.put("staffId", staff.getStaffId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean logout(String token) throws TokenException {
|
public Boolean logout(String token) {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
if (staffId == null)
|
if (staffId == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -81,8 +74,11 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
|
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Integer multiImport(String token, MultipartFile file) throws BadRequestException {
|
public Integer multiImport(String token, MultipartFile file) throws BadRequestException, ForbiddenException {
|
||||||
//TODO:check Token here
|
//TODO:check Token here
|
||||||
|
if (TokenUtils.getStaffGlobalLevel(token) != 1) {
|
||||||
|
throw new ForbiddenException("无该操作权限");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
XSSFWorkbook xwb = new XSSFWorkbook(file.getInputStream());
|
XSSFWorkbook xwb = new XSSFWorkbook(file.getInputStream());
|
||||||
|
@ -96,7 +92,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
ArrayList<String> staffPasswordC = new ArrayList<>();
|
ArrayList<String> staffPasswordC = new ArrayList<>();
|
||||||
ArrayList<String> staffFullnameC = new ArrayList<>();
|
ArrayList<String> staffFullnameC = new ArrayList<>();
|
||||||
ArrayList<String> staffGenderC = new ArrayList<>();
|
ArrayList<String> staffGenderC = new ArrayList<>();
|
||||||
ArrayList<String> staffLevelC = new ArrayList<>();
|
ArrayList<String> staffGlobalLevelC = new ArrayList<>();
|
||||||
if (!xlsxColumnGetter("staffUsername", 0, staffUsernameC, sheet)) {
|
if (!xlsxColumnGetter("staffUsername", 0, staffUsernameC, sheet)) {
|
||||||
throw new BadRequestException("读取列staffUsername失败");
|
throw new BadRequestException("读取列staffUsername失败");
|
||||||
}
|
}
|
||||||
|
@ -122,14 +118,14 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
throw new BadRequestException("读取列staffGender失败");
|
throw new BadRequestException("读取列staffGender失败");
|
||||||
}
|
}
|
||||||
System.out.println(staffGenderC);
|
System.out.println(staffGenderC);
|
||||||
if (!xlsxColumnGetter("staffLevel", 4, staffLevelC, sheet) ||
|
if (!xlsxColumnGetter("staffGlobalLevel", 4, staffGlobalLevelC, sheet) ||
|
||||||
staffLevelC.size() != totalCount) {
|
staffGlobalLevelC.size() != totalCount) {
|
||||||
throw new BadRequestException("读取列staffLevel失败");
|
throw new BadRequestException("读取列staffGlobalLevel失败");
|
||||||
}
|
}
|
||||||
System.out.println(staffLevelC);
|
System.out.println(staffGlobalLevelC);
|
||||||
for (int i = 0; i < totalCount; i++) {
|
for (int i = 0; i < totalCount; i++) {
|
||||||
if (Integer.parseInt(staffLevelC.get(i)) != 2 && Integer.parseInt(staffLevelC.get(i)) != 3) {
|
if (Integer.parseInt(staffGlobalLevelC.get(i)) != 2 && Integer.parseInt(staffGlobalLevelC.get(i)) != 3) {
|
||||||
throw new BadRequestException("列staffLevel无效");
|
throw new BadRequestException("列staffGlobalLevel无效");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +140,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
staff.setStaffPassword(DigestUtils.md5DigestAsHex((DigestUtils.md5DigestAsHex(staffPasswordC.get(i).getBytes()) + staff.getStaffSalt()).getBytes()));
|
staff.setStaffPassword(DigestUtils.md5DigestAsHex((DigestUtils.md5DigestAsHex(staffPasswordC.get(i).getBytes()) + staff.getStaffSalt()).getBytes()));
|
||||||
staff.setStaffFullname(staffFullnameC.get(i));
|
staff.setStaffFullname(staffFullnameC.get(i));
|
||||||
staff.setStaffGender(staffGenderC.get(i));
|
staff.setStaffGender(staffGenderC.get(i));
|
||||||
staff.setStaffLevel(Integer.parseInt(staffLevelC.get(i)));
|
staff.setStaffGlobalLevel(Integer.parseInt(staffGlobalLevelC.get(i)));
|
||||||
System.out.println(staff);
|
System.out.println(staff);
|
||||||
if (baseMapper.insert(staff) != 1) {
|
if (baseMapper.insert(staff) != 1) {
|
||||||
throw new BadRequestException("第" + (i + 1) + "行数据错误");
|
throw new BadRequestException("第" + (i + 1) + "行数据错误");
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
@ -28,13 +29,12 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
|
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectGroupServiceImpl projectGroupService;
|
private IProjectGroupService projectGroupService;
|
||||||
|
|
||||||
//FIXME: 抛出未授权异常
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> getSubTaskList(String token, Integer projectId, Long fatherId) throws ForbiddenException, BadRequestException {
|
public List<TaskDTO> getSubTaskList(String token, Integer projectId, Long fatherId) throws ForbiddenException, BadRequestException {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (fatherId == null) {
|
if (fatherId == null) {
|
||||||
throw new BadRequestException("请求参数错误");
|
throw new BadRequestException("请求参数错误");
|
||||||
|
@ -45,7 +45,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
@Override
|
@Override
|
||||||
public Boolean existSubTask(String token, Integer projectId, Long taskId) throws ForbiddenException {
|
public Boolean existSubTask(String token, Integer projectId, Long taskId) throws ForbiddenException {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
return baseMapper.exists(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, taskId));
|
return baseMapper.exists(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, taskId));
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException {
|
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException {
|
||||||
Integer level = getHolderLevel(token, taskId);
|
Integer level = getHolderLevel(token, taskId);
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (level == 0 || level == 3) {
|
if (level == 0 || level == 3) {
|
||||||
throw new BadRequestException("错误父级参数");
|
throw new BadRequestException("错误父级参数");
|
||||||
|
@ -82,7 +82,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||||
Integer level = getHolderLevel(token, taskId);
|
Integer level = getHolderLevel(token, taskId);
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new BadRequestException("无该项目访问权限");
|
throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
throw new BadRequestException("父级参数错误");
|
throw new BadRequestException("父级参数错误");
|
||||||
|
@ -114,7 +114,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StaffProcessDto> getProjectProcessOfStaff(String token, Integer projectId) throws BadRequestException, ForbiddenException {
|
public List<StaffProcessDTO> getProjectProcessOfStaff(String token, Integer projectId) throws BadRequestException, ForbiddenException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException("无查看权限");
|
throw new ForbiddenException("无查看权限");
|
||||||
|
@ -123,8 +123,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getHolderLevel(Integer staffId, Long taskId) {
|
public Integer getHolderLevel(Integer staffId, Integer staffGlobalLevel, Long taskId) {
|
||||||
try {
|
try {
|
||||||
|
if (staffGlobalLevel == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
Task task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, taskId));
|
Task task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, taskId));
|
||||||
if (task == null || staffId <= 0)
|
if (task == null || staffId <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -146,13 +149,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
@Override
|
@Override
|
||||||
public Integer getHolderLevel(String token, Long taskId) {
|
public Integer getHolderLevel(String token, Long taskId) {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
return getHolderLevel(staffId, taskId);
|
Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
|
||||||
|
return getHolderLevel(staffId, staffGlobalLevel, taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Task> getMyTaskList(String token, Integer projectId) throws BadRequestException {
|
public List<Task> getMyTaskList(String token, Integer projectId) throws BadRequestException {
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new BadRequestException("无该项目访问权限");
|
throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery()
|
return baseMapper.selectList(Wrappers.<Task>lambdaQuery()
|
||||||
|
@ -186,7 +190,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
|
Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
|
||||||
if (userLevel == 0) {
|
if (userLevel == 0) {
|
||||||
System.out.println(userLevel);
|
System.out.println(userLevel);
|
||||||
throw new ForbiddenException("无该项目访问权限");
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS);
|
||||||
}
|
}
|
||||||
if (!task.checkInsert()) {
|
if (!task.checkInsert()) {
|
||||||
throw new BadRequestException("工作项参数错误");
|
throw new BadRequestException("工作项参数错误");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.utils;
|
package cn.edu.hfut.rmdjzz.projectmanagement.utils;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.DoNotDeserialize;
|
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.DoNotSerialize;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class BeanUtils {
|
public class BeanUtils {
|
||||||
/**
|
/**
|
||||||
* 将bean转成map,被标注{@link DoNotDeserialize}注释的变量会被跳过
|
* 将bean转成map,被标注{@link DoNotSerialize}注释的变量会被跳过
|
||||||
*
|
*
|
||||||
* @param putNulls 是否将值为null的变量也放入结果map
|
* @param putNulls 是否将值为null的变量也放入结果map
|
||||||
* @param toUnderline 是否将变量命名转为下划线型
|
* @param toUnderline 是否将变量命名转为下划线型
|
||||||
|
@ -30,7 +30,7 @@ public class BeanUtils {
|
||||||
Class<?> clazz = object.getClass();
|
Class<?> clazz = object.getClass();
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
String fieldName = field.getName();
|
String fieldName = field.getName();
|
||||||
if (fieldName.equals("serialVersionUID") || field.getAnnotation(DoNotDeserialize.class) != null) {
|
if (fieldName.equals("serialVersionUID") || field.getAnnotation(DoNotSerialize.class) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String key = toUnderline ? StringUtils.camelToUnderline(fieldName) : fieldName;
|
String key = toUnderline ? StringUtils.camelToUnderline(fieldName) : fieldName;
|
||||||
|
|
|
@ -17,21 +17,22 @@ import java.util.Date;
|
||||||
//TODO: 演示的时候把expireTime改短点儿
|
//TODO: 演示的时候把expireTime改短点儿
|
||||||
@Component
|
@Component
|
||||||
public final class TokenUtils {
|
public final class TokenUtils {
|
||||||
public final static String pvKey = "SignedByRMDJZZ";
|
private final static String PV_KEY = "SignedByRMDJZZ";
|
||||||
|
|
||||||
//TODO: 加个大权限
|
//TODO: 加个大权限
|
||||||
public static String getToken(String staffUsername, Integer staffId, Long duration) {
|
public static String getToken(String staffUsername, Integer staffId, Integer staffGlobalLevel, Long duration) {
|
||||||
return JWT.create()
|
return JWT.create()
|
||||||
.withClaim("staffUsername", staffUsername)
|
.withClaim("staffUsername", staffUsername)
|
||||||
.withClaim("staffId", staffId)
|
.withClaim("staffId", staffId)
|
||||||
|
.withClaim("staffGlobalLevel", staffGlobalLevel)
|
||||||
.withClaim("duration", duration)
|
.withClaim("duration", duration)
|
||||||
.withIssuedAt(new Date())
|
.withIssuedAt(new Date())
|
||||||
.withExpiresAt(new Date(System.currentTimeMillis() + duration * 1000L))
|
.withExpiresAt(new Date(System.currentTimeMillis() + duration * 1000L))
|
||||||
.sign(Algorithm.HMAC256(pvKey));
|
.sign(Algorithm.HMAC256(PV_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkToken(String token) throws TokenException {
|
public static boolean checkToken(String token) throws TokenException {
|
||||||
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(pvKey)).build();
|
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(PV_KEY)).build();
|
||||||
try {
|
try {
|
||||||
verifier.verify(token);
|
verifier.verify(token);
|
||||||
return true;
|
return true;
|
||||||
|
@ -52,12 +53,16 @@ public final class TokenUtils {
|
||||||
return JWT.decode(token).getClaim("staffId").asInt();
|
return JWT.decode(token).getClaim("staffId").asInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Integer getStaffGlobalLevel(String token) {
|
||||||
|
return JWT.decode(token).getClaim("staffGlobalLevel").asInt();
|
||||||
|
}
|
||||||
|
|
||||||
public static Long getDuration(String token) {
|
public static Long getDuration(String token) {
|
||||||
return JWT.decode(token).getClaim("duration").asLong();
|
return JWT.decode(token).getClaim("duration").asLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String refreshToken(String token) {
|
public static String refreshToken(String token) {
|
||||||
return getToken(getUsername(token), getStaffId(token), getDuration(token));
|
return getToken(getUsername(token), getStaffId(token), getStaffGlobalLevel(token), getDuration(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String autoRequire(String token) {
|
public static String autoRequire(String token) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.AnnouncementMapper">
|
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.AnnouncementMapper">
|
||||||
<resultMap id="announcementDto" type="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDto">
|
<resultMap id="announcementDto" type="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO">
|
||||||
<id property="announcementId" column="announcement_id"/>
|
<id property="announcementId" column="announcement_id"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper">
|
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper">
|
||||||
<resultMap id="projectDto" type="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto">
|
<resultMap id="projectDto" type="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO">
|
||||||
<id property="projectId" column="project_id"/>
|
<id property="projectId" column="project_id"/>
|
||||||
<result property="completed" column="is_completed"/>
|
<result property="completed" column="is_completed"/>
|
||||||
<result property="deleted" column="is_deleted"/>
|
<result property="deleted" column="is_deleted"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="findMyProject" resultMap="projectDto">
|
<select id="selectMyProject" resultMap="projectDto">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM (SELECT project_id,
|
FROM (SELECT project_id,
|
||||||
project_name,
|
project_name,
|
||||||
|
@ -32,11 +32,15 @@
|
||||||
AND task_project_id != 0
|
AND task_project_id != 0
|
||||||
GROUP BY task_project_id) AS t
|
GROUP BY task_project_id) AS t
|
||||||
ON project.project_id = t.task_project_id
|
ON project.project_id = t.task_project_id
|
||||||
|
<where>
|
||||||
|
<if test="staffId != null">
|
||||||
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{staffId} )
|
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{staffId} )
|
||||||
AND is_deleted = false) AS T
|
</if>
|
||||||
|
</where>
|
||||||
|
) AS T
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
<select id="findProjectProcess" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto">
|
<select id="selectProjectProcess" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDTO">
|
||||||
SELECT #{projectId} AS project_id,
|
SELECT #{projectId} AS project_id,
|
||||||
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
||||||
total_num
|
total_num
|
||||||
|
@ -44,7 +48,6 @@
|
||||||
COUNT(task_status) AS total_num
|
COUNT(task_status) AS total_num
|
||||||
FROM task
|
FROM task
|
||||||
WHERE is_deleted = false
|
WHERE is_deleted = false
|
||||||
AND task_project_id != 0
|
|
||||||
AND task_project_id = #{projectId}) AS T;
|
AND task_project_id = #{projectId}) AS T;
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper">
|
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper">
|
||||||
<resultMap id="taskDto" type="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto">
|
<resultMap id="taskDto" type="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO">
|
||||||
<id property="taskId" column="task_id"/>
|
<id property="taskId" column="task_id"/>
|
||||||
<result property="attachedInfo" column="attached_info" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
<result property="attachedInfo" column="attached_info"
|
||||||
|
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<select id="selectSubTaskList" resultMap="taskDto">
|
<select id="selectSubTaskList" resultMap="taskDto">
|
||||||
SELECT task_id,
|
SELECT task_id,
|
||||||
|
@ -24,12 +25,14 @@
|
||||||
judge.task_father_id IS NOT NULL AS has_children
|
judge.task_father_id IS NOT NULL AS has_children
|
||||||
FROM task AS t
|
FROM task AS t
|
||||||
JOIN (SELECT staff_id, staff_fullname FROM staff) AS s ON t.task_holder_id = s.staff_id
|
JOIN (SELECT staff_id, staff_fullname FROM staff) AS s ON t.task_holder_id = s.staff_id
|
||||||
LEFT JOIN (SELECT DISTINCT task_father_id FROM task WHERE is_deleted = 0) AS judge ON t.task_id = judge.task_father_id
|
LEFT JOIN (SELECT DISTINCT task_father_id FROM task WHERE is_deleted = 0) AS judge
|
||||||
|
ON t.task_id = judge.task_father_id
|
||||||
WHERE is_deleted = 0
|
WHERE is_deleted = 0
|
||||||
AND task_project_id = #{projectId}
|
AND task_project_id = #{projectId}
|
||||||
AND t.task_father_id = #{fatherId}
|
AND t.task_father_id = #{fatherId}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectProjectProcessOfStaff" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto">
|
<select id="selectProjectProcessOfStaff"
|
||||||
|
resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO">
|
||||||
SELECT t2.task_type,
|
SELECT t2.task_type,
|
||||||
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
||||||
IF(total_num IS NULL, 0, total_num) AS total_num
|
IF(total_num IS NULL, 0, total_num) AS total_num
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class MybatisPlusTests {
|
||||||
@Test
|
@Test
|
||||||
public void resultProjectTest() {
|
public void resultProjectTest() {
|
||||||
System.out.println(objectMapper.writeValueAsString(((ProjectServiceImpl) projectService).getBaseMapper()
|
System.out.println(objectMapper.writeValueAsString(((ProjectServiceImpl) projectService).getBaseMapper()
|
||||||
.findMyProject(new Page<>(1, 5), 1, Wrappers.query())));
|
.selectMyProject(new Page<>(1, 5), 1, Wrappers.query())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
|
Loading…
Reference in New Issue