Skip to content

Commit

Permalink
fix: 修复项目删除不能恢复
Browse files Browse the repository at this point in the history
  • Loading branch information
javahuang committed Feb 21, 2023
1 parent bc5be9e commit 8b2a946
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ else if (query.getProjectId() != null && Boolean.TRUE.equals(query.getLatest()))
// 获取考试排名信息
if (query.isRankEnabled()) {
List<Double> scores = list(Wrappers.<Answer>lambdaQuery().select(Answer::getExamScore, Answer::getId)
.eq(Answer::getProjectId, answerView.getProjectId())).stream().map(x -> x.getExamScore())
.eq(Answer::getProjectId, answerView.getProjectId())).stream()
.map(x -> Optional.ofNullable(x.getExamScore()).orElse(Double.valueOf(0)))
.collect(Collectors.toList());
Collections.sort(scores, Collections.reverseOrder());
answerView.setRank(scores.indexOf(answerView.getExamScore()) + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public void addProjectPartner(ProjectPartnerRequest request) {
public void deleteProjectPartner(ProjectPartnerRequest request) {
remove(Wrappers.<ProjectPartner>lambdaUpdate()
.in(CollectionUtils.isNotEmpty(request.getIds()), ProjectPartner::getId, request.getIds())
.in(CollectionUtils.isNotEmpty(request.getProjectIds()), ProjectPartner::getProjectId,
request.getProjectIds())
.eq(request.getProjectId() != null, ProjectPartner::getProjectId, request.getProjectId()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ private void validateSettingKey(String expressionString) {
@Override
public void deleteProject(ProjectRequest request) {
removeById(request.getId());
// 删除项目参与者
ProjectPartnerRequest deletePartnerRequest = new ProjectPartnerRequest();
deletePartnerRequest.setProjectId(request.getId());
projectPartnerService.deleteProjectPartner(deletePartnerRequest);
}

@Override
Expand All @@ -169,7 +165,8 @@ public ProjectSetting getSetting(ProjectQuery query) {

@Override
public List<ProjectView> getDeleted(ProjectQuery query) {
List<ProjectView> list = projectViewMapper.toView(getBaseMapper().selectLogicDeleted());
List<ProjectView> list = projectViewMapper
.toView(getBaseMapper().selectLogicDeleted(SecurityContextUtils.getUserId()));
list.forEach(view -> {
if (!ProjectModeEnum.folder.equals(view.getMode())) {
view.setTotal(answerMapper
Expand All @@ -182,6 +179,10 @@ public List<ProjectView> getDeleted(ProjectQuery query) {
@Override
public void batchDestroyProject(ProjectRequest request) {
getBaseMapper().batchDestroy(request.getIds());
// 删除项目参与者
ProjectPartnerRequest deletePartnerRequest = new ProjectPartnerRequest();
deletePartnerRequest.setProjectIds(request.getIds());
projectPartnerService.deleteProjectPartner(deletePartnerRequest);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
public interface ProjectMapper extends BaseMapper<Project> {

@Select("select * from t_project where is_deleted = 1")
@Select("select * from t_project where is_deleted = 1 and create_by = #{userId}")
@ResultMap("mybatis-plus_Project")
List<Project> selectLogicDeleted();
List<Project> selectLogicDeleted(String userId);

@Delete({ "<script>", "delete", "FROM t_project", "WHERE id IN",
"<foreach item='item' index='index' collection='ids'", "open='(' separator=',' close=')'>", "#{item}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public class ProjectPartnerRequest {

private MultipartFile file;

private List<String> projectIds;

}

0 comments on commit 8b2a946

Please sign in to comment.