#68 added ping in db
This commit is contained in:
parent
d921def09d
commit
d4b514a9b0
@ -1,6 +1,7 @@
|
||||
package ru.ulstu.conference.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
@ -16,4 +17,8 @@ public interface ConferenceRepository extends JpaRepository<Conference, Integer>
|
||||
|
||||
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
||||
List<Conference> findAllActive(@Param("date") Date date);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE Conference c SET c.ping = (c.ping + 1) WHERE c.id = :id")
|
||||
int updatePingConference(@Param("id") Integer id);
|
||||
}
|
||||
|
@ -146,7 +146,6 @@ public class ConferenceService {
|
||||
conference.setTitle(conferenceDto.getTitle());
|
||||
conference.setDescription(conferenceDto.getDescription());
|
||||
conference.setUrl(conferenceDto.getUrl());
|
||||
Integer pingCount = conferenceDto.getPing() - conference.getPing(); // for notification
|
||||
conference.setPing(conference.getPing());
|
||||
conference.setBeginDate(conferenceDto.getBeginDate());
|
||||
conference.setEndDate(conferenceDto.getEndDate());
|
||||
@ -180,9 +179,10 @@ public class ConferenceService {
|
||||
return conferenceRepository.findAllActive(new Date());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void ping(ConferenceDto conferenceDto) throws IOException {
|
||||
pingService.addPing(findOne(conferenceDto.getId()));
|
||||
// conferenceDto.setPing(conferenceDto.getPing() + 1);
|
||||
conferenceRepository.updatePingConference(conferenceDto.getId());
|
||||
}
|
||||
|
||||
public Conference findOne(Integer conferenceId) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.ulstu.ping.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
@ -26,7 +25,6 @@ public class Ping extends BaseEntity {
|
||||
@JoinColumn(name = "users_id")
|
||||
private User user;
|
||||
|
||||
@Nullable
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "conference_id")
|
||||
private Conference conference;
|
||||
|
Loading…
Reference in New Issue
Block a user