feat: entity scope 조정 에러 fix

dev
minuk926 3 years ago
parent 4bc557ee84
commit dc6402cadd

@ -64,14 +64,7 @@ public class CtgyFileMgtController {
public ResponseEntity<? extends IRestResponse> savePublicBoardFiles(@Nonnull MinInfoBoard680Dto dto) { public ResponseEntity<? extends IRestResponse> savePublicBoardFiles(@Nonnull MinInfoBoard680Dto dto) {
AssertUtils.isTrue(!Checks.isEmpty(dto), "파일 정보가 존재하지 않습니다."); AssertUtils.isTrue(!Checks.isEmpty(dto), "파일 정보가 존재하지 않습니다.");
MinInfoBoard680 minInfoBoard680 = MinInfoBoard680.builder() return RestResponse.of(service.saveFiles(dto));
.inCode(dto.getInCode())
.inDept(dto.getInDept())
.inTitle(dto.getInTitle())
.inContents(dto.getInContents())
.inFilename(dto.getInFilename())
.build();
return RestResponse.of(service.saveFiles(minInfoBoard680, dto.getFiles()));
} }
@Operation(summary = "공지사항 삭제", description = "공지사항 삭제") @Operation(summary = "공지사항 삭제", description = "공지사항 삭제")

@ -10,7 +10,6 @@ import java.sql.Date;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder
public class MinSimsaReviewGroupDto { public class MinSimsaReviewGroupDto {
private Date msEdate; private Date msEdate;
private String msuTeam; private String msuTeam;

@ -1,9 +1,7 @@
package com.xit.biz.ctgy.entity; package com.xit.biz.ctgy.entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel; import lombok.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
@ -11,12 +9,14 @@ import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@Schema(name = "MinCivBoard680", description = "게시판") @Schema(name = "MinCivBoard680", description = "게시판")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Data
@Entity
@Table(name = "min_civ_board680", schema = "", catalog = "") @Table(name = "min_civ_board680", schema = "", catalog = "")
@Entity
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@Builder
public class MinCivBoard680 implements Serializable { public class MinCivBoard680 implements Serializable {
private static final long SerialVersionUID = 1L; private static final long SerialVersionUID = 1L;

@ -1,5 +1,6 @@
package com.xit.biz.ctgy.entity; package com.xit.biz.ctgy.entity;
import com.xit.biz.ctgy.CtgyConstants;
import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.oauth2.utils.HeaderUtil;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
@ -17,7 +18,6 @@ import java.time.format.DateTimeFormatter;
@NoArgsConstructor(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
@Setter
@Builder @Builder
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@ -48,6 +48,7 @@ public class MinInfoBoard680 implements Serializable {
@Schema(required = false, title = "부서", example = " ", description = "Input Description...") @Schema(required = false, title = "부서", example = " ", description = "Input Description...")
@Column(name = "in_dept", nullable = true) @Column(name = "in_dept", nullable = true)
@Setter
private String inDept; private String inDept;
@Schema(required = false, title = "글번호", example = " ", description = "Input Description...") @Schema(required = false, title = "글번호", example = " ", description = "Input Description...")
@ -56,10 +57,12 @@ public class MinInfoBoard680 implements Serializable {
@Schema(required = false, title = "제목", example = " ", description = "Input Description...") @Schema(required = false, title = "제목", example = " ", description = "Input Description...")
@Column(name = "in_title", nullable = true) @Column(name = "in_title", nullable = true)
@Setter
private String inTitle; private String inTitle;
@Schema(required = false, title = "내용", example = " ", description = "Input Description...") @Schema(required = false, title = "내용", example = " ", description = "Input Description...")
@Column(name = "in_contents", nullable = true) @Column(name = "in_contents", nullable = true)
@Setter
private String inContents; private String inContents;
@Schema(required = false, title = "조회수", example = " ", description = "Input Description...") @Schema(required = false, title = "조회수", example = " ", description = "Input Description...")
@ -68,23 +71,28 @@ public class MinInfoBoard680 implements Serializable {
@Schema(required = false, title = "파일명", example = " ", description = "Input Description...") @Schema(required = false, title = "파일명", example = " ", description = "Input Description...")
@Column(name = "in_filename", nullable = true) @Column(name = "in_filename", nullable = true)
@Setter
private String inFilename; private String inFilename;
@Schema(required = false, title = "파일사이즈", example = " ", description = "Input Description...") @Schema(required = false, title = "파일사이즈", example = " ", description = "Input Description...")
@Column(name = "in_filesize", nullable = true) @Column(name = "in_filesize", nullable = true)
@Setter
private Long inFilesize; private Long inFilesize;
@Schema(required = false, title = "파일URL", example = " ", description = "Input Description...") @Schema(required = false, title = "파일URL", example = " ", description = "Input Description...")
@Column(name = "in_fileurl", nullable = true) @Column(name = "in_fileurl", nullable = true)
@Setter
private String inFileurl; private String inFileurl;
@Schema(required = false, title = "기타", example = " ", description = "Input Description...") @Schema(required = false, title = "기타", example = " ", description = "Input Description...")
@Column(name = "in_etc", nullable = true) @Column(name = "in_etc", nullable = true)
@Setter
private String inEtc; private String inEtc;
@PrePersist @PrePersist
public void onPrePersist(){ public void onPrePersist(){
LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime localDateTime = LocalDateTime.now();
this.inBgubun = CtgyConstants.PublicBoard.GUBUN.getCode();
this.inNalja = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); this.inNalja = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
this.inTime = localDateTime.format(DateTimeFormatter.ofPattern("HH:mm")); this.inTime = localDateTime.format(DateTimeFormatter.ofPattern("HH:mm"));
this.inName = HeaderUtil.getUserName(); this.inName = HeaderUtil.getUserName();

@ -1,11 +1,9 @@
package com.xit.biz.ctgy.entity; package com.xit.biz.ctgy.entity;
import com.xit.biz.cmm.entity.ids.CmmCodeLIds;
import com.xit.biz.ctgy.entity.ids.MinMaincodePK; import com.xit.biz.ctgy.entity.ids.MinMaincodePK;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Data; import lombok.*;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
@ -13,13 +11,15 @@ import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@Schema(name = "MinMaincode", description = "코드") @Schema(name = "MinMaincode", description = "코드")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Data
@Entity
@Table(name = "min_maincode", schema = "", catalog = "") @Table(name = "min_maincode", schema = "", catalog = "")
@Entity
@IdClass(MinMaincodePK.class) @IdClass(MinMaincodePK.class)
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
public class MinMaincode implements Serializable { public class MinMaincode implements Serializable {
private static final long SerialVersionUID = 1L; private static final long SerialVersionUID = 1L;

@ -1,9 +1,7 @@
package com.xit.biz.ctgy.entity; package com.xit.biz.ctgy.entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel; import lombok.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
@ -11,12 +9,14 @@ import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@Schema(name = "Tf680Recall", description = "민원") @Schema(name = "Tf680Recall", description = "민원")
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED)
@Data @Data
@Entity @Entity
@Table(name = "tf680_recall", schema = "", catalog = "") @Table(name = "tf680_recall", schema = "", catalog = "")
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@Builder
public class Tf680Recall implements Serializable { public class Tf680Recall implements Serializable {
private static final long SerialVersionUID = 1L; private static final long SerialVersionUID = 1L;

@ -1,5 +1,6 @@
package com.xit.biz.ctgy.service; package com.xit.biz.ctgy.service;
import com.xit.biz.ctgy.dto.MinInfoBoard680Dto;
import com.xit.biz.ctgy.entity.MinInfoBoard680; import com.xit.biz.ctgy.entity.MinInfoBoard680;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -13,7 +14,7 @@ import java.util.List;
public interface ICtgyFileService { public interface ICtgyFileService {
MinInfoBoard680 findFiles(Long inCode); MinInfoBoard680 findFiles(Long inCode);
List<MinInfoBoard680> saveFiles(@Nonnull MinInfoBoard680 minInfoBoard680, MultipartFile[] files); List<MinInfoBoard680> saveFiles(@Nonnull MinInfoBoard680Dto dto);
void removePublicBoardFile(Long inCode); void removePublicBoardFile(Long inCode);
} }

@ -1,6 +1,7 @@
package com.xit.biz.ctgy.service.impl; package com.xit.biz.ctgy.service.impl;
import com.xit.biz.ctgy.CtgyConstants; import com.xit.biz.ctgy.dto.MinInfoBoard680Dto;
import com.xit.biz.ctgy.dto.struct.MinInfoBoard680Mapstruct;
import com.xit.biz.ctgy.entity.MinInfoBoard680; import com.xit.biz.ctgy.entity.MinInfoBoard680;
import com.xit.biz.ctgy.repository.IPublicBoardRepository; import com.xit.biz.ctgy.repository.IPublicBoardRepository;
import com.xit.biz.ctgy.service.ICtgyFileService; import com.xit.biz.ctgy.service.ICtgyFileService;
@ -13,6 +14,7 @@ import com.xit.core.util.DateUtil;
import io.jsonwebtoken.lang.Assert; import io.jsonwebtoken.lang.Assert;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.mapstruct.factory.Mappers;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -47,6 +49,7 @@ public class CtgyFileService implements ICtgyFileService {
private long maxSize; private long maxSize;
private final IPublicBoardRepository repository; private final IPublicBoardRepository repository;
private final MinInfoBoard680Mapstruct mapstruct = Mappers.getMapper(MinInfoBoard680Mapstruct.class);
@Override @Override
public MinInfoBoard680 findFiles(Long inCode) { public MinInfoBoard680 findFiles(Long inCode) {
@ -60,14 +63,14 @@ public class CtgyFileService implements ICtgyFileService {
* CmmFileMst.fileMstId null, not null * CmmFileMst.fileMstId null, not null
* DB * DB
* *
* @param entity MinInfoBoard680 * @param dto MinInfoBoard680Dto
* @param files MultipartFile[]
* @return CmmFileMst * @return CmmFileMst
*/ */
@Override @Override
@Transactional @Transactional
public List<MinInfoBoard680> saveFiles(@Nonnull MinInfoBoard680 entity, MultipartFile[] files) { public List<MinInfoBoard680> saveFiles(@Nonnull MinInfoBoard680Dto dto) {
List<MinInfoBoard680> entityList = new ArrayList<>(); List<MinInfoBoard680> entityList = new ArrayList<>();
MultipartFile[] files = dto.getFiles();
if(files != null && files.length > 0){ if(files != null && files.length > 0){
String makePath = File.separator + DateUtil.getToday(""); String makePath = File.separator + DateUtil.getToday("");
@ -87,15 +90,21 @@ public class CtgyFileService implements ICtgyFileService {
MinInfoBoard680 savedEntity = null; MinInfoBoard680 savedEntity = null;
// 파일 저장 && 전송 // 파일 저장 && 전송
if(Checks.isEmpty(entity.getInCode())) if(Checks.isEmpty(dto.getInCode())) {
savedEntity = new MinInfoBoard680(); dto.setInCode(repository.getInCodeByInBgubun());
else dto.setInContentno(dto.getInCode());
savedEntity = repository.findById(entity.getInCode()).orElseGet(MinInfoBoard680::new); dto.setInFilename(orgFileName);
dto.setInFilesize(mf.getSize());
dto.setInFileurl(serviceUrl + urlPath);
savedEntity = mapstruct.toEntity(dto); //MinInfoBoard680.builder().build();
}else {
savedEntity = repository.findById(dto.getInCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND));
savedEntity.setInFilename(orgFileName); savedEntity.setInFilename(orgFileName);
savedEntity.setInFilesize(mf.getSize()); savedEntity.setInFilesize(mf.getSize());
savedEntity.setInFileurl(serviceUrl + urlPath); savedEntity.setInFileurl(serviceUrl + urlPath);
setEntity(savedEntity, entity); setEntity(savedEntity, dto);
JpaUtil.saveIfNullId(entity.getInCode(), repository, savedEntity); }
JpaUtil.saveIfNullId(dto.getInCode(), repository, savedEntity);
entityList.add(savedEntity); entityList.add(savedEntity);
mf.transferTo(new File(fileUploadPath + File.separator + orgFileName)); mf.transferTo(new File(fileUploadPath + File.separator + orgFileName));
@ -115,13 +124,15 @@ public class CtgyFileService implements ICtgyFileService {
} }
}else{ }else{
MinInfoBoard680 savedEntity = null; MinInfoBoard680 savedEntity = null;
if(Checks.isEmpty(entity.getInCode())) if(Checks.isEmpty(dto.getInCode())) {
savedEntity = new MinInfoBoard680(); dto.setInCode(repository.getInCodeByInBgubun());
else dto.setInContentno(dto.getInCode());
savedEntity = repository.findById(entity.getInCode()).orElseGet(MinInfoBoard680::new); savedEntity = mapstruct.toEntity(dto);
}else {
setEntity(savedEntity, entity); savedEntity = repository.findById(dto.getInCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND));
JpaUtil.saveIfNullId(entity.getInCode(), repository, savedEntity); setEntity(savedEntity, dto);
}
JpaUtil.saveIfNullId(dto.getInCode(), repository, savedEntity);
} }
return entityList; return entityList;
} }
@ -146,16 +157,10 @@ public class CtgyFileService implements ICtgyFileService {
} }
private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680 entity){ private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680Dto dto){
savedEntity.setInBgubun(CtgyConstants.PublicBoard.GUBUN.getCode()); savedEntity.setInDept(dto.getInDept());
savedEntity.setInDept(entity.getInDept()); savedEntity.setInTitle(dto.getInTitle());
savedEntity.setInTitle(entity.getInTitle()); savedEntity.setInContents(dto.getInContents());
savedEntity.setInContents(entity.getInContents());
if(Checks.isEmpty(entity.getInCode())) {
savedEntity.setInCode(repository.getInCodeByInBgubun());
savedEntity.setInContentno(savedEntity.getInCode());
}
} }
} }

@ -82,7 +82,7 @@ public class ParkingService implements IParkingService {
mapper.insertSimsaTargetIntoSelect(dto); mapper.insertSimsaTargetIntoSelect(dto);
// 등록된 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수 // 등록된 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수
Tf680Recall recallEntity = recallRepository.findById(dto.getRcCode()).orElseGet(Tf680Recall::new); Tf680Recall recallEntity = recallRepository.findById(dto.getRcCode()).orElseGet(()->Tf680Recall.builder().build());
recallEntity.setRcIrTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); recallEntity.setRcIrTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode());
JpaUtil.saveIfNullId(recallEntity.getRcCode(), recallRepository, recallEntity); JpaUtil.saveIfNullId(recallEntity.getRcCode(), recallRepository, recallEntity);

@ -17,8 +17,8 @@ api:
file: file:
cmm: cmm:
upload: upload:
# root: c:/data/file/upload root: c:/data/file/upload
root: /Users/minuk/data/file/upload # root: /Users/minuk/data/file/upload
# 공지사항 # 공지사항
path: /kangnamSIM/simUpFile path: /kangnamSIM/simUpFile
publicPath: simUpFile #/kangnamSIM/simUpFile publicPath: simUpFile #/kangnamSIM/simUpFile

Loading…
Cancel
Save