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) {
AssertUtils.isTrue(!Checks.isEmpty(dto), "파일 정보가 존재하지 않습니다.");
MinInfoBoard680 minInfoBoard680 = MinInfoBoard680.builder()
.inCode(dto.getInCode())
.inDept(dto.getInDept())
.inTitle(dto.getInTitle())
.inContents(dto.getInContents())
.inFilename(dto.getInFilename())
.build();
return RestResponse.of(service.saveFiles(minInfoBoard680, dto.getFiles()));
return RestResponse.of(service.saveFiles(dto));
}
@Operation(summary = "공지사항 삭제", description = "공지사항 삭제")

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

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

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

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

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

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

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

@ -82,7 +82,7 @@ public class ParkingService implements IParkingService {
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());
JpaUtil.saveIfNullId(recallEntity.getRcCode(), recallRepository, recallEntity);

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

Loading…
Cancel
Save