Skip to content

Commit

Permalink
Merge pull request #78 from lab-cherry/haeri
Browse files Browse the repository at this point in the history
Haeri
  • Loading branch information
taking authored Nov 14, 2023
2 parents aaaeb51 + c058988 commit 31f9582
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 89 deletions.
23 changes: 23 additions & 0 deletions nw/src/main/java/lab/cherry/nw/controller/FinaldocsController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lab.cherry.nw.controller;

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 @@ -156,6 +157,28 @@ public ResponseEntity<?> findById(@PathVariable("id") String id) {
return new ResponseEntity<>(finaldocsService.findById(id), new HttpHeaders(), HttpStatus.OK);
}

/**
* [FinaldocsController] 특정 최종확인서 조회 함수
*
* @param id 최종확인서 고유번호를 입력합니다.
* @return
* <pre>
* true : 특정 최종확인서 정보를 반환합니다.
* false : 에러(400, 404)를 반환합니다.
* </pre>
*
* Author : hhhaeri(yhoo0020@gmail.com)
*/
@GetMapping("/user/{userid}")
@Operation(summary = "User Id 로 최종확인서 찾기", description = "최종확인서를 조회합니다.")
public ResponseEntity<?> findByUserId(@PathVariable("userid") String userid) {

log.info("[FinaldocsController] findByFinaldocsId... with userId", userid);

return new ResponseEntity<>(finaldocsService.findByUserId(userid), new HttpHeaders(), HttpStatus.OK);
}


/**
* [FinaldocsController] 특정 최종확인서 삭제 함수
*
Expand Down
110 changes: 68 additions & 42 deletions nw/src/main/java/lab/cherry/nw/model/FinaldocsEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.Serializable;
import java.time.Instant;
import java.util.List;
import java.util.Map;

/**
* <pre>
Expand All @@ -40,33 +39,37 @@ public class FinaldocsEntity implements Serializable {
@Schema(title = "최종확인서 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String id;

@NotNull
@JsonProperty("finaltempl")
@Schema(title = "최종확인서 템플릿 정보", example = "64ed89aa9e813b5ab16da6de")
private FinalTemplEntity finaltempl;

@NotNull
@DBRef
@JsonProperty("user")
@Schema(title = "사용자 정보", example = "64ed89aa9e813b5ab16da6de")
@Schema(title = "유저 정보") // (Long) Tsid
private UserEntity user;

@NotNull
@DBRef
@JsonProperty("org")
@Schema(title = "조직 정보", example = "64ed89aa9e813b5ab16da6de")
@Schema(title = "조직 정보") // (Long) Tsid
private OrgEntity org;

@NotNull
@JsonProperty("finaldocsName")
@Schema(title = "최종확인서 이름", example = "11시 그랜드 최종 확인서")
@Size(min = 4, max = 255, message = "Minimum name length: 4 characters")
private String name;
@DBRef
@JsonProperty("finaltempl")
@Schema(title = "최종확인서 템플릿 정보", example = "64ed89aa9e813b5ab16da6de")
private FinalTemplEntity finaltempl;

@JsonProperty("content")
@Schema(title = "최종확인서 내용", example = "")
private List<Object> content;

@DBRef
@JsonProperty("org_approver")
@Schema(title = "업체 확인자 정보",type="String",example = "38352658567418867")
private UserEntity org_approver;

@JsonProperty("org_confirm")
@Schema(title = "업체 확인", type="Boolean", example = "false")
private boolean org_confirm;

@JsonProperty("client_confirm")
@Schema(title = "신랑신부 확인", type="Boolean", example = "false")
private boolean client_confirm;

@JsonProperty("updated_at")
@JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul")
Expand All @@ -78,6 +81,21 @@ public class FinaldocsEntity implements Serializable {
@Schema(title = "최종확인서 생성 시간", example = "2023-07-04 12:00:00")
private Instant createdAt;

//////////////////////////////////////////////////////////////////////////

@Getter
@Builder
@NoArgsConstructor @AllArgsConstructor
public static class FinaldocsFinalConfirm {
@Schema(title = "업체 확인자 정보", type="String", example = "38352658567418867")
private String org_approver;

@Schema(title = "업체 확인", type="Boolean", example = "false")
private boolean org_confirm;

@Schema(title = "신랑신부 확인", type="Boolean", example = "false")
private boolean client_confirm;
}

//////////////////////////////////////////////////////////////////////////

Expand All @@ -86,31 +104,33 @@ public class FinaldocsEntity implements Serializable {
@NoArgsConstructor @AllArgsConstructor
public static class FinaldocsCreateDto {

@NotBlank
@Schema(title = "최종확인서 이름", example = "11시 그랜드 최종 확인서")
@Size(min = 4, max = 255, message = "Minimum name length: 4 characters")
private String name;
// @NotBlank
// @Schema(title = "최종확인서 이름", example = "11시 그랜드 최종 확인서")
// @Size(min = 4, max = 255, message = "Minimum name length: 4 characters")
// private String name;

@Schema(title = "사용자 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String userSeq;

@NotBlank
@JsonProperty("user")
@Schema(title = "사용자 정보", example = "64ed89aa9e813b5ab16da6de")
private String user;
@Schema(title = "조직 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String orgSeq;

@NotBlank
@JsonProperty("org")
@Schema(title = "조직 정보", example = "64ed89aa9e813b5ab16da6de")
private String org;
@Schema(title = "최종확인서 템플릿 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String finaltemplSeq;

@NotBlank
@JsonProperty("finaltempl")
@Schema(title = "최종확인서 템플릿 정보", example = "64ed89aa9e813b5ab16da6de")
private String finaltempl;

// @NotBlank
@JsonProperty("content")
@Schema(title = "최종확인서 내용", example = "")
private List<Object> content;

@Schema(title = "업체 확인자 정보",type="String",example = "38352658567418867")
private String org_approverSeq;

@Schema(title = "업체 확인", type="Boolean", example = "false")
private boolean org_confirm;

@Schema(title = "신랑신부 확인", type="Boolean", example = "false")
private boolean client_confirm;


}

Expand All @@ -120,21 +140,27 @@ public static class FinaldocsCreateDto {
@NoArgsConstructor @AllArgsConstructor
public static class FinaldocsUpdateDto {

@Schema(title = "최종확인서 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String id;

@Schema(title = "최종확인서 템플릿 정보", example = "64ed89aa9e813b5ab16da6de")
private String finaltempl;
@Schema(title = "최종확인서 템플릿 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String finaltemplSeq;

@Schema(title = "사용자 정보", example = "64ed89aa9e813b5ab16da6de")
private String user;
@Schema(title = "사용자 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String userSeq;

@Schema(title = "조직 정보", example = "64ed89aa9e813b5ab16da6de")
private String org;
@Schema(title = "조직 고유번호", example = "64ed89aa9e813b5ab16da6de")
private String orgSeq;

@Schema(title = "최종확인서 내용", example = "")
private List<Object> content;

@Schema(title = "업체 확인자 정보",type="String",example = "38352658567418867")
private String org_approverSeq;

@Schema(title = "업체 확인", type="Boolean", example = "false")
private boolean org_confirm;

@Schema(title = "신랑신부 확인", type="Boolean", example = "false")
private boolean client_confirm;


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import org.bson.types.ObjectId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import lab.cherry.nw.model.BookmarkEntity;
import lab.cherry.nw.model.FinaldocsEntity;
import lab.cherry.nw.model.UserCardEntity;


/**
Expand All @@ -22,14 +26,17 @@ public interface FinaldocsRepository extends MongoRepository<FinaldocsEntity, St

Page<FinaldocsEntity> findAll(Pageable pageable);

Page<FinaldocsEntity> findPageByName(String finaldocsName, Pageable pageable);
// Page<FinaldocsEntity> findPageByName(String finaldocsName, Pageable pageable);

Page<FinaldocsEntity> findPageById(String id, Pageable pageable);

Optional<FinaldocsEntity> findById(String id);

Optional<FinaldocsEntity> findByName(String finaldocsName);
// Optional<FinaldocsEntity> findByName(String finaldocsName);

List<FinaldocsEntity> findAllBycreatedAtBetween(Instant start, Instant end);

@Query("{'user.$_id' : ?0}")
Optional<FinaldocsEntity> findByUserid(String userid);

}
12 changes: 8 additions & 4 deletions nw/src/main/java/lab/cherry/nw/service/FinaldocsService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package lab.cherry.nw.service;

import java.util.Optional;
import org.bson.types.ObjectId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import lab.cherry.nw.model.BookmarkEntity;
import lab.cherry.nw.model.FinaldocsEntity;
import lab.cherry.nw.model.UserCardEntity;

/**
* <pre>
Expand All @@ -17,11 +21,11 @@
public interface FinaldocsService {
Page<FinaldocsEntity> getFinaldocs(Pageable pageable);
FinaldocsEntity createFinaldocs(FinaldocsEntity.FinaldocsCreateDto finaldocsCreateDto);
void updateById(String id, FinaldocsEntity.FinaldocsUpdateDto finaldocs);
void updateById(String id, FinaldocsEntity.FinaldocsUpdateDto finaldocsUpdateDto);
FinaldocsEntity findById(String id);
FinaldocsEntity findByName(String name);
FinaldocsEntity findByUserId(String userId);
// FinaldocsEntity findByName(String name);
void deleteById(String id);
Boolean Approval(Boolean Yn);
Page<FinaldocsEntity> findPageByName(String name, Pageable pageable);
// Page<FinaldocsEntity> findPageByName(String name, Pageable pageable);
Page<FinaldocsEntity> findPageById(String id, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void deleteById(String id) {


/**
* [FinalTemplServiceImpl] ID로 최종확인서 템플릿 조회 함수
* [FinalTemplServiceImpl] ID로 최종확인서 템플릿 조회 함수
*
* @param id 조회할 최종확인서 템플릿의 식별자입니다.
* @return 주어진 식별자에 해당하는 조직 정보
Expand All @@ -156,7 +156,6 @@ public void deleteById(String id) {
// return finaldocsRepository.findByName(name).orElseThrow(() -> new EntityNotFoundException("Fianldocs with Id " + name + " Not Found."));
// }


@Transactional(readOnly = true)
public FinalTemplEntity findById(String id) {
return finalTemplRepository.findById(id).orElseThrow(() -> new EntityNotFoundException("finalTempl with Id " + id + " Not Found."));
Expand Down
Loading

0 comments on commit 31f9582

Please sign in to comment.