pamapi/src/doc/小鈴鐺通知API/所有小鈴鐺通知設為已讀.txt | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/domain/PersonalNotification.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/web/rest/PersonalNotificationResource.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 |
pamapi/src/doc/¤p¹aÅL³qª¾API/©Ò¦³¤p¹aÅL³qª¾³]¬°¤wŪ.txt
¤ñ¹ï·sÀÉ®× @@ -0,0 +1,6 @@ http post : å°ç®åç»å ¥è çææå°é´éºéç¥è¨å®çºå·²è® http://localhost:8080/api/personal_notification/readAllMyNotification pamapi/src/main/java/com/pollex/pam/domain/PersonalNotification.java
@@ -51,7 +51,7 @@ @Column(name = "created_date", updatable = false) private Instant createdDate = Instant.now(); @Column(name = "read_date", updatable = false) @Column(name = "read_date") private Instant readDate; public Long getId() { pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java
@@ -1,10 +1,14 @@ package com.pollex.pam.service; import java.time.Instant; import java.util.List; import javax.management.Notification; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import com.pollex.pam.domain.Appointment; import com.pollex.pam.domain.Consultant; @@ -15,6 +19,7 @@ import com.pollex.pam.enums.PersonalNotificationRoleEnum; import com.pollex.pam.repository.CustomerRepository; import com.pollex.pam.repository.PersonalNotificationRepository; import com.pollex.pam.security.SecurityUtils; import com.pollex.pam.service.dto.AppointmentUpdateDTO; @Service @@ -131,4 +136,24 @@ personalNotificationRepository.save(entity); } public void readAllMyNotification() { if(StringUtils.hasText(SecurityUtils.getAgentNo())) { Long consultantId = consultantService.findByAgentNo(SecurityUtils.getAgentNo()).getId(); readAllNotification(PersonalNotificationRoleEnum.CONSULTANT, consultantId); }else if(SecurityUtils.getCustomerDBId()!=null){ readAllNotification(PersonalNotificationRoleEnum.CUSTOMER, SecurityUtils.getCustomerDBId()); } } public void readAllNotification(PersonalNotificationRoleEnum ownerRole , Long ownerId) { List<PersonalNotification> allNotification = personalNotificationRepository.findAllByOwnerRoleAndOwnerId(ownerRole, ownerId); Instant today = Instant.now(); allNotification.stream() .filter(notification -> notification.getReadDate()==null) .forEach(notification ->{ notification.setReadDate(today); personalNotificationRepository.saveAll(allNotification); }); } } pamapi/src/main/java/com/pollex/pam/web/rest/PersonalNotificationResource.java
@@ -8,6 +8,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -45,14 +48,8 @@ return new ResponseEntity<>(personalNotificationList, HttpStatus.OK); } // @GetMapping("/create") // public void create() { // PersonalNotification test = new PersonalNotification(); // test.setContent("content test"); // test.setNotificationType(NotificationTypeEnum.ACTIVITY); // test.setOwnerId(Long.valueOf(11)); // test.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT); // test.setTitle("title test"); // personalNotificationRepository.save(test); // } @PostMapping("/readAllMyNotification") public void readAll() { personalNotificationService.readAllMyNotification(); } }