Skip to content

Commit

Permalink
Merge pull request #92 from dsc-sookmyung/feature/child-backend
Browse files Browse the repository at this point in the history
[#25] fix: register event with eid
  • Loading branch information
hellouz818 authored May 31, 2022
2 parents c638e16 + db28cca commit d8d2c62
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 181 deletions.
7 changes: 7 additions & 0 deletions spring/notinote/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM adoptopenjdk/openjdk11

ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ public ResponseEntity<?> getEventList() {
}

@PutMapping("/event/register")
public ResponseEntity<?> registerEvent(@RequestParam(value = "id") Long id, @RequestBody EventRegisterDto registerDto) throws GeneralSecurityException, IOException {
return ResponseEntity.ok(eventService.registerEvent(id, registerDto));
}

@PostMapping("/event/register")
public ResponseEntity<?> registerEventWithoutId(@RequestBody EventRegisterDto registerDto) throws GeneralSecurityException, IOException {
return ResponseEntity.ok(eventService.registerEvent(registerDto));
public ResponseEntity<?> registerEvent(@RequestParam(value = "eid") Long eid, @RequestBody EventRegisterDto registerDto) throws GeneralSecurityException, IOException {
return ResponseEntity.ok(eventService.registerEvent(eid, registerDto));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class EventService {

public Event create(EventRequestDto requestDto, Notice notice) {
Event event = new Event(requestDto);
event.setNotice(notice);
if (notice != null) event.setNotice(notice);
eventRepository.save(event);

return event;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.answer.notinote.Notice.controller;


import com.answer.notinote.Auth.token.provider.JwtTokenProvider;
import com.answer.notinote.Event.dto.EventRequestDto;
import com.answer.notinote.Notice.dto.NoticeOCRDto;
import com.answer.notinote.Notice.dto.NoticeRequestDto;
import com.answer.notinote.Notice.dto.NoticeSentenceDto;
import com.answer.notinote.Notice.dto.NoticeTitleListDto;
import com.answer.notinote.Event.service.EventService;
import com.answer.notinote.Notice.dto.*;
import com.answer.notinote.Notice.service.NoticeService;
import com.answer.notinote.User.domain.entity.User;
import com.answer.notinote.User.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;
Expand All @@ -21,34 +18,30 @@


@RestController
@RequiredArgsConstructor
public class NoticeController {

@Autowired
NoticeService noticeService;
private final NoticeService noticeService;

@Autowired
UserService userService;
private final UserService userService;

@Autowired
JwtTokenProvider jwtTokenProvider;
private final JwtTokenProvider jwtTokenProvider;

public NoticeController(NoticeService noticeService) {
this.noticeService = noticeService;
}
private final EventService eventService;

@RequestMapping(value = "/notice/ocr", method = RequestMethod.POST)
public NoticeOCRDto executeOCR (@RequestPart MultipartFile uploadfile, HttpServletRequest userrequest) throws IOException {
String token = jwtTokenProvider.resolveAccessToken(userrequest);
public NoticeOCRDto executeOCR (@RequestPart MultipartFile uploadfile, HttpServletRequest request) throws IOException {
String token = jwtTokenProvider.resolveAccessToken(request);
String email = jwtTokenProvider.getUserEmail(token);
User user = userService.findUserByEmail(email);
String targetLanguage = user.getUlanguage();

String korean = noticeService.detectText(uploadfile); //원문 추출
String trans_full = noticeService.transText(korean, targetLanguage); //번역문 추출
List<EventRequestDto> events = noticeService.detectEventOCR(korean, trans_full, targetLanguage); //이벤트 추출
List<NoticeSentenceDto> fullText = noticeService.extractSentenceFromEventOCR(trans_full, events);
return new NoticeOCRDto(korean, trans_full, fullText);

List<EventRequestDto> eventWords = noticeService.detectEvent(korean, trans_full, targetLanguage); //이벤트 추출
List<NoticeSentenceDto> fullText = noticeService.extractSentenceFromEventRequestDto(trans_full, eventWords);
return new NoticeOCRDto(korean, trans_full, fullText);
}

@RequestMapping(value = "/notice/save", method = RequestMethod.POST)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.answer.notinote.Notice.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;

@Getter
@AllArgsConstructor
@Builder
public class NoticeEventDto {
int id;
long eid;
String content;
LocalDate date;
boolean highlight;
boolean registered;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
@Builder
public class NoticeSentenceDto {
int id;
long eid = -1;
String content;
LocalDate date;
boolean highlight;
boolean registered;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ public class NoticeTitleListDto {
private String uploadfile;
private String title;
private LocalDate date;
private List<NoticeSentenceDto> fullText = new ArrayList<>();
private List<NoticeEventDto> fullText = new ArrayList<>();
private String korean;
private String trans_full;

public NoticeTitleListDto(Notice entity, List<NoticeSentenceDto> sentences){
public NoticeTitleListDto(Notice entity, List<NoticeEventDto> sentences){
this.uploadfile = entity.getNimageurl() + "/" + entity.getNimagename();
this.title = entity.getTitle();
this.date = entity.getNdate();
this.korean = entity.getOrigin_full();
this.trans_full = entity.getTrans_full();

this.fullText.addAll(sentences);
}
Expand Down
Loading

0 comments on commit d8d2c62

Please sign in to comment.