Skip to content

Commit

Permalink
Chore: Qsheet data List 변경
Browse files Browse the repository at this point in the history
Chore: Qsheet data List 변경
  • Loading branch information
taking authored Sep 21, 2023
2 parents d4afe94 + 58a0516 commit 838b40d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public ResponseEntity<?> findAllQsheets(
qsheetEntity = qsheetService.getQsheets(pageable);
} else if(userid != null && orgid==null) {
qsheetEntity = qsheetService.findPageByUserId(userid, pageable);
} else{
qsheetEntity = qsheetService.findPageByOrgId(orgid, pageable);
}
} else{
qsheetEntity = qsheetService.findPageByOrgId(orgid, pageable);
}
for (QsheetEntity qsheet : qsheetEntity) {
qsheet.sortDataByOrderIndex();
}
Expand All @@ -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);

Expand Down
47 changes: 26 additions & 21 deletions nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
import java.io.Serializable;
import java.time.Instant;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.List;


/**
Expand Down Expand Up @@ -47,8 +45,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;


Expand All @@ -58,7 +56,8 @@ public class QsheetEntity implements Serializable {
private String name;

@JsonProperty("data")
private Map<String, ItemData> data;
@Schema(title = "큐시트 내용", example = "") // (Long) Tsid
private List<ItemData> data;

@JsonProperty("created_at")
@JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul")
Expand All @@ -75,6 +74,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;
Expand Down Expand Up @@ -102,27 +102,32 @@ public static class CreateDto {
private String name;
private String userSeq;
private String orgSeq;
private Map<String, ItemData> data;
private List<ItemData> 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.sort(Comparator.comparingInt(ItemData::getOrderIndex));
}
}
// 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<String, ItemData> data;
private List<ItemData> data;
}

public void updateFromDto(UpdateDto updateDto) {
Expand Down

0 comments on commit 838b40d

Please sign in to comment.