mirror of
https://github.com/ArenMg/aren.git
synced 2025-01-24 06:50:49 +00:00
Fixer problème suppression débat
This commit is contained in:
parent
0378605e3f
commit
de288abcc0
2 changed files with 46 additions and 26 deletions
|
@ -122,6 +122,26 @@ public class DebateService extends AbstractService<Debate> {
|
|||
return results.get(0);
|
||||
}
|
||||
|
||||
public void remove(Long debateId){
|
||||
super.transactionBegin();
|
||||
try{
|
||||
getEntityManager().createNativeQuery("DELETE FROM debates_teams WHERE debate_id=:debateId")
|
||||
.setParameter("debateId",debateId)
|
||||
.executeUpdate() ;
|
||||
getEntityManager().createNativeQuery("DELETE FROM debates_guests WHERE debate_id=:debateId")
|
||||
.setParameter("debateId",debateId)
|
||||
.executeUpdate() ;
|
||||
getEntityManager().createNativeQuery("DELETE FROM notifications WHERE debate_id = :debateId")
|
||||
.setParameter("debateId", debateId)
|
||||
.executeUpdate();
|
||||
super.commit();
|
||||
Debate debate=super.find(debateId) ;
|
||||
super.remove(debate);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
|
|
|
@ -151,9 +151,10 @@ public class DebateRESTFacade extends AbstractRESTFacade<Debate> {
|
|||
* @param id
|
||||
*/
|
||||
@Override
|
||||
@RolesAllowed({"MODO"})
|
||||
@RolesAllowed({"ADMIN"})
|
||||
public void remove(Long id) {
|
||||
super.remove(id);
|
||||
debateService.clearComments(id);
|
||||
debateService.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,7 +212,6 @@ public class DebateRESTFacade extends AbstractRESTFacade<Debate> {
|
|||
@Path("{id}/comments")
|
||||
@RolesAllowed({"ADMIN"})
|
||||
public void clear(@PathParam("id") Long id) {
|
||||
|
||||
debateService.clearComments(id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue