fix: 양방향 entity 문제

dev
Lim Jonguk 3 years ago
parent edaf2d89e4
commit a4e78c5504

@ -129,23 +129,23 @@ dependencies {
//compileOnly 'com.querydsl:querydsl-apt' //compileOnly 'com.querydsl:querydsl-apt'
// JPA mapstruct : lombok - lombok // JPA mapstruct : lombok - lombok
// implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0' implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
// implementation 'org.projectlombok:lombok' implementation 'org.projectlombok:lombok'
// implementation 'org.mapstruct:mapstruct:1.4.2.Final' implementation 'org.mapstruct:mapstruct:1.4.2.Final'
// annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0" annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0"
// annotationProcessor 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok'
// annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
// JPA mapstruct : lombok - mapstruct // JPA mapstruct : lombok - mapstruct
// target class @Builder + setter Mapper Generation // target class @Builder + setter Mapper Generation
// @NoArgsConstructor, @Setter // @NoArgsConstructor, @Setter
// but, Setter mapstruct @Builder Generation // but, Setter mapstruct @Builder Generation
implementation 'org.mapstruct:mapstruct:1.4.2.Final' // implementation 'org.mapstruct:mapstruct:1.4.2.Final'
implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0' // implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
implementation 'org.projectlombok:lombok' // implementation 'org.projectlombok:lombok'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' // annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0" // annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0"
annotationProcessor 'org.projectlombok:lombok' // annotationProcessor 'org.projectlombok:lombok'
//-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------//
@ -224,6 +224,8 @@ dependencies {
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.1' implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.1'
implementation 'com.fasterxml.jackson.module:jackson-module-afterburner:2.13.1' implementation 'com.fasterxml.jackson.module:jackson-module-afterburner:2.13.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.13.1' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.13.1'
// JAP LAZY loading (OneToMay <--> ManyToOne)
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate5'
//implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.5' //implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.5'
// response xml // response xml

@ -1,5 +1,7 @@
package com.xit.biz.cmm.controller; package com.xit.biz.cmm.controller;
import com.xit.biz.cmm.dto.ComboCodeDto;
import com.xit.biz.cmm.dto.IComboCodeDto;
import com.xit.biz.cmm.entity.*; import com.xit.biz.cmm.entity.*;
import com.xit.biz.cmm.entity.ids.CmmCodeSIds; import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
@ -18,11 +20,12 @@ import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.List;
@Tag(name = "CmmCodeMgtController", description = "코드 관리") @Tag(name = "CmmCodeMgtController", description = "코드 관리")
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/api/biz/cmm/callback") @RequestMapping("/api/v1/biz/cmm")
public class CmmCodeMgtController { public class CmmCodeMgtController {
private final ICmmCodeService cmmCodeService; private final ICmmCodeService cmmCodeService;
@ -31,7 +34,9 @@ public class CmmCodeMgtController {
public ResponseEntity<? extends IRestResponse> findComboCodes(@Nonnull final CmmCodeSIds searchKeyDto) { public ResponseEntity<? extends IRestResponse> findComboCodes(@Nonnull final CmmCodeSIds searchKeyDto) {
Assert.notNull(searchKeyDto, "조회할 콤보코드 대상이 없습니다."); Assert.notNull(searchKeyDto, "조회할 콤보코드 대상이 없습니다.");
Assert.notNull(searchKeyDto.getCodeGrpId(), "조회할 대분류 코드를 선택해 주세요."); Assert.notNull(searchKeyDto.getCodeGrpId(), "조회할 대분류 코드를 선택해 주세요.");
return RestResponse.of(cmmCodeService.findComboCodes(searchKeyDto)); List<ComboCodeDto> list = cmmCodeService.findComboCodes(searchKeyDto);
return RestResponse.of(list);
//return RestResponse.of(cmmCodeService.findComboCodes(searchKeyDto));
} }
@Operation(summary = "코드그룹 목록 조회") @Operation(summary = "코드그룹 목록 조회")

@ -1,9 +1,16 @@
package com.xit.biz.cmm.dto; package com.xit.biz.cmm.dto;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Schema(name = "CmmCodeDto", description = "콤보공통코드 DTO") @Schema(name = "CmmCodeDto", description = "콤보공통코드 DTO")
public interface ComboCodeDto {
public String getCode(); @Getter
public String getValue(); @Setter
@AllArgsConstructor
public class ComboCodeDto {
private String code;
private String value;
} }

@ -0,0 +1,10 @@
package com.xit.biz.cmm.dto;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(name = "CmmCodeDto", description = "콤보공통코드 DTO")
public interface IComboCodeDto {
public String getCode();
public String getValue();
}

@ -1,9 +1,10 @@
package com.xit.biz.cmm.repository; package com.xit.biz.cmm.repository;
import com.xit.biz.cmm.dto.ComboCodeDto;
import com.xit.biz.cmm.entity.CmmCodeL; import com.xit.biz.cmm.entity.CmmCodeL;
import com.xit.biz.cmm.entity.ids.CmmCodeLIds; import com.xit.biz.cmm.entity.ids.CmmCodeLIds;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.cmm.dto.IComboCodeDto;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -12,6 +13,6 @@ import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
public interface ICmmCodeLRepostory extends JpaRepository<CmmCodeL, CmmCodeLIds>, JpaSpecificationExecutor<CmmCodeDto> { public interface ICmmCodeLRepostory extends JpaRepository<CmmCodeL, CmmCodeLIds>, JpaSpecificationExecutor<CmmCodeDto> {
@Query(value = "select c.codeCd as code, c.codeNm as value from #{#entityName} c where c.codeGrpId = :codeGrpId and c.useYn = 'Y' order by c.codeOrdr asc") @Query(value = "select new com.xit.biz.cmm.dto.ComboCodeDto(c.codeCd, c.codeNm) from #{#entityName} c where c.codeGrpId = :codeGrpId and c.useYn = 'Y' order by c.codeOrdr asc")
List<ComboCodeDto> queryComboCode(@Param("codeGrpId") String codeGrpId); List<ComboCodeDto> queryComboCode(@Param("codeGrpId") String codeGrpId);
} }

@ -1,9 +1,9 @@
package com.xit.biz.cmm.repository; package com.xit.biz.cmm.repository;
import com.xit.biz.cmm.dto.ComboCodeDto;
import com.xit.biz.cmm.entity.CmmCodeM; import com.xit.biz.cmm.entity.CmmCodeM;
import com.xit.biz.cmm.entity.ids.CmmCodeMIds; import com.xit.biz.cmm.entity.ids.CmmCodeMIds;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
import com.xit.biz.cmm.dto.ComboCodeDto;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -12,6 +12,6 @@ import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
public interface ICmmCodeMRepository extends JpaRepository<CmmCodeM, CmmCodeMIds>, JpaSpecificationExecutor<CmmCodeDto> { public interface ICmmCodeMRepository extends JpaRepository<CmmCodeM, CmmCodeMIds>, JpaSpecificationExecutor<CmmCodeDto> {
@Query(value = "select c.codeCd as code, c.codeNm as value from #{#entityName} c where c.codeGrpId = :codeGrpId and c.codeLcd = :codeLcd and c.useYn = 'Y' order by c.codeOrdr asc") @Query(value = "select new com.xit.biz.cmm.dto.ComboCodeDto(c.codeCd, c.codeNm) from #{#entityName} c where c.codeGrpId = :codeGrpId and c.codeLcd = :codeLcd and c.useYn = 'Y' order by c.codeOrdr asc")
List<ComboCodeDto> queryComboCode(@Param("codeGrpId")String codeGrpId, @Param("codeLcd")String codeLcd); List<ComboCodeDto> queryComboCode(@Param("codeGrpId")String codeGrpId, @Param("codeLcd")String codeLcd);
} }

@ -1,9 +1,10 @@
package com.xit.biz.cmm.repository; package com.xit.biz.cmm.repository;
import com.xit.biz.cmm.dto.ComboCodeDto;
import com.xit.biz.cmm.entity.CmmCodeS; import com.xit.biz.cmm.entity.CmmCodeS;
import com.xit.biz.cmm.entity.ids.CmmCodeSIds; import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.cmm.dto.IComboCodeDto;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -13,5 +14,8 @@ import java.util.List;
public interface ICmmCodeSRepository extends JpaRepository<CmmCodeS, CmmCodeSIds>, JpaSpecificationExecutor<CmmCodeDto> { public interface ICmmCodeSRepository extends JpaRepository<CmmCodeS, CmmCodeSIds>, JpaSpecificationExecutor<CmmCodeDto> {
@Query(value = "select c.codeCd as code, c.codeNm as value from #{#entityName} c where c.codeGrpId = :codeGrpId and c.codeLcd = :codeLcd and c.codeMcd = :codeMcd and c.useYn = 'Y' order by c.codeOrdr asc") @Query(value = "select c.codeCd as code, c.codeNm as value from #{#entityName} c where c.codeGrpId = :codeGrpId and c.codeLcd = :codeLcd and c.codeMcd = :codeMcd and c.useYn = 'Y' order by c.codeOrdr asc")
List<ComboCodeDto> queryComboCode(@Param("codeGrpId")String codeGrpId, @Param("codeLcd")String codeLcd, @Param("codeMcd")String codeMcd); List<IComboCodeDto> queryComboCodeInterface(@Param("codeGrpId")String codeGrpId, @Param("codeLcd")String codeLcd, @Param("codeMcd")String codeMcd);
@Query(value = "select new com.xit.biz.cmm.dto.ComboCodeDto(c.codeCd, c.codeNm) from #{#entityName} c where c.codeGrpId = :codeGrpId and c.codeLcd = :codeLcd and c.codeMcd = :codeMcd and c.useYn = 'Y' order by c.codeOrdr asc")
List<ComboCodeDto> queryComboCodeClass(@Param("codeGrpId")String codeGrpId, @Param("codeLcd")String codeLcd, @Param("codeMcd")String codeMcd);
} }

@ -0,0 +1,16 @@
package com.xit.biz.cmm.repository;
import com.xit.biz.cmm.dto.IComboCodeDto;
import com.xit.biz.cmm.entity.CmmCodeS;
import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface ICmmComboCodeRepository extends JpaRepository<CmmCodeS, CmmCodeSIds>, JpaSpecificationExecutor<IComboCodeDto> {
@Query(value = "SELECT C.code_cd AS code, C.code_nm AS value FROM tb_cmm_code_s C WHERE C.code_grp_id = :codeGrpId AND C.code_lcd = :codeLcd AND C.code_mcd = :codeMcd AND C.use_yn = 'Y' ORDER BY C.code_ordr ASC", nativeQuery = true)
List<IComboCodeDto> queryComboCode(@Param("codeGrpId")String codeGrpId, @Param("codeLcd")String codeLcd, @Param("codeMcd")String codeMcd);
}

@ -3,6 +3,7 @@ package com.xit.biz.cmm.service;
import com.xit.biz.cmm.entity.CmmCodeGrp; import com.xit.biz.cmm.entity.CmmCodeGrp;
import com.xit.biz.cmm.entity.ids.CmmCodeSIds; import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
import com.xit.biz.cmm.dto.IComboCodeDto;
import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.cmm.dto.ComboCodeDto;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;

@ -1,5 +1,6 @@
package com.xit.biz.cmm.service.impl; package com.xit.biz.cmm.service.impl;
import com.xit.biz.cmm.dto.ComboCodeDto;
import com.xit.biz.cmm.dto.struct.CmmCodeGrpMapstruct; import com.xit.biz.cmm.dto.struct.CmmCodeGrpMapstruct;
import com.xit.biz.cmm.dto.struct.CmmCodeLMapstruct; import com.xit.biz.cmm.dto.struct.CmmCodeLMapstruct;
import com.xit.biz.cmm.dto.struct.CmmCodeMMapstruct; import com.xit.biz.cmm.dto.struct.CmmCodeMMapstruct;
@ -10,11 +11,8 @@ import com.xit.biz.cmm.entity.CmmCodeM;
import com.xit.biz.cmm.entity.CmmCodeS; import com.xit.biz.cmm.entity.CmmCodeS;
import com.xit.biz.cmm.entity.ids.CmmCodeSIds; import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.cmm.dto.IComboCodeDto;
import com.xit.biz.cmm.repository.ICmmCodeGrpRepository; import com.xit.biz.cmm.repository.*;
import com.xit.biz.cmm.repository.ICmmCodeLRepostory;
import com.xit.biz.cmm.repository.ICmmCodeMRepository;
import com.xit.biz.cmm.repository.ICmmCodeSRepository;
import com.xit.biz.cmm.service.ICmmCodeService; import com.xit.biz.cmm.service.ICmmCodeService;
import com.xit.core.util.AssertUtils; import com.xit.core.util.AssertUtils;
import com.xit.core.util.Checks; import com.xit.core.util.Checks;
@ -38,6 +36,7 @@ public class CmmCodeService implements ICmmCodeService {
private final ICmmCodeLRepostory cmmCodeLRepository; private final ICmmCodeLRepostory cmmCodeLRepository;
private final ICmmCodeMRepository cmmCodeMRepository; private final ICmmCodeMRepository cmmCodeMRepository;
private final ICmmCodeSRepository cmmCodeSRepository; private final ICmmCodeSRepository cmmCodeSRepository;
private final ICmmComboCodeRepository cmmComboCodeRepository;
private CmmCodeGrpMapstruct codeGrpstruct = Mappers.getMapper(CmmCodeGrpMapstruct.class); private CmmCodeGrpMapstruct codeGrpstruct = Mappers.getMapper(CmmCodeGrpMapstruct.class);
private CmmCodeLMapstruct codeLstruct = Mappers.getMapper(CmmCodeLMapstruct.class); private CmmCodeLMapstruct codeLstruct = Mappers.getMapper(CmmCodeLMapstruct.class);
@ -51,7 +50,10 @@ public class CmmCodeService implements ICmmCodeService {
// 소분류 코드 조회 // 소분류 코드 조회
if(StringUtils.hasText(searchKeyDto.getCodeMcd())){ if(StringUtils.hasText(searchKeyDto.getCodeMcd())){
AssertUtils.isTrue(!Checks.isEmpty(searchKeyDto.getCodeLcd()), "대분류 코드가 선택되지 않았습니다."); AssertUtils.isTrue(!Checks.isEmpty(searchKeyDto.getCodeLcd()), "대분류 코드가 선택되지 않았습니다.");
return cmmCodeSRepository.queryComboCode(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd()); List<ComboCodeDto> list = cmmCodeSRepository.queryComboCodeClass(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd());
//List<IComboCodeDto> list = cmmComboCodeRepository.queryComboCode(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd());
return list;
//return cmmCodeSRepository.queryComboCode(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd());
} }
// 중분류 코드 조회 // 중분류 코드 조회

@ -18,6 +18,7 @@ import com.xit.core.oauth2.utils.CookieUtil;
import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.oauth2.utils.HeaderUtil;
import com.xit.core.util.Checks; import com.xit.core.util.Checks;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@ -168,6 +169,7 @@ public class AuthMinService implements IAuthMinService {
} }
// 5. 토큰 발급 // 5. 토큰 발급
tokenDto.setUser(user);
return tokenDto; return tokenDto;
} }

@ -43,7 +43,7 @@ public class MinCivBoard680Controller {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> findMinCivBoard680s( public ResponseEntity<? extends IRestResponse> findMinCivBoard680s(
@Parameter(hidden = true) @Parameter(hidden = true)
@ModelAttribute("minCivBoard680Dto") //@ModelAttribute("minCivBoard680Dto")
final MinCivBoard680Dto minCivBoard680Dto, final MinCivBoard680Dto minCivBoard680Dto,
@Parameter(hidden = true) @Parameter(hidden = true)
final Pageable pageable) { final Pageable pageable) {

@ -6,6 +6,8 @@ import com.xit.biz.ctgy.dto.struct.MinCivBoard680Mapstruct;
import com.xit.biz.ctgy.dto.struct.MinUserinfoMapstruct; import com.xit.biz.ctgy.dto.struct.MinUserinfoMapstruct;
import com.xit.biz.ctgy.service.IMinCivBoard680Service; import com.xit.biz.ctgy.service.IMinCivBoard680Service;
import com.xit.biz.ctgy.service.IMinUserinfoService; import com.xit.biz.ctgy.service.IMinUserinfoService;
import com.xit.core.annotation.Secured;
import com.xit.core.annotation.SecurityPolicy;
import com.xit.core.api.IRestResponse; import com.xit.core.api.IRestResponse;
import com.xit.core.api.RestResponse; import com.xit.core.api.RestResponse;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -18,6 +20,8 @@ import org.mapstruct.factory.Mappers;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
@ -26,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
@Tag(name = "MinUserinfoController", description = "사용자 관리") @Tag(name = "MinUserinfoController", description = "사용자 관리")
@RestController @RestController
@RequestMapping("/api/v1/ctgy/user") @RequestMapping("/api/v1/ctgy")
@Validated @Validated
@RequiredArgsConstructor @RequiredArgsConstructor
public class MinUserinfoController { public class MinUserinfoController {
@ -43,7 +47,7 @@ public class MinUserinfoController {
@Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "1"), @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "1"),
@Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10")
}) })
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value="users", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> findMinUserinfos( public ResponseEntity<? extends IRestResponse> findMinUserinfos(
@Parameter(hidden = true) @Parameter(hidden = true)
@ModelAttribute("minUserinfoDto") @ModelAttribute("minUserinfoDto")
@ -53,4 +57,12 @@ public class MinUserinfoController {
return RestResponse.of(service.findMinUserinfos(mapstruct.toEntity(minUserinfoDto), pageable)); return RestResponse.of(service.findMinUserinfos(mapstruct.toEntity(minUserinfoDto), pageable));
} }
@Operation(summary = "사용자 정보 조회" , description = "사용자 정보 조회")
@GetMapping("/user")
@Secured(policy = SecurityPolicy.TOKEN)
@Transactional(readOnly = true)
public ResponseEntity<? extends IRestResponse> getUserInfo() {
return RestResponse.of(service.findMyUserWithoutAuthorities());
}
} }

@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -24,7 +25,7 @@ import javax.validation.constraints.NotNull;
@Tag(name = "OAuth2MinController", description = "인증 관리") @Tag(name = "OAuth2MinController", description = "인증 관리")
@RestController @RestController
@RequestMapping("/api/v1/ctgy/auth") @RequestMapping("/api/v1/ctgy/account")
@Validated @Validated
@RequiredArgsConstructor @RequiredArgsConstructor
public class OAuth2MinController { public class OAuth2MinController {
@ -62,6 +63,7 @@ public class OAuth2MinController {
// @Parameter(in = ParameterIn.QUERY, name = "password", description = "비밀번호", required = true, example = "minuk926926") // @Parameter(in = ParameterIn.QUERY, name = "password", description = "비밀번호", required = true, example = "minuk926926")
// }) // })
@PostMapping("/login") @PostMapping("/login")
@Transactional
public ResponseEntity<? extends IRestResponse> login( public ResponseEntity<? extends IRestResponse> login(
//@Validated //@Validated
@Valid @Valid

@ -71,7 +71,7 @@ public class MinUserinfo implements Serializable {
//@Transient //@Transient
//@JsonIgnore //@JsonIgnore
@OneToMany(targetEntity = MinSimsaUser680.class, mappedBy = "minUserinfo")//, cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(targetEntity = MinSimsaUser680.class, mappedBy = "minUserinfo") //, fetch = FetchType.EAGER)//, cascade = CascadeType.ALL, orphanRemoval = true)
private final Set<MinSimsaUser680> minSimsaUser680s = new HashSet<>(); private final Set<MinSimsaUser680> minSimsaUser680s = new HashSet<>();
public void addMinSimsaUser680(final MinSimsaUser680 minSimsaUser680){ public void addMinSimsaUser680(final MinSimsaUser680 minSimsaUser680){

@ -1,9 +1,11 @@
package com.xit.biz.ctgy.repository; package com.xit.biz.ctgy.repository;
import com.xit.biz.ctgy.entity.MinUserinfo; import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.core.oauth2.utils.SecurityUtil;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional; import java.util.Optional;
@ -11,8 +13,11 @@ public interface IMinUserinfoRepository extends JpaRepository<MinUserinfo, Strin
Optional<MinUserinfo> findByUserid(String userid); Optional<MinUserinfo> findByUserid(String userid);
@Query(value = "SELECT TRAFFIC.ECL_ENCRYPT(?1) AS passwd FROM DUAL C", nativeQuery = true) @Query(value = "SELECT TRAFFIC.ECL_ENCRYPT(?1) AS passwd FROM DUAL C", nativeQuery = true)
//@Query(value = "SELECT ECL_ENCRYPT(?1) AS passwd", nativeQuery = true)
String queryGetPasswdEncode(@Param("passwd") String passwd); String queryGetPasswdEncode(@Param("passwd") String passwd);
@Query(value = "SELECT TRAFFIC.ECL_DECRYPT(MU.passwd) AS passwd FROM min_userinfo MU WHERE MU.userid = ?1", nativeQuery = true) @Query(value = "SELECT ECL_DECRYPT(MU.passwd) AS passwd FROM min_userinfo MU WHERE MU.userid = ?1", nativeQuery = true)
String queryGetPasswd(@Param("userid") String userid); String queryGetPasswd(@Param("userid") String userid);
MinUserinfo findMinUserinfoByUserid(String userid);
} }

@ -1,10 +1,15 @@
package com.xit.biz.ctgy.service; package com.xit.biz.ctgy.service;
import com.xit.biz.cmm.entity.CmmUser;
import com.xit.biz.ctgy.entity.MinUserinfo; import com.xit.biz.ctgy.entity.MinUserinfo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Optional;
public interface IMinUserinfoService { public interface IMinUserinfoService {
Page<MinUserinfo> findMinUserinfos(MinUserinfo minUserinfo, Pageable pageable); Page<MinUserinfo> findMinUserinfos(MinUserinfo minUserinfo, Pageable pageable);
MinUserinfo findMyUserWithoutAuthorities();
} }

@ -1,8 +1,11 @@
package com.xit.biz.ctgy.service.impl; package com.xit.biz.ctgy.service.impl;
import com.xit.biz.cmm.entity.CmmUser;
import com.xit.biz.ctgy.entity.MinUserinfo; import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.biz.ctgy.repository.IMinUserinfoRepository; import com.xit.biz.ctgy.repository.IMinUserinfoRepository;
import com.xit.biz.ctgy.service.IMinUserinfoService; import com.xit.biz.ctgy.service.IMinUserinfoService;
import com.xit.core.oauth2.utils.HeaderUtil;
import com.xit.core.oauth2.utils.SecurityUtil;
import com.xit.core.support.jpa.JpaUtil; import com.xit.core.support.jpa.JpaUtil;
import org.springframework.data.domain.Example; import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.ExampleMatcher;
@ -11,6 +14,8 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
@Service @Service
@ -34,4 +39,12 @@ public class MinUserinfoService implements IMinUserinfoService {
// List<CmmUser> userList = page.getContent(); // List<CmmUser> userList = page.getContent();
return page; return page;
} }
@Override
@Transactional(readOnly = true)
public MinUserinfo findMyUserWithoutAuthorities() {
//cmmUserRepos
//return Optional.empty(); //cmmUserRepository.findOneWithAuthorities(SecurityUtil.getCurrentMemberId());
return repository.findMinUserinfoByUserid(HeaderUtil.getUserId());
}
} }

@ -63,7 +63,7 @@ public class RestResponse<T> implements IRestResponse, Serializable {
//noinspection unchecked //noinspection unchecked
this.data = (T) page.getContent(); this.data = (T) page.getContent();
this.paginator = new Paginator(page.getNumber(), page.getSize(), Integer.parseInt(String.valueOf(page.getTotalElements())));// paginator.getTotalPages this.paginator = new Paginator(page.getPageable().getPageNumber(), page.getSize(), Integer.parseInt(String.valueOf(page.getTotalElements())));// paginator.getTotalPages
this.count = paginator.getTotalCount(); this.count = paginator.getTotalCount();

@ -1,5 +1,6 @@
package com.xit.core.config.database; package com.xit.core.config.database;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.xit.core.support.CamelCaseLinkedMap; import com.xit.core.support.CamelCaseLinkedMap;
import com.xit.core.support.CamelCaseMap; import com.xit.core.support.CamelCaseMap;
import com.xit.core.support.ObjectTypeHandler; import com.xit.core.support.ObjectTypeHandler;
@ -128,6 +129,21 @@ public class DataSourceConfig {
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor(); return new PersistenceExceptionTranslationPostProcessor();
} }
/**
* - failed to lazily initialize a collection of role could not initialize proxy
* 1) @OneToMay fetch = FetchType.EAGER :
* 2) @Transactinal
* 3) Hibernate5Module Bean
* @return
*/
// @Bean
// public Hibernate5Module hibernate5Module(){
// Hibernate5Module hibernate5Module = new Hibernate5Module();
// // 강제로 지연 로딩 사용 : 양방향 무한 로딩 발생 --> @JsonIgnore 추가로 처리
// //hibernate5Module.configure(Hibernate5Module.Feature.FORCE_LAZY_LOADING, true);
// return hibernate5Module();
// }
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////

@ -89,7 +89,8 @@ public class SpringDocApiConfig {
return GroupedOpenApi.builder() return GroupedOpenApi.builder()
.group("common-API") .group("common-API")
.pathsToMatch( .pathsToMatch(
"/api/biz/cmm/**" "/api/biz/cmm/**",
"/api/v1/biz/cmm/**"
) )
.pathsToExclude( .pathsToExclude(
"/api/biz/cmm/flux/**" "/api/biz/cmm/flux/**"

@ -1,5 +1,6 @@
package com.xit.core.oauth2.api.dto; package com.xit.core.oauth2.api.dto;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.core.constant.XitConstants; import com.xit.core.constant.XitConstants;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
@ -23,4 +24,7 @@ public class TokenDto {
@Schema(required = true, title = "Refresh token", example = " ", description = "Refresh token") @Schema(required = true, title = "Refresh token", example = " ", description = "Refresh token")
private String refreshToken; private String refreshToken;
@Schema(required = true, title = "User info", example = " ", description = "User info")
private MinUserinfo user;
} }

@ -33,7 +33,7 @@ spring:
# ================================================================================================================== # ==================================================================================================================
jpa: jpa:
database-platform: org.hibernate.dialect.Oracle10gDialect database-platform: org.hibernate.dialect.Oracle10gDialect
#show-sql: false show-sql: false
properties: properties:
hibernate: hibernate:
hbm2ddl: hbm2ddl:

@ -8,18 +8,26 @@ spring:
sql: sql:
init: init:
mode: always mode: always
platform: h2 platform: h2 #postgres
#schema-locations: classpath:/data/h2/schema.sql #schema-locations: classpath:/data/h2/schema.sql
#data-locations: classpath:/data/h2/data.sql #data-locations:
# - classpath:/data/h2/TRAFFIC_MIN_USERINFO.sql
# - classpath:/data/h2/TRAFFIC_MIN_SIMSA_USER680.sql
# ================================================================================================================== # ==================================================================================================================
# database setting # database setting
# ================================================================================================================== # ==================================================================================================================
datasource: datasource:
# driver-class-name: org.postgresql.Driver #org.h2.Driver
# url: jdbc:postgresql://localhost:5432/bustms
# username: traffic
# password: xhdgkq0
driver-class-name: org.h2.Driver driver-class-name: org.h2.Driver
url: jdbc:h2:mem:xitdb;MODE=Oracle;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE url: jdbc:h2:mem:xitdb;MODE=Oracle;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: sa username: sa
password: '' password: ''
hikari: hikari:
driver-class-name: ${spring.datasource.driver-class-name} driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url} jdbc-url: ${spring.datasource.url}
@ -31,13 +39,12 @@ spring:
# JPA setting # JPA setting
# ================================================================================================================== # ==================================================================================================================
jpa: jpa:
database-platform: org.hibernate.dialect.H2Dialect database-platform: org.hibernate.dialect.PostgreSQLDialect
#show-sql: false #show-sql: false
properties: properties:
hibernate: hibernate:
hbm2ddl: hbm2ddl:
# create / create-drop / update / validate / none # create / create-drop / update / validate / none
# auto: create-drop
auto: create-drop auto: create-drop
h2: h2:

@ -0,0 +1,23 @@
select * from MIN_MAINCODE order by c1, c2, c3;
insert into TB_CMM_CODE_S(
code_grp_id,
CODE_LCD,
CODE_MCD,
CODE_CD,
CODE_NM,
CODE_META_1,
CODE_META_2,
CODE_META_3
)
select 'traffic',
c1,
c2,
c3,
cdname,
etc1,
etc2,
ETC3
from MIN_MAINCODE
order by c1, c2, c3;
commit;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,72 @@
create table tb_cmm_code_grp (
code_grp_id varchar2(20) not null,
created_by varchar2(64),
created_dtm timestamp,
modified_by varchar2(64),
modified_dtm timestamp,
use_yn varchar2(1) default 'Y' not null,
code_nm varchar2(20) not null,
code_ordr number(3) default 99 not null,
code_remark varchar2(50),
primary key (code_grp_id)
);
create table tb_cmm_code_l (
code_cd varchar2(10) not null,
code_grp_id varchar2(20) not null,
created_by varchar2(64),
created_dtm timestamp,
modified_by varchar2(64),
modified_dtm timestamp,
use_yn varchar2(1) default 'Y' not null,
code_meta_1 varchar2(10),
code_meta_2 varchar2(10),
code_meta_3 varchar2(10),
code_meta_4 varchar2(10),
code_meta_5 varchar2(10),
code_nm varchar2(20) not null,
code_ordr number(3) default 99 not null,
code_remark varchar2(50),
primary key (code_cd, code_grp_id)
);
create table tb_cmm_code_m (
code_cd varchar2(10) not null,
code_grp_id varchar2(20) not null,
code_lcd varchar2(10) not null,
created_by varchar2(64),
created_dtm timestamp,
modified_by varchar2(64),
modified_dtm timestamp,
use_yn varchar2(1) default 'Y' not null,
code_meta_1 varchar2(10),
code_meta_2 varchar2(10),
code_meta_3 varchar2(10),
code_meta_4 varchar2(10),
code_meta_5 varchar2(10),
code_nm varchar2(20) not null,
code_ordr number(3) not null,
code_remark varchar2(50),
primary key (code_cd, code_grp_id, code_lcd)
);
create table tb_cmm_code_s (
code_cd varchar2(10) not null,
code_grp_id varchar2(20) not null,
code_lcd varchar2(10) not null,
code_mcd varchar2(10) not null,
created_by varchar2(64),
created_dtm timestamp,
modified_by varchar2(64),
modified_dtm timestamp,
use_yn varchar2(1) default 'Y' not null,
code_meta_1 varchar2(10),
code_meta_2 varchar2(10),
code_meta_3 varchar2(10),
code_meta_4 varchar2(10),
code_meta_5 varchar2(10),
code_nm varchar2(20) not null,
code_ordr number(3) default 99 not null,
code_remark varchar2(50),
primary key (code_cd, code_grp_id, code_lcd, code_mcd)
);

@ -1,9 +1,10 @@
package com.xit.biz.cmm.repository; package com.xit.biz.cmm.repository;
import com.xit.biz.cmm.dto.ComboCodeDto;
import com.xit.biz.cmm.entity.*; import com.xit.biz.cmm.entity.*;
import com.xit.biz.cmm.entity.spec.CmmCodeSpecification; import com.xit.biz.cmm.entity.spec.CmmCodeSpecification;
import com.xit.biz.cmm.dto.CmmCodeDto; import com.xit.biz.cmm.dto.CmmCodeDto;
import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.cmm.dto.IComboCodeDto;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -96,7 +97,7 @@ class ICmmCodeRepositoryTest {
//List<CmmCodeS> list = cmmCodeSRepository.findByCodeGrpIdAndCodeLcdAndCodeMcdAndUseYnOrderByCodeOrdr(savedCmmCodeS.getCodeGrpId(), savedCmmCodeS.getCodeLcd(), savedCmmCodeS.getCodeMcd(), savedCmmCodeS.getUseYn()); //List<CmmCodeS> list = cmmCodeSRepository.findByCodeGrpIdAndCodeLcdAndCodeMcdAndUseYnOrderByCodeOrdr(savedCmmCodeS.getCodeGrpId(), savedCmmCodeS.getCodeLcd(), savedCmmCodeS.getCodeMcd(), savedCmmCodeS.getUseYn());
//System.out.println(list); //System.out.println(list);
List<ComboCodeDto> comboCodeDtos = cmmCodeSRepository.queryComboCode(savedCmmCodeS.getCodeGrpId(), savedCmmCodeS.getCodeLcd(), savedCmmCodeS.getCodeMcd()); List<ComboCodeDto> comboCodeDtos = cmmCodeSRepository.queryComboCodeClass(savedCmmCodeS.getCodeGrpId(), savedCmmCodeS.getCodeLcd(), savedCmmCodeS.getCodeMcd());
System.out.println(comboCodeDtos); System.out.println(comboCodeDtos);
// cmmFileDtlIds.setFileMstId(savedCmmFileMst.getFileMstId()); // cmmFileDtlIds.setFileMstId(savedCmmFileMst.getFileMstId());

Loading…
Cancel
Save