Skip to content

Commit

Permalink
fix delete participate while delete event
Browse files Browse the repository at this point in the history
  • Loading branch information
feellmoose committed Dec 9, 2023
1 parent 6a36f36 commit d23ffa8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/sast/evento/service/ParticipateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public interface ParticipateService {
// 获取个人的活动的状态
Participate getParticipation(String userId, Integer eventId);

void deleteAllParticipateOfEvent(Integer eventId);

}
9 changes: 5 additions & 4 deletions src/main/java/sast/evento/service/impl/EventServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import sast.evento.entitiy.Event;
import sast.evento.entitiy.Location;
import sast.evento.exception.LocalRunTimeException;
import sast.evento.mapper.EventMapper;
import sast.evento.mapper.EventModelMapper;
import sast.evento.mapper.EventTypeMapper;
import sast.evento.mapper.LocationMapper;
import sast.evento.mapper.*;
import sast.evento.model.Action;
import sast.evento.model.EventModel;
import sast.evento.model.PageModel;
Expand Down Expand Up @@ -54,6 +51,9 @@ public class EventServiceImpl implements EventService {
@Resource
private EventDepartmentService eventDepartmentService;

@Resource
private ParticipateService participateService;

@Resource
private PermissionService permissionService;

Expand Down Expand Up @@ -202,6 +202,7 @@ public Boolean deleteEvent(Integer eventId) {
if (!eventDepartmentService.deleteEventDepartmentsByEventId(eventId)) {
throw new LocalRunTimeException(ErrorEnum.COMMON_ERROR, "delete eventDepartment failed");
}
participateService.deleteAllParticipateOfEvent(eventId);
boolean isSuccess = eventMapper.deleteById(eventId) > 0;
if (isSuccess) {
eventStateScheduleService.removeJobs(eventId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import sast.evento.common.enums.ErrorEnum;
Expand All @@ -11,8 +12,6 @@
import sast.evento.mapper.ParticipateMapper;
import sast.evento.service.ParticipateService;

import static net.sf.jsqlparser.util.validation.metadata.NamedObject.user;

/**
* @projectName: sast-evento-backend
* @author: mio
Expand Down Expand Up @@ -159,4 +158,10 @@ public Participate getParticipation(String userId, Integer eventId) {
//id不会被json序列化,所以随便传了个
return userparticipate != null ? userparticipate : new Participate(1, false, false, false, userId, eventId);
}

@Override
public void deleteAllParticipateOfEvent(Integer eventId) {
participateMapper.delete(Wrappers.lambdaQuery(Participate.class)
.eq(Participate::getEventId, eventId));
}
}

0 comments on commit d23ffa8

Please sign in to comment.