[공통 코드 관리] 공통 코드 및 그룹 코드 관련 엔티티, DTO, 매퍼, 서비스 및 컨트롤러 추가. 기존 매퍼 삭제 및 외래 키 제약 조건 제거. 데이터베이스 스키마 수정.

This commit is contained in:
2025-08-26 16:45:54 +09:00
parent 6df8409e96
commit 0c141eb397
20 changed files with 150 additions and 193 deletions

View File

@@ -95,13 +95,3 @@
create index idx_member_user_id
on st_member (user_id);
alter table if exists st_common_code
add constraint FKdk30t67v5e2vo1k7gl5sk1jp9
foreign key (group_code)
references st_common_group_code (code);
alter table if exists st_common_code
add constraint FKgcyw9ydft76p31oox94ho93wf
foreign key (parent_code)
references st_common_code (code);

View File

@@ -1,68 +0,0 @@
package com.bio.bio_backend.domain.admin.CommonCode.mapper;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CommonCodeDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CreateCommonCodeRequestDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CreateCommonCodeResponseDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.UpdateCommonCodeRequestDto;
import com.bio.bio_backend.domain.admin.CommonCode.entity.CommonCode;
import com.bio.bio_backend.global.annotation.IgnoreBaseEntityMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper(componentModel = "spring")
public interface CommonCodeMapper {
CommonCodeMapper INSTANCE = Mappers.getMapper(CommonCodeMapper.class);
/**
* CommonCode 엔티티를 CommonCodeDto로 변환
*/
CommonCodeDto toCommonCodeDto(CommonCode entity);
/**
* CommonCodeDto를 CommonCode 엔티티로 변환
*/
@Mapping(target = "commonGroupCode", ignore = true)
@Mapping(target = "parentCodeEntity", ignore = true)
CommonCode toCommonCode(CommonCodeDto dto);
/**
* CommonCode 엔티티 리스트를 CommonCodeDto 리스트로 변환
*/
List<CommonCodeDto> toCommonCodeDtoList(List<CommonCode> entities);
/**
* CommonCodeDto 리스트를 CommonCode 엔티티 리스트로 변환
*/
List<CommonCode> toCommonCodeList(List<CommonCodeDto> dtos);
/**
* CommonCodeDto를 CreateCommonCodeResponseDto로 변환
*/
@Mapping(target = "createdAt", ignore = true)
CreateCommonCodeResponseDto toCreateCommonCodeResponseDto(CommonCodeDto dto);
/**
* CreateCommonCodeRequestDto를 CommonCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
CommonCodeDto toCommonCodeDto(CreateCommonCodeRequestDto requestDto);
/**
* UpdateCommonCodeRequestDto를 CommonCodeDto로 변환
*/
@Mapping(target = "code", ignore = true)
@Mapping(target = "oid", ignore = true)
CommonCodeDto toCommonCodeDto(UpdateCommonCodeRequestDto requestDto);
/**
* CommonCodeDto의 값으로 CommonCode 엔티티를 업데이트 (null 값은 무시)
*/
@IgnoreBaseEntityMapping
@Mapping(target = "commonGroupCode", ignore = true)
@Mapping(target = "parentCodeEntity", ignore = true)
void updateCommonCodeFromDto(CommonCodeDto commonCodeDto, @org.mapstruct.MappingTarget CommonCode commonCode);
}

View File

@@ -1,67 +0,0 @@
package com.bio.bio_backend.domain.admin.CommonCode.mapper;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CommonGroupCodeDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CreateCommonGroupCodeRequestDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CreateCommonGroupCodeResponseDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.UpdateCommonGroupCodeRequestDto;
import com.bio.bio_backend.domain.admin.CommonCode.entity.CommonGroupCode;
import com.bio.bio_backend.global.annotation.IgnoreBaseEntityMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper(componentModel = "spring")
public interface CommonGroupCodeMapper {
CommonGroupCodeMapper INSTANCE = Mappers.getMapper(CommonGroupCodeMapper.class);
/**
* CommonGroupCode 엔티티를 CommonGroupCodeDto로 변환
*/
CommonGroupCodeDto toCommonGroupCodeDto(CommonGroupCode entity);
/**
* CommonGroupCodeDto를 CommonGroupCode 엔티티로 변환
*/
CommonGroupCode toCommonGroupCode(CommonGroupCodeDto dto);
/**
* CommonGroupCode 엔티티 리스트를 CommonGroupCodeDto 리스트로 변환
*/
List<CommonGroupCodeDto> toCommonGroupCodeDtoList(List<CommonGroupCode> entities);
/**
* CommonGroupCodeDto 리스트를 CommonGroupCode 엔티티 리스트로 변환
*/
List<CommonGroupCode> toCommonGroupCodeList(List<CommonGroupCodeDto> dtos);
/**
* CommonGroupCodeDto를 CreateCommonGroupCodeResponseDto로 변환
*/
CreateCommonGroupCodeResponseDto toCreateCommonGroupCodeResponseDto(CommonGroupCodeDto dto);
/**
* CreateCommonGroupCodeRequestDto를 CommonGroupCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
@Mapping(target = "createdAt", ignore = true)
@Mapping(target = "updatedAt", ignore = true)
CommonGroupCodeDto toCommonGroupCodeDto(CreateCommonGroupCodeRequestDto requestDto);
/**
* UpdateCommonGroupCodeRequestDto를 CommonGroupCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
@Mapping(target = "code", ignore = true)
@Mapping(target = "createdAt", ignore = true)
@Mapping(target = "updatedAt", ignore = true)
CommonGroupCodeDto toCommonGroupCodeDto(UpdateCommonGroupCodeRequestDto requestDto);
/**
* CommonGroupCodeDto의 값으로 CommonGroupCode 엔티티를 업데이트 (null 값은 무시)
*/
@IgnoreBaseEntityMapping
void updateCommonGroupCodeFromDto(CommonGroupCodeDto groupCodeDto, @org.mapstruct.MappingTarget CommonGroupCode groupCode);
}

View File

@@ -1,9 +1,9 @@
package com.bio.bio_backend.domain.admin.CommonCode.controller;
package com.bio.bio_backend.domain.admin.common_code.controller;
import com.bio.bio_backend.domain.admin.CommonCode.dto.*;
import com.bio.bio_backend.domain.admin.CommonCode.service.CommonCodeService;
import com.bio.bio_backend.domain.admin.CommonCode.mapper.CommonCodeMapper;
import com.bio.bio_backend.domain.admin.CommonCode.mapper.CommonGroupCodeMapper;
import com.bio.bio_backend.domain.admin.common_code.dto.*;
import com.bio.bio_backend.domain.admin.common_code.service.CommonCodeService;
import com.bio.bio_backend.domain.admin.common_code.mapper.CommonCodeMapper;
import com.bio.bio_backend.domain.admin.common_code.mapper.CommonGroupCodeMapper;
import com.bio.bio_backend.global.dto.ApiResponseDto;
import com.bio.bio_backend.global.constants.ApiResponseCode;
import com.bio.bio_backend.global.annotation.LogExecution;

View File

@@ -1,12 +1,10 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@Builder
@NoArgsConstructor

View File

@@ -1,12 +1,10 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@Builder
@NoArgsConstructor
@@ -23,6 +21,4 @@ public class CommonGroupCodeDto {
private String characterRef5Title;
private Integer sortOrder;
private Boolean useFlag;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}

View File

@@ -1,4 +1,4 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,12 +1,10 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@Builder
@NoArgsConstructor
@@ -26,5 +24,4 @@ public class CreateCommonCodeResponseDto {
private String characterRef5;
private Integer sortOrder;
private Boolean useFlag;
private LocalDateTime createdAt;
}

View File

@@ -1,4 +1,4 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,12 +1,10 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@Builder
@NoArgsConstructor
@@ -23,5 +21,4 @@ public class CreateCommonGroupCodeResponseDto {
private String characterRef5Title;
private Integer sortOrder;
private Boolean useFlag;
private LocalDateTime createdAt;
}

View File

@@ -1,4 +1,4 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package com.bio.bio_backend.domain.admin.CommonCode.dto;
package com.bio.bio_backend.domain.admin.common_code.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package com.bio.bio_backend.domain.admin.CommonCode.entity;
package com.bio.bio_backend.domain.admin.common_code.entity;
import com.bio.bio_backend.global.constants.AppConstants;
import com.bio.bio_backend.global.entity.BaseEntity;
@@ -64,10 +64,12 @@ public class CommonCode extends BaseEntity {
// 관계 설정
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "group_code", referencedColumnName = "code", insertable = false, updatable = false)
@JoinColumn(
name = "group_code",
referencedColumnName = "code",
insertable = false,
updatable = false,
foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)
)
private CommonGroupCode commonGroupCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_code", referencedColumnName = "code", insertable = false, updatable = false)
private CommonCode parentCodeEntity;
}

View File

@@ -1,4 +1,4 @@
package com.bio.bio_backend.domain.admin.CommonCode.entity;
package com.bio.bio_backend.domain.admin.common_code.entity;
import com.bio.bio_backend.global.constants.AppConstants;
import com.bio.bio_backend.global.entity.BaseEntity;

View File

@@ -0,0 +1,57 @@
package com.bio.bio_backend.domain.admin.common_code.mapper;
import com.bio.bio_backend.domain.admin.common_code.dto.CommonCodeDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonCodeRequestDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonCodeResponseDto;
import com.bio.bio_backend.domain.admin.common_code.dto.UpdateCommonCodeRequestDto;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonCode;
import com.bio.bio_backend.global.annotation.IgnoreBaseEntityMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import java.util.List;
@Mapper(componentModel = "spring")
public interface CommonCodeMapper {
/**
* CommonCode 엔티티를 CommonCodeDto로 변환
*/
CommonCodeDto toCommonCodeDto(CommonCode commonCode);
/**
* CommonCodeDto를 CommonCode 엔티티로 변환
*/
@Mapping(target = "commonGroupCode", ignore = true)
CommonCode toCommonCode(CommonCodeDto commonCodeDto);
/**
* CommonCode 엔티티 리스트를 CommonCodeDto 리스트로 변환
*/
List<CommonCodeDto> toCommonCodeDtoList(List<CommonCode> commonCodes);
/**
* CommonCodeDto를 CreateCommonCodeResponseDto로 변환
*/
CreateCommonCodeResponseDto toCreateCommonCodeResponseDto(CommonCodeDto commonCodeDto);
/**
* CreateCommonCodeRequestDto를 CommonCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
CommonCodeDto toCommonCodeDto(CreateCommonCodeRequestDto createRequestDto);
/**
* UpdateCommonCodeRequestDto를 CommonCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
@Mapping(target = "code", ignore = true)
CommonCodeDto toCommonCodeDto(UpdateCommonCodeRequestDto updateRequestDto);
/**
* CommonCodeDto의 값으로 CommonCode 엔티티를 업데이트
*/
@IgnoreBaseEntityMapping
@Mapping(target = "commonGroupCode", ignore = true)
void updateCommonCodeFromDto(CommonCodeDto commonCodeDto, @org.mapstruct.MappingTarget CommonCode commonCode);
}

View File

@@ -0,0 +1,55 @@
package com.bio.bio_backend.domain.admin.common_code.mapper;
import com.bio.bio_backend.domain.admin.common_code.dto.CommonGroupCodeDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonGroupCodeRequestDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonGroupCodeResponseDto;
import com.bio.bio_backend.domain.admin.common_code.dto.UpdateCommonGroupCodeRequestDto;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonGroupCode;
import com.bio.bio_backend.global.annotation.IgnoreBaseEntityMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import java.util.List;
@Mapper(componentModel = "spring")
public interface CommonGroupCodeMapper {
/**
* CommonGroupCode 엔티티를 CommonGroupCodeDto로 변환
*/
CommonGroupCodeDto toCommonGroupCodeDto(CommonGroupCode commonGroupCode);
/**
* CommonGroupCodeDto를 CommonGroupCode 엔티티로 변환
*/
CommonGroupCode toCommonGroupCode(CommonGroupCodeDto commonGroupCodeDto);
/**
* CommonGroupCode 엔티티 리스트를 CommonGroupCodeDto 리스트로 변환
*/
List<CommonGroupCodeDto> toCommonGroupCodeDtoList(List<CommonGroupCode> commonGroupCodes);
/**
* CommonGroupCodeDto를 CreateCommonGroupCodeResponseDto로 변환
*/
CreateCommonGroupCodeResponseDto toCreateCommonGroupCodeResponseDto(CommonGroupCodeDto commonGroupCodeDto);
/**
* CreateCommonGroupCodeRequestDto를 CommonGroupCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
CommonGroupCodeDto toCommonGroupCodeDto(CreateCommonGroupCodeRequestDto createRequestDto);
/**
* UpdateCommonGroupCodeRequestDto를 CommonGroupCodeDto로 변환
*/
@Mapping(target = "oid", ignore = true)
@Mapping(target = "code", ignore = true)
CommonGroupCodeDto toCommonGroupCodeDto(UpdateCommonGroupCodeRequestDto updateRequestDto);
/**
* CommonGroupCodeDto의 값으로 CommonGroupCode 엔티티를 업데이트
*/
@IgnoreBaseEntityMapping
void updateCommonGroupCodeFromDto(CommonGroupCodeDto commonGroupCodeDto, @org.mapstruct.MappingTarget CommonGroupCode commonGroupCode);
}

View File

@@ -1,6 +1,6 @@
package com.bio.bio_backend.domain.admin.CommonCode.repository;
package com.bio.bio_backend.domain.admin.common_code.repository;
import com.bio.bio_backend.domain.admin.CommonCode.entity.CommonCode;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonCode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

View File

@@ -1,6 +1,6 @@
package com.bio.bio_backend.domain.admin.CommonCode.repository;
package com.bio.bio_backend.domain.admin.common_code.repository;
import com.bio.bio_backend.domain.admin.CommonCode.entity.CommonGroupCode;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonGroupCode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

View File

@@ -1,7 +1,7 @@
package com.bio.bio_backend.domain.admin.CommonCode.service;
package com.bio.bio_backend.domain.admin.common_code.service;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CommonCodeDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CommonGroupCodeDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CommonCodeDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CommonGroupCodeDto;
import java.util.List;

View File

@@ -1,13 +1,13 @@
package com.bio.bio_backend.domain.admin.CommonCode.service;
package com.bio.bio_backend.domain.admin.common_code.service;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CommonCodeDto;
import com.bio.bio_backend.domain.admin.CommonCode.dto.CommonGroupCodeDto;
import com.bio.bio_backend.domain.admin.CommonCode.entity.CommonCode;
import com.bio.bio_backend.domain.admin.CommonCode.entity.CommonGroupCode;
import com.bio.bio_backend.domain.admin.CommonCode.mapper.CommonCodeMapper;
import com.bio.bio_backend.domain.admin.CommonCode.mapper.CommonGroupCodeMapper;
import com.bio.bio_backend.domain.admin.CommonCode.repository.CommonCodeRepository;
import com.bio.bio_backend.domain.admin.CommonCode.repository.CommonGroupCodeRepository;
import com.bio.bio_backend.domain.admin.common_code.dto.CommonCodeDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CommonGroupCodeDto;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonCode;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonGroupCode;
import com.bio.bio_backend.domain.admin.common_code.mapper.CommonCodeMapper;
import com.bio.bio_backend.domain.admin.common_code.mapper.CommonGroupCodeMapper;
import com.bio.bio_backend.domain.admin.common_code.repository.CommonCodeRepository;
import com.bio.bio_backend.domain.admin.common_code.repository.CommonGroupCodeRepository;
import com.bio.bio_backend.global.exception.ApiException;
import com.bio.bio_backend.global.constants.ApiResponseCode;
import lombok.RequiredArgsConstructor;