添加了成员离队的接口

master
ArgonarioD 2022-07-12 13:55:49 +08:00
parent 1a001fb599
commit 71cb31427f
1 changed files with 23 additions and 3 deletions

View File

@ -15,7 +15,6 @@ 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;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -74,12 +73,13 @@ public class ProjectGroupController {
} }
//TODO: test //TODO: test
@Operation(description = "body中只传staffUsername和projectStaffPosition")
@SneakyThrows @SneakyThrows
@PostMapping @PostMapping
public ResponseMap addGroupMember( public ResponseMap addGroupMember(
@RequestHeader(TokenUtils.HEADER_TOKEN) String token, @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@Parameter(description = "只传staffUsername和projectStaffPosition") @RequestBody GroupPositionVO groupPosition @RequestBody GroupPositionVO groupPosition
) { ) {
if (projectGroupService.insertNewMember(token, projectId, groupPosition.getStaffUsername(), groupPosition.getProjectStaffPosition())) { if (projectGroupService.insertNewMember(token, projectId, groupPosition.getStaffUsername(), groupPosition.getProjectStaffPosition())) {
return ResponseMap.ofSuccess(); return ResponseMap.ofSuccess();
@ -87,14 +87,34 @@ public class ProjectGroupController {
throw new BadRequestException(BadRequestException.OPERATE_FAILED); throw new BadRequestException(BadRequestException.OPERATE_FAILED);
} }
@SneakyThrows
@DeleteMapping("/{staffId}")
public ResponseMap deleteGroupMember(
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId,
@PathVariable Integer staffId
) {
if (projectGroupService.compareProjectAccessLevel(projectId, token, staffId) <= 0) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
if (projectGroupService.remove(Wrappers.<ProjectGroup>lambdaQuery()
.eq(ProjectGroup::getProjectId, projectId)
.eq(ProjectGroup::getStaffId, staffId))
) {
return ResponseMap.ofSuccess();
}
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
}
//TODO: test //TODO: test
@Operation(description = "body中只传projectStaffPosition")
@SneakyThrows @SneakyThrows
@PutMapping("/{staffId}") @PutMapping("/{staffId}")
public ResponseMap modifyDesignatedStaffPosition( public ResponseMap modifyDesignatedStaffPosition(
@RequestHeader(TokenUtils.HEADER_TOKEN) String token, @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable Integer staffId, @PathVariable Integer staffId,
@Parameter(description = "在body中只传projectStaffPosition") @RequestBody GroupPositionVO groupPosition @RequestBody GroupPositionVO groupPosition
) { ) {
if (projectGroupService.updateStaffPositions(token, projectId, staffId, groupPosition.getProjectStaffPosition())) { if (projectGroupService.updateStaffPositions(token, projectId, staffId, groupPosition.getProjectStaffPosition())) {
return ResponseMap.ofSuccess(); return ResponseMap.ofSuccess();