Skip to content

Commit

Permalink
Merge pull request #69 from lab-cherry/yby654
Browse files Browse the repository at this point in the history
Chore : 큐시트 타입 추가
  • Loading branch information
taking authored Nov 9, 2023
2 parents 8a0f1b6 + e4eccd0 commit d04351f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
24 changes: 14 additions & 10 deletions nw/src/main/java/lab/cherry/nw/model/QsheetEntity.java
Original file line number Diff line number Diff line change
@@ -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;

/**
* <pre>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -155,6 +156,9 @@ public static class QsheetCreateDto {
private List<ItemData> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <pre>
Expand All @@ -22,8 +23,8 @@ public interface QsheetRepository extends MongoRepository<QsheetEntity, String>

@Query("{'user.$_id' : ?0}")
Page<QsheetEntity> findPageByUserid(String userSeq, Pageable pageable);
@Query("{'org.$_id' : ?0}")
Page<QsheetEntity> findPageByOrgid(String orgSeq, Pageable pageable);
@Query("{ 'org.$_id' : ?0 ,'type' : ?1 }")
Page<QsheetEntity> findPageByOrgid(String orgSeq, String type, Pageable pageable);

Optional<QsheetEntity> findById(String id);
void deleteById(UUID id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -345,8 +347,8 @@ public Page<QsheetEntity> findPageByUserId(String userSeq, Pageable pageable) {
}

@Transactional(readOnly = true)
public Page<QsheetEntity> findPageByOrgId(String orgSeq, Pageable pageable) {
return qsheetRepository.findPageByOrgid(orgSeq, pageable);
public Page<QsheetEntity> findPageByOrgId(String orgSeq, String type, Pageable pageable) {
return qsheetRepository.findPageByOrgid(orgSeq, type, pageable);
}

public Map<String, Object> download(String[] qsheetIds) {
Expand Down
3 changes: 2 additions & 1 deletion nw/src/main/java/lab/cherry/nw/service/QsheetService.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,7 +25,7 @@ public interface QsheetService {
void updateById(String id, QsheetEntity.QsheetUpdateDto updateDto, List<MultipartFile> files);
void deleteById(String id);
Page<QsheetEntity> findPageByUserId(String userSeq, Pageable pageable);
Page<QsheetEntity> findPageByOrgId(String orgSeq, Pageable pageable);
Page<QsheetEntity> findPageByOrgId(String orgSeq, String type, Pageable pageable);
// void updateOrgById(String id, List<String> orgIds);
Map<String, Object> download(String[] qsheetSeq);
}

0 comments on commit d04351f

Please sign in to comment.