Skip to content

Commit

Permalink
Merge pull request #73 from taking/taking
Browse files Browse the repository at this point in the history
Chore: getQsheet params share={Boolean} added
  • Loading branch information
taking authored Nov 13, 2023
2 parents 5fccdb3 + 37ee106 commit 7581d05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
http
.authorizeHttpRequests()
.requestMatchers(HttpMethod.GET, "/api/v1/org/{orgSeq}").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/qsheet/{qsheetSeq}").permitAll()
.requestMatchers(
"/api/auth/**",
"/docs/**",
Expand Down
12 changes: 9 additions & 3 deletions nw/src/main/java/lab/cherry/nw/controller/QsheetController.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,18 @@ public ResponseEntity<?> deleteById(@PathVariable("id") String id) {
*/
@GetMapping("{id}")
@Operation(summary = "ID로 큐시트 찾기", description = "큐시트를 조회합니다.")
public ResponseEntity<?> findByQsheetId(@PathVariable("id") String id) {
public ResponseEntity<?> findByQsheetId(@PathVariable("id") String id,
@RequestParam(required = false, defaultValue = "false") Boolean share) {

log.info("[QsheetController] findByQsheetId...!");

// final ResultResponse response = ResultResponse.of(SuccessCode.OK, userService.findById(id));
return new ResponseEntity<>(qsheetService.findById(id), new HttpHeaders(), HttpStatus.OK);
if(share) {
List<QsheetEntity.ItemData> qsheetData = qsheetService.findByIdWithData(id);
return new ResponseEntity<>(qsheetData, new HttpHeaders(), HttpStatus.OK);
} else {
QsheetEntity qsheetEntity = qsheetService.findById(id);
return new ResponseEntity<>(qsheetEntity, new HttpHeaders(), HttpStatus.OK);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ public QsheetEntity findById(String id) {
return qsheetRepository.findById(id).orElseThrow(() -> new EntityNotFoundException("Qsheet with Id " + id + " Not Found."));
}

@Transactional(readOnly = true)
public List<QsheetEntity.ItemData> findByIdWithData(String id) {
QsheetEntity qsheetEntity = findById(id);
return qsheetEntity.getData();
}

@Transactional(readOnly = true)
public Page<QsheetEntity> findPageByUserId(String userSeq, Pageable pageable) {
return qsheetRepository.findPageByUserid(userSeq, pageable);
Expand Down
3 changes: 3 additions & 0 deletions nw/src/main/java/lab/cherry/nw/service/QsheetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import lab.cherry.nw.model.QsheetEntity;
Expand All @@ -19,6 +20,7 @@
@Component
public interface QsheetService {
Page<QsheetEntity> getQsheets(Pageable pageable);
@PreAuthorize("hasAnyRole('ADMIN','ORG')")
QsheetEntity findById(String id);
QsheetEntity createQsheet(QsheetEntity.QsheetCreateDto qsheetCreateDto, List<MultipartFile> files);
void updateById(String id, QsheetEntity.QsheetUpdateDto updateDto, List<MultipartFile> files);
Expand All @@ -27,4 +29,5 @@ public interface QsheetService {
Page<QsheetEntity> findPageByOrgId(String orgSeq, String type, Pageable pageable);
// void updateOrgById(String id, List<String> orgIds);
Map<String, Object> download(String[] qsheetSeq);
List<QsheetEntity.ItemData> findByIdWithData(String id);
}

0 comments on commit 7581d05

Please sign in to comment.