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 642f477..762d0af 100644 --- a/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java +++ b/nw/src/main/java/lab/cherry/nw/controller/QsheetController.java @@ -2,7 +2,6 @@ import java.util.List; import java.util.Map; -import org.bson.types.ObjectId; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -31,7 +30,11 @@ import lab.cherry.nw.error.ResultResponse; import lab.cherry.nw.error.enums.SuccessCode; import lab.cherry.nw.model.QsheetEntity; +import lab.cherry.nw.model.RoleEntity; +import lab.cherry.nw.model.UserEntity; +import lab.cherry.nw.service.AuthService; import lab.cherry.nw.service.QsheetService; +import lab.cherry.nw.service.UserService; import lab.cherry.nw.util.Common; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -67,6 +70,7 @@ public class QsheetController { public ResponseEntity findAllQsheets( @RequestParam(required = false) String userSeq, @RequestParam(required = false) String orgSeq, + @RequestParam(required = false) String type, @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "100") Integer size, @RequestParam(defaultValue = "id,desc") String[] sort) { @@ -81,7 +85,7 @@ public ResponseEntity findAllQsheets( } else if(userSeq != null && orgSeq==null) { qsheetEntity = qsheetService.findPageByUserId(userSeq, pageable); } else{ - qsheetEntity = qsheetService.findPageByOrgId(orgSeq, pageable); + qsheetEntity = qsheetService.findPageByOrgId(orgSeq, type, pageable); } for (QsheetEntity qsheet : qsheetEntity) { qsheet.sortDataByOrderIndex(); 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 8b20f97..ea79c9d 100644 --- a/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java +++ b/nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java @@ -1,24 +1,21 @@ package lab.cherry.nw.model; +import java.io.Serializable; +import java.time.Instant; +import java.util.Comparator; +import java.util.List; +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.DBRef; +import org.springframework.data.mongodb.core.mapping.Document; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.aggregation.VariableOperators.Map; -import org.springframework.data.mongodb.core.mapping.DBRef; -import org.springframework.data.mongodb.core.mapping.Document; -import java.io.Serializable; -import java.time.Instant; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; /** *
@@ -69,6 +66,10 @@ public class QsheetEntity implements Serializable {
     @Schema(title = "큐시트 업데이트 시간", example = "2023-07-04 12:00:00")
     private Instant updated_at;
 
+    @JsonProperty("type")
+    @Schema(title = "타입", type="String", example = "템플릿 or 유저")
+    private String type;
+
     @JsonProperty("memo")
     @Schema(title = "메모", type="String", example = "신랑 깜짝 이벤트 준비")
     private String memo;
@@ -155,6 +156,9 @@ public static class QsheetCreateDto {
 		private List data;
         @Schema(title = "메모", type="String", example = "신랑 깜짝 이벤트 준비")
         private String memo;
+        @NotNull
+        @Schema(title = "타입", type="String", example = "template or user")
+        private String type;
         @Schema(title = "업체 확인자 정보",type="String",example = "38352658567418867")
         private String org_approverSeq;
         @Schema(title = "업체 확인", type="Boolean", example = "false")
diff --git a/nw/src/main/java/lab/cherry/nw/repository/QsheetRepository.java b/nw/src/main/java/lab/cherry/nw/repository/QsheetRepository.java
index d0befb8..f5dc45a 100644
--- a/nw/src/main/java/lab/cherry/nw/repository/QsheetRepository.java
+++ b/nw/src/main/java/lab/cherry/nw/repository/QsheetRepository.java
@@ -7,6 +7,7 @@
 import org.springframework.data.mongodb.repository.MongoRepository;
 import org.springframework.data.mongodb.repository.Query;
 import lab.cherry.nw.model.QsheetEntity;
+import lab.cherry.nw.model.RoleEntity;
 
 /**
  * 
@@ -22,8 +23,8 @@ public interface QsheetRepository extends MongoRepository
 
     @Query("{'user.$_id' : ?0}")
     Page findPageByUserid(String userSeq, Pageable pageable);
-    @Query("{'org.$_id' : ?0}")
-    Page findPageByOrgid(String orgSeq, Pageable pageable);
+    @Query("{ 'org.$_id' : ?0 ,'type' : ?1 }")
+    Page findPageByOrgid(String orgSeq, String type, Pageable pageable);
 
     Optional findById(String id);
     void deleteById(UUID id);
diff --git a/nw/src/main/java/lab/cherry/nw/service/Impl/QsheetServiceImpl.java b/nw/src/main/java/lab/cherry/nw/service/Impl/QsheetServiceImpl.java
index c39ff9b..7e044c1 100644
--- a/nw/src/main/java/lab/cherry/nw/service/Impl/QsheetServiceImpl.java
+++ b/nw/src/main/java/lab/cherry/nw/service/Impl/QsheetServiceImpl.java
@@ -149,6 +149,7 @@ public QsheetEntity createQsheet(QsheetEntity.QsheetCreateDto qsheetCreateDto, L
             .org(orgEntity)
             .name(qsheetCreateDto.getName())
             .data(newItemData)
+            .type(qsheetCreateDto.getType())
             // .data(qsheetCreateDto.getData())
             .memo(qsheetCreateDto.getMemo())
             .org_approver(orgUserEntity)
@@ -259,6 +260,7 @@ public void updateById(String id, QsheetEntity.QsheetUpdateDto qsheetUpdateDto,
             .org_confirm(qsheetUpdateDto.isOrg_confirm()==!(qsheetEntity.isOrg_confirm())?qsheetUpdateDto.isOrg_confirm():qsheetEntity.isOrg_confirm())
             .client_confirm(qsheetUpdateDto.isClient_confirm()==!(qsheetEntity.isClient_confirm())?qsheetUpdateDto.isClient_confirm():qsheetEntity.isClient_confirm())
             .memo(qsheetUpdateDto.getMemo()!=null?qsheetUpdateDto.getMemo():qsheetEntity.getMemo())
+            .type(qsheetEntity.getType())
 			.updated_at(instant)
 			.build();
 			qsheetRepository.save(qsheetEntity);
@@ -345,8 +347,8 @@ public Page findPageByUserId(String userSeq, Pageable pageable) {
     }
 
     @Transactional(readOnly = true)
-    public Page findPageByOrgId(String orgSeq, Pageable pageable) {
-        return qsheetRepository.findPageByOrgid(orgSeq, pageable);
+    public Page findPageByOrgId(String orgSeq, String type, Pageable pageable) {
+        return qsheetRepository.findPageByOrgid(orgSeq, type, pageable);
     }
     
     public Map download(String[] qsheetIds) {
diff --git a/nw/src/main/java/lab/cherry/nw/service/QsheetService.java b/nw/src/main/java/lab/cherry/nw/service/QsheetService.java
index 7494cf7..e53106b 100644
--- a/nw/src/main/java/lab/cherry/nw/service/QsheetService.java
+++ b/nw/src/main/java/lab/cherry/nw/service/QsheetService.java
@@ -1,6 +1,7 @@
 package lab.cherry.nw.service;
 
 import lab.cherry.nw.model.QsheetEntity;
+import lab.cherry.nw.model.RoleEntity;
 import java.util.List;
 import java.util.Map;
 import org.springframework.data.domain.Page;
@@ -24,7 +25,7 @@ public interface QsheetService {
  void updateById(String id, QsheetEntity.QsheetUpdateDto updateDto, List files);
  void deleteById(String id);
  Page findPageByUserId(String userSeq, Pageable pageable);
- Page findPageByOrgId(String orgSeq, Pageable pageable);
+ Page findPageByOrgId(String orgSeq, String type, Pageable pageable);
 // void updateOrgById(String id, List orgIds);
 Map download(String[] qsheetSeq);
 }
\ No newline at end of file