Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface PublicScheduleAdminRepository extends JpaRepository<PublicSched

List<PublicSchedule> findByAuthor(String author);

List<PublicSchedule> findAllByClassification(DetailClassification detailClassification);
List<PublicSchedule> findAllByClassificationOrderByIdDesc(DetailClassification detailClassification);

List<PublicSchedule> findAll();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/calendar/private")
@RequestMapping("/calendar/admin/private")
public class PrivateScheduleAdminController {

private final PrivateScheduleAdminService privateScheduleAdminService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/calendar/public")
@RequestMapping("/calendar/admin/public")
public class PublicScheduleAdminController {

private final PublicScheduleAdminService publicScheduleAdminService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class PublicScheduleAdminCreateEventReqDto {
@Size(max = 2000, message = "๋‚ด์šฉ์€ 2000์ž์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class PublicScheduleAdminCreateJobReqDto {
@Size(max = 2000, message = "๋‚ด์šฉ์€ 2000์ž์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class PublicScheduleAdminUpdateReqDto {
@Size(max = 2000, message = "๋‚ด์šฉ์€ 2000์ž์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/calendar")
@RequestMapping("/calendar/admin")
public class TotalScheduleAdminController {

private final TotalScheduleAdminService totalScheduleAdminService;

@GetMapping("/list/{detailClassification}")
public ResponseEntity<TotalScheduleAdminSearchListResDto> totalScheduleAdminClassificationList(
@PathVariable DetailClassification detailClassification) {

TotalScheduleAdminSearchListResDto scheduleList = totalScheduleAdminService.findAllByClassification(
detailClassification);

return ResponseEntity.ok(scheduleList);
}

@GetMapping("/search")
public ResponseEntity<TotalScheduleAdminSearchListResDto> totalScheduleAdminSearchList(
@ModelAttribute @Valid TotalScheduleAdminSearchReqDto totalScheduleAdminSearchReqDto) {
TotalScheduleAdminSearchListResDto scheduleList = totalScheduleAdminService
.searchTotalScheduleAdminList(totalScheduleAdminSearchReqDto);
TotalScheduleAdminSearchListResDto scheduleList = totalScheduleAdminService.searchTotalScheduleAdminList(
totalScheduleAdminSearchReqDto);

return ResponseEntity.ok(scheduleList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TotalScheduleAdminService {

public TotalScheduleAdminSearchListResDto findAllByClassification(DetailClassification detailClassification) {

List<PublicSchedule> scheduleList = publicScheduleAdminRepository.findAllByClassification(
List<PublicSchedule> scheduleList = publicScheduleAdminRepository.findAllByClassificationOrderByIdDesc(
detailClassification);

return TotalScheduleAdminSearchListResDto.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class PrivateScheduleCreateReqDto {
@Size(max = 2000)
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class PrivateScheduleUpdateReqDto {
@Size(max = 2000)
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PublicScheduleCreateEventReqDto {
@Size(max = 2000, message = "๋‚ด์šฉ์€ 2000์ž์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class PublicScheduleCreateJobReqDto {
@Size(max = 2000, message = "๋‚ด์šฉ์€ 2000์ž์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class PublicScheduleUpdateReqDto {
@Size(max = 2000, message = "๋‚ด์šฉ์€ 2000์ž์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String content;

@Size(max = 255, message = "๋งํฌ๋Š” 255์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String link;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ private void saveEventsToPublicSchedule(List<FortyTwoEventResponse> events) {

private void convertAndSaveEvent(FortyTwoEventResponse event) {
String description = event.getDescription();
if (description != null && description.length() > 255) {
description = description.substring(0, 255);
}
PublicSchedule publicSchedule = PublicSchedule.builder()
.classification(DetailClassification.EVENT)
.eventTag(determineEventTag(event))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.transaction.annotation.Transactional;

import gg.data.calendar.PrivateSchedule;
import gg.data.calendar.type.DetailClassification;
import gg.data.calendar.type.ScheduleStatus;
import gg.repo.calendar.PrivateScheduleRepository;
import gg.repo.calendar.PublicScheduleRepository;
Expand All @@ -21,10 +20,10 @@
private final PublicScheduleRepository publicScheduleRepository;
private final PrivateScheduleRepository privateScheduleRepository;
private final MessageSender messageSender;
private static final String SCHEDULE_MESSAGE_D_DAY = "๐Ÿ“†์ผ์ •์š”์ •๐Ÿงš์œผ๋กœ๋ถ€ํ„ฐ ์•Œ๋ฆผ์ด ๋„์ฐฉํ–ˆ์Šต๋‹ˆ๋‹ค.\n"
+ "๐Ÿ“ง42gg์บ˜๋ฆฐ๋”๐Ÿ“ง์™€ <<์˜ค๋Š˜>>์˜ ์ผ์ •์„ ํ™•์ธํ•ด๋ณด์„ธ์š”!\n";
private static final String SCHEDULE_MESSAGE_BEFORE_D_DAY = "๐Ÿ“…์ผ์ •์š”์ •๐Ÿงš์œผ๋กœ๋ถ€ํ„ฐ ์•Œ๋ฆผ์ด ๋„์ฐฉํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n"
+ "๐Ÿ“ง42gg์บ˜๋ฆฐ๋”๐Ÿ“ง์™€ >>๋‚ด์ผ<<์˜ ์ผ์ •์„ ํ™•์ธํ•ด๋ณด์„ธ์š”!\n";
private static final String SCHEDULE_MESSAGE_D_DAY =
"๐Ÿ“†์ผ์ •์š”์ •๐Ÿงš์œผ๋กœ๋ถ€ํ„ฐ ์•Œ๋ฆผ์ด ๋„์ฐฉํ–ˆ์Šต๋‹ˆ๋‹ค.\n" + "๐Ÿ“ง42gg์บ˜๋ฆฐ๋”๐Ÿ“ง์™€ <<์˜ค๋Š˜>>์˜ ์ผ์ •์„ ํ™•์ธํ•ด๋ณด์„ธ์š”!\n";
private static final String SCHEDULE_MESSAGE_BEFORE_D_DAY =
"๐Ÿ“…์ผ์ •์š”์ •๐Ÿงš์œผ๋กœ๋ถ€ํ„ฐ ์•Œ๋ฆผ์ด ๋„์ฐฉํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n" + "๐Ÿ“ง42gg์บ˜๋ฆฐ๋”๐Ÿ“ง์™€ >>๋‚ด์ผ<<์˜ ์ผ์ •์„ ํ™•์ธํ•ด๋ณด์„ธ์š”!\n";

@Transactional
public void sendScheduleNotifications() {
Expand All @@ -37,19 +36,18 @@
List<PrivateSchedule> alarmSchedule = privateScheduleRepository.findSchedulesWithAlarmForBothDays(startOfDay,
endOfDay, startDday, endDday, ScheduleStatus.ACTIVATE);
for (PrivateSchedule schedule : alarmSchedule) {
String message = schedule.getPublicSchedule().getStartTime()
.isBefore(currentTime.plusDays(1))
? SCHEDULE_MESSAGE_D_DAY : SCHEDULE_MESSAGE_BEFORE_D_DAY;
String message =
schedule.getPublicSchedule().getStartTime().isBefore(currentTime.plusDays(1)) ? SCHEDULE_MESSAGE_D_DAY :
SCHEDULE_MESSAGE_BEFORE_D_DAY;

Check warning on line 41 in gg-calendar-api/src/main/java/gg/calendar/api/user/utils/service/ScheduleNotiService.java

View check run for this annotation

Codecov / codecov/patch

gg-calendar-api/src/main/java/gg/calendar/api/user/utils/service/ScheduleNotiService.java#L41

Added line #L41 was not covered by tests
messageSender.send(schedule.getUser().getIntraId(),
message + "printf('์ผ์ •: " + schedule.getPublicSchedule().getTitle() + "');\n"
+ "System.out.println(" + makeLink(schedule) + ");\n\n");
message + "printf('์ผ์ •: " + schedule.getPublicSchedule().getTitle() + "');\n");

Check warning on line 43 in gg-calendar-api/src/main/java/gg/calendar/api/user/utils/service/ScheduleNotiService.java

View check run for this annotation

Codecov / codecov/patch

gg-calendar-api/src/main/java/gg/calendar/api/user/utils/service/ScheduleNotiService.java#L43

Added line #L43 was not covered by tests
}
}

public String makeLink(PrivateSchedule schedule) {
boolean flag = schedule.getPublicSchedule().getClassification() == DetailClassification.JOB_NOTICE;
return flag ? schedule.getPublicSchedule().getLink() :
"https://gg.42seoul.kr/calendar/detail/" + schedule.getId();
}
// public String makeLink(PrivateSchedule schedule) {
// boolean flag = schedule.getPublicSchedule().getClassification() == DetailClassification.JOB_NOTICE;
// return flag ? schedule.getPublicSchedule().getLink() :
// "https://gg.42seoul.kr/calendar/detail/" + schedule.getId();
// }
}

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void getPrivateScheduleAdminDetailTestSuccess() throws Exception {

// when
String response = mockMvc.perform(
get("/admin/calendar/private/{id}", privateSchedule.getId()).header("Authorization",
get("/calendar/admin/private/{id}", privateSchedule.getId()).header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
Expand Down Expand Up @@ -111,7 +111,7 @@ void getPrivateScheduleAdminDetailTestFailNotCorrectType() throws Exception {

// when
String response = mockMvc.perform(
get("/admin/calendar/private/qweksd").header("Authorization",
get("/calendar/admin/private/qweksd").header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString();
Expand All @@ -130,7 +130,7 @@ void getPrivateScheduleAdminDetailTestFailNotFound() throws Exception {

// when
String response = mockMvc.perform(
get("/admin/calendar/private/500123").header("Authorization",
get("/calendar/admin/private/500123").header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isNotFound()).andReturn().getResponse().getContentAsString();
Expand All @@ -149,7 +149,7 @@ void getPrivateScheduleAdminDetailTestFailNotFoundGroupId() throws Exception {

// when
String response = mockMvc.perform(
get("/admin/calendar/private/{id}", privateSchedule.getId()).header("Authorization",
get("/calendar/admin/private/{id}", privateSchedule.getId()).header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isNotFound()).andReturn().getResponse().getContentAsString();
Expand All @@ -173,7 +173,7 @@ void deletePrivateScheduleAdminTestSuccess() throws Exception {

// when
mockMvc.perform(
patch("/admin/calendar/private/{id}", privateSchedule.getId()).header("Authorization",
patch("/calendar/admin/private/{id}", privateSchedule.getId()).header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isOk());
Expand All @@ -193,7 +193,7 @@ void deletePrivateScheduleAdminTestFailNotCorrectType() throws Exception {

// when
String response = mockMvc.perform(
patch("/admin/calendar/private/qweksd").header("Authorization",
patch("/calendar/admin/private/qweksd").header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString();
Expand All @@ -212,7 +212,7 @@ void deletePrivateScheduleAdminTestFailNotFound() throws Exception {

// when
String response = mockMvc.perform(
patch("/admin/calendar/private/500123").header("Authorization",
patch("/calendar/admin/private/500123").header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isNotFound()).andReturn().getResponse().getContentAsString();
Expand All @@ -232,7 +232,7 @@ void deletePrivateScheduleAdminTestFailNotPrivateSchedule() throws Exception {

// when
String response = mockMvc.perform(
patch("/admin/calendar/private/{id}", privateSchedule.getId()).header("Authorization",
patch("/calendar/admin/private/{id}", privateSchedule.getId()).header("Authorization",
"Bearer " + accessToken))
.andDo(print())
.andExpect(status().isForbidden()).andReturn().getResponse().getContentAsString();
Expand Down
Loading