From 376913ee05d8f25f25307f61b441c8b9c7966bd4 Mon Sep 17 00:00:00 2001 From: yby654 Date: Thu, 21 Sep 2023 04:03:29 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Chore:=20Qsheet=20data=20List=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nw/controller/QsheetController.java | 8 ++-- .../lab/cherry/nw/model/QsheetEntity.java | 40 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java b/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java index bf21661..71b6b97 100644 --- a/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java +++ b/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java @@ -71,9 +71,9 @@ public ResponseEntity findAllQsheets( } else{ qsheetEntity = qsheetService.findPageByOrgId(orgid, pageable); } - for (QsheetEntity qsheet : qsheetEntity) { - qsheet.sortDataByOrderIndex(); - } +// for (QsheetEntity qsheet : qsheetEntity) { +// qsheet.sortDataByOrderIndex(); +// } return new ResponseEntity<>(qsheetEntity, new HttpHeaders(), HttpStatus.OK); } @@ -94,7 +94,7 @@ public ResponseEntity findAllQsheets( @ApiResponse(responseCode = "400", description = "입력 값이 잘못 되었습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) @Operation(summary = "Qsheet 생성", description = "Qsheet를 추가합니다.") - public ResponseEntity createMH(@Valid @RequestBody QsheetEntity.CreateDto qsheetCreateDto) { + public ResponseEntity createQsheet(@Valid @RequestBody QsheetEntity.CreateDto qsheetCreateDto) { log.info("[QsheetController] createQsheet...!"); qsheetService.createQsheet(qsheetCreateDto); diff --git a/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java b/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java index 3687b14..000024d 100644 --- a/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java +++ b/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.minio.messages.Item; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; @@ -17,6 +18,7 @@ import java.time.Instant; import java.util.Comparator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -47,8 +49,8 @@ public class QsheetEntity implements Serializable { private UserEntity userid; @DBRef - @JsonProperty("orgid") - @Schema(title = "조직 정보", example = "더글로리") // (Long) Tsid + @JsonProperty("orgSeq") + @Schema(title = "조직 정보", example = "38352658567418867") // (Long) Tsid private OrgEntity orgid; @@ -58,7 +60,8 @@ public class QsheetEntity implements Serializable { private String name; @JsonProperty("data") - private Map data; + @Schema(title = "큐시트 내용", example = "") // (Long) Tsid + private List data; @JsonProperty("created_at") @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul") @@ -75,6 +78,7 @@ public class QsheetEntity implements Serializable { @Builder public static class ItemData { private int orderIndex; + private String process; private String content; private String actor; private String note; @@ -102,27 +106,27 @@ public static class CreateDto { private String name; private String userSeq; private String orgSeq; - private Map data; + private List data; } - public void sortDataByOrderIndex() { - if (data != null) { - data = data.entrySet() - .stream() - .sorted(Map.Entry.comparingByValue(Comparator.comparingInt(ItemData::getOrderIndex))) - .collect(Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue, - (e1, e2) -> e1, - LinkedHashMap::new - )); - } - } +// public void sortDataByOrderIndex() { +// if (data != null) { +// data = data.entrySet() +// .stream() +// .sorted(Map.Entry.comparingByValue(Comparator.comparingInt(ItemData::getOrderIndex))) +// .collect(Collectors.toMap( +// Map.Entry::getKey, +// Map.Entry::getValue, +// (e1, e2) -> e1, +// LinkedHashMap::new +// )); +// } +// } @Getter @Builder @NoArgsConstructor @AllArgsConstructor public static class UpdateDto { - private Map data; + private List data; } public void updateFromDto(UpdateDto updateDto) { From 58a051698476244d041b2d622b4226f8473bfc4a Mon Sep 17 00:00:00 2001 From: yby654 Date: Thu, 21 Sep 2023 04:38:30 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Chore:=20=ED=81=90=EC=8B=9C=ED=8A=B8=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=83=80=EC=9E=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lab/cherry/nw/controller/QsheetController.java | 12 ++++++------ .../main/java/lab/cherry/nw/model/QsheetEntity.java | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java b/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java index 71b6b97..e524ce4 100644 --- a/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java +++ b/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java @@ -68,12 +68,12 @@ public ResponseEntity findAllQsheets( qsheetEntity = qsheetService.getQsheets(pageable); } else if(userid != null && orgid==null) { qsheetEntity = qsheetService.findPageByUserId(userid, pageable); - } else{ - qsheetEntity = qsheetService.findPageByOrgId(orgid, pageable); - } -// for (QsheetEntity qsheet : qsheetEntity) { -// qsheet.sortDataByOrderIndex(); -// } + } else{ + qsheetEntity = qsheetService.findPageByOrgId(orgid, pageable); + } + for (QsheetEntity qsheet : qsheetEntity) { + qsheet.sortDataByOrderIndex(); + } return new ResponseEntity<>(qsheetEntity, new HttpHeaders(), HttpStatus.OK); } diff --git a/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java b/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java index 000024d..ce532e1 100644 --- a/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java +++ b/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.minio.messages.Item; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; @@ -17,10 +16,7 @@ import java.io.Serializable; import java.time.Instant; import java.util.Comparator; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; /** @@ -109,6 +105,11 @@ public static class CreateDto { private List data; } + public void sortDataByOrderIndex() { + if (data != null) { + data.sort(Comparator.comparingInt(ItemData::getOrderIndex)); + } + } // public void sortDataByOrderIndex() { // if (data != null) { // data = data.entrySet()