회원관리 수정중, 토큰 response 수정

This commit is contained in:
2025-12-10 15:54:40 +09:00
parent 9fbefda9d5
commit b3903fbb57
16 changed files with 225 additions and 384 deletions

View File

@@ -25,7 +25,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
// 1. 유저 조회
MemberEntity member =
membersRepository
.findByEmployeeNo(username)
.findByUserId(username)
.orElseThrow(() -> new BadCredentialsException("ID 또는 비밀번호가 일치하지 않습니다."));
// 2. jBCrypt + 커스텀 salt 로 저장된 패스워드 비교

View File

@@ -16,7 +16,6 @@ public class CustomUserDetails implements UserDetails {
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
// 권한을 Member에서 가져오는 경우 바꾸면 됩니다 — 일단 기본값
return Collections.emptyList();
}

View File

@@ -241,11 +241,8 @@ public class GlobalExceptionHandler {
String codeName = "";
switch (e.getField()) {
case EMPLOYEE_NO -> {
codeName = "DUPLICATE_EMPLOYEEID";
}
case EMAIL -> {
codeName = "DUPLICATE_EMAIL";
case USER_ID -> {
codeName = "DUPLICATE_DATA";
}
default -> {
codeName = "DUPLICATE_DATA";

View File

@@ -16,11 +16,12 @@ import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "회원정보 관리자 관리", description = "회원정보 관리자 관리 API")
@Tag(name = "관리자 관리", description = "관리자 관리 API")
@RestController
@RequestMapping("/api/admin/members")
@RequiredArgsConstructor
@@ -28,12 +29,12 @@ public class AdminApiController {
private final AdminService adminService;
@Operation(summary = "회원가입", description = "회원가입")
@Operation(summary = "관리자 계정 등록", description = "관리자 계정 등록")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "회원가입 성공",
description = "등록 성공",
content =
@Content(
mediaType = "application/json",
@@ -45,7 +46,7 @@ public class AdminApiController {
@PostMapping("/join")
public ApiResponseDto<Long> saveMember(
@io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "회원가입",
description = "관리자 계정 등록",
required = true,
content =
@Content(
@@ -58,94 +59,34 @@ public class AdminApiController {
return ApiResponseDto.createOK(adminService.saveMember(addReq));
}
@Operation(summary = "역할 추가", description = "uuid 기준으로 역할 추가")
@Operation(summary = "관리자 계정 수정", description = "관리자 계정 수정")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "역할 추가",
description = "수정 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = UUID.class))),
schema = @Schema(implementation = Long.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PostMapping("/roles/add")
public ApiResponseDto<UUID> saveRoles(
@PutMapping("/{uuid}")
public ApiResponseDto<UUID> updateMembers(
@io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "역할 추가",
description = "관리자 계정 수정",
required = true,
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = MembersDto.RolesDto.class)))
@RequestBody
@Valid
MembersDto.RolesDto rolesDto) {
adminService.saveRoles(rolesDto);
return ApiResponseDto.createOK(rolesDto.getUuid());
}
@Operation(summary = "역할 삭제", description = "uuid 기준으로 역할 삭제")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "역할 삭제",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = UUID.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@DeleteMapping("/roles/rm")
public ApiResponseDto<UUID> deleteRoles(
@io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "역할 삭제",
required = true,
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = MembersDto.RolesDto.class)))
@RequestBody
@Valid
MembersDto.RolesDto rolesDto) {
adminService.deleteRoles(rolesDto);
return ApiResponseDto.createOK(rolesDto.getUuid());
}
@Operation(summary = "상태 수정", description = "상태 수정")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "상태 수정",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = UUID.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PatchMapping("{uuid}/status")
public ApiResponseDto<UUID> updateStatus(
@io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "상태 수정",
required = true,
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = MembersDto.StatusDto.class)))
schema = @Schema(implementation = MembersDto.UpdateReq.class)))
@PathVariable
UUID uuid,
@RequestBody @Valid MembersDto.StatusDto statusDto) {
adminService.updateStatus(uuid, statusDto);
return ApiResponseDto.createOK(uuid);
@RequestBody MembersDto.UpdateReq updateReq) {
adminService.updateMembers(uuid, updateReq);
return ApiResponseDto.createOK(UUID.randomUUID());
}
@Operation(summary = "회원 탈퇴", description = "회원 탈퇴")

View File

@@ -65,7 +65,7 @@ public class MembersApiController {
@PutMapping("/{uuid}")
public ApiResponseDto<UUID> updateMember(
@PathVariable UUID uuid, @RequestBody MembersDto.UpdateReq updateReq) {
membersService.updateMember(uuid, updateReq);
// membersService.updateMember(uuid, updateReq);
return ApiResponseDto.createOK(uuid);
}
}

View File

@@ -32,7 +32,7 @@ public class MemberDetails implements UserDetails {
public String getUsername() {
// 로그인 ID 로 무엇을 쓸지 선택
// 1) 이메일 로그인:
return member.getEmail();
return member.getUserId();
// 2) 사번으로 로그인하고 싶으면:
// return member.getEmployeeNo();

View File

@@ -90,28 +90,34 @@ public class MembersDto {
@Setter
public static class AddReq {
@Schema(description = "사번", example = "11111")
@Schema(description = "관리자 유형", example = "ROLE_ADMIN")
@NotBlank
@Size(max = 50)
private String employeeNo;
private String userRole;
@Schema(description = "이름", example = "홍길동")
@NotBlank
@Size(min = 2, max = 100)
private String name;
@Schema(hidden = true)
private String password;
@Schema(description = "ID", example = "gildong")
@NotBlank
@Size(min = 2, max = 50)
private String userId;
@Schema(description = "이메일", example = "gildong@daum.net")
@Size(max = 100)
private String email;
@Schema(description = "임시 비밀번호", example = "q!w@e#r4")
private String tempPassword;
public AddReq(String employeeNo, String name, String password, String email) {
this.employeeNo = employeeNo;
@Schema(description = "사번", example = "123456")
private String employeeNo;
public AddReq(
String userRole, String name, String userId, String tempPassword, String employeeNo) {
this.userRole = userRole;
this.name = name;
this.password = password;
this.email = email;
this.userId = userId;
this.tempPassword = tempPassword;
this.employeeNo = employeeNo;
}
}
@@ -129,17 +135,12 @@ public class MembersDto {
@Schema(description = "패스워드", example = "")
@Size(max = 255)
private String password;
private String tempPassword;
@Schema(description = "이메일", example = "gildong@daum.net")
@Size(max = 100)
private String email;
public UpdateReq(String employeeNo, String name, String password, String email) {
public UpdateReq(String employeeNo, String name, String tempPassword) {
this.employeeNo = employeeNo;
this.name = name;
this.password = password;
this.email = email;
this.tempPassword = tempPassword;
}
}

View File

@@ -10,8 +10,7 @@ public class MemberException {
public static class DuplicateMemberException extends RuntimeException {
public enum Field {
EMPLOYEE_NO,
EMAIL,
USER_ID,
DEFAULT
}

View File

@@ -6,7 +6,6 @@ import com.kamco.cd.kamcoback.postgres.core.MembersCoreService;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -17,9 +16,6 @@ public class AdminService {
private final MembersCoreService membersCoreService;
@Value("${member.init_password}")
private String password;
/**
* 회원가입
*
@@ -29,14 +25,18 @@ public class AdminService {
@Transactional
public Long saveMember(MembersDto.AddReq addReq) {
// salt 생성, 사번이 salt
String salt = BCryptSaltGenerator.generateSaltWithEmployeeNo(addReq.getEmployeeNo().trim());
String salt = BCryptSaltGenerator.generateSaltWithEmployeeNo(addReq.getUserId().trim());
// 패스워드 암호화, 초기 패스워드 고정
String hashedPassword = BCrypt.hashpw(password, salt);
addReq.setPassword(hashedPassword);
String hashedPassword = BCrypt.hashpw(addReq.getTempPassword(), salt);
addReq.setTempPassword(hashedPassword);
return membersCoreService.saveMembers(addReq);
}
public void updateMembers(UUID uuid, MembersDto.UpdateReq updateReq) {
membersCoreService.updateMembers(uuid, updateReq);
}
/**
* 역할 추가
*
@@ -44,7 +44,7 @@ public class AdminService {
*/
@Transactional
public void saveRoles(MembersDto.RolesDto rolesDto) {
membersCoreService.saveRoles(rolesDto);
// membersCoreService.saveRoles(rolesDto);
}
/**
@@ -53,7 +53,7 @@ public class AdminService {
* @param rolesDto
*/
public void deleteRoles(MembersDto.RolesDto rolesDto) {
membersCoreService.deleteRoles(rolesDto);
// membersCoreService.deleteRoles(rolesDto);
}
/**
@@ -62,7 +62,7 @@ public class AdminService {
* @param statusDto
*/
public void updateStatus(UUID uuid, MembersDto.StatusDto statusDto) {
membersCoreService.updateStatus(uuid, statusDto);
// membersCoreService.updateStatus(uuid, statusDto);
}
/**
@@ -71,7 +71,7 @@ public class AdminService {
* @param uuid
*/
public void deleteAccount(UUID uuid) {
membersCoreService.deleteAccount(uuid);
// membersCoreService.deleteAccount(uuid);
}
/**
@@ -80,6 +80,6 @@ public class AdminService {
* @param id
*/
public void resetPassword(Long id) {
membersCoreService.resetPassword(id);
// membersCoreService.resetPassword(id);
}
}

View File

@@ -1,24 +1,16 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.auth.BCryptSaltGenerator;
import com.kamco.cd.kamcoback.members.dto.MembersDto;
import com.kamco.cd.kamcoback.members.exception.MemberException;
import com.kamco.cd.kamcoback.members.dto.MembersDto.AddReq;
import com.kamco.cd.kamcoback.members.exception.MemberException.DuplicateMemberException;
import com.kamco.cd.kamcoback.members.exception.MemberException.DuplicateMemberException.Field;
import com.kamco.cd.kamcoback.members.exception.MemberException.MemberNotFoundException;
import com.kamco.cd.kamcoback.postgres.entity.MemberArchivedEntity;
import com.kamco.cd.kamcoback.postgres.entity.MemberArchivedEntityId;
import com.kamco.cd.kamcoback.postgres.entity.MemberEntity;
import com.kamco.cd.kamcoback.postgres.entity.MemberRoleEntity;
import com.kamco.cd.kamcoback.postgres.entity.MemberRoleEntityId;
import com.kamco.cd.kamcoback.postgres.repository.members.MembersArchivedRepository;
import com.kamco.cd.kamcoback.postgres.repository.members.MembersRepository;
import com.kamco.cd.kamcoback.postgres.repository.members.MembersRoleRepository;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@Service
@@ -26,34 +18,25 @@ import org.springframework.stereotype.Service;
public class MembersCoreService {
private final MembersRepository membersRepository;
private final MembersRoleRepository memberRoleRepository;
private final MembersArchivedRepository memberArchivedRepository;
@Value("${member.init_password}")
private String password;
/**
* 회원가입
*
* @param addReq
* @return
*/
public Long saveMembers(MembersDto.AddReq addReq) {
if (membersRepository.existsByEmployeeNo(addReq.getEmployeeNo())) {
throw new MemberException.DuplicateMemberException(
MemberException.DuplicateMemberException.Field.EMPLOYEE_NO, addReq.getEmployeeNo());
public Long saveMembers(AddReq addReq) {
if (membersRepository.existsByUserId(addReq.getUserId())) {
throw new DuplicateMemberException(Field.USER_ID, addReq.getUserId());
}
if (membersRepository.existsByEmail(addReq.getEmail())) {
throw new MemberException.DuplicateMemberException(
MemberException.DuplicateMemberException.Field.EMAIL, addReq.getEmail());
}
MemberEntity memberEntity = new MemberEntity();
memberEntity.setEmployeeNo(addReq.getEmployeeNo());
memberEntity.setUserId(addReq.getUserId());
memberEntity.setUserRole(addReq.getUserRole());
memberEntity.setTempPassword(addReq.getTempPassword());
memberEntity.setPassword(addReq.getTempPassword());
memberEntity.setName(addReq.getName());
memberEntity.setPassword(addReq.getPassword());
memberEntity.setEmail(addReq.getEmail());
memberEntity.setEmployeeNo(addReq.getEmployeeNo());
return membersRepository.save(memberEntity).getId();
}
@@ -66,141 +49,141 @@ public class MembersCoreService {
*/
public void updateMembers(UUID uuid, MembersDto.UpdateReq updateReq) {
MemberEntity memberEntity =
membersRepository.findByUUID(uuid).orElseThrow(() -> new MemberNotFoundException());
membersRepository.findByUUID(uuid).orElseThrow(MemberNotFoundException::new);
if (StringUtils.isNotBlank(updateReq.getName())) {
memberEntity.setName(updateReq.getName());
}
if (StringUtils.isNotBlank(updateReq.getTempPassword())) {
memberEntity.setTempPassword(updateReq.getTempPassword());
memberEntity.setPassword(updateReq.getTempPassword());
}
if (StringUtils.isNotBlank(memberEntity.getEmployeeNo())) {
memberEntity.setEmployeeNo(updateReq.getEmployeeNo());
}
if (StringUtils.isNotBlank(updateReq.getName())) {
memberEntity.setName(updateReq.getName());
}
if (StringUtils.isNotBlank(updateReq.getPassword())) {
memberEntity.setPassword(updateReq.getPassword());
}
if (StringUtils.isNotBlank(updateReq.getEmail())) {
memberEntity.setEmail(updateReq.getEmail());
}
membersRepository.save(memberEntity);
}
/**
* 역할 추가
*
* @param rolesDto
*/
public void saveRoles(MembersDto.RolesDto rolesDto) {
MemberEntity memberEntity =
membersRepository
.findByUUID(rolesDto.getUuid())
.orElseThrow(() -> new MemberNotFoundException());
if (memberRoleRepository.findByUuidAndRoleName(rolesDto)) {
throw new MemberException.DuplicateMemberException(
MemberException.DuplicateMemberException.Field.DEFAULT, "중복된 역할이 있습니다.");
}
MemberRoleEntityId memberRoleEntityId = new MemberRoleEntityId();
memberRoleEntityId.setMemberUuid(rolesDto.getUuid());
memberRoleEntityId.setRoleName(rolesDto.getRoleName());
MemberRoleEntity memberRoleEntity = new MemberRoleEntity();
memberRoleEntity.setId(memberRoleEntityId);
memberRoleEntity.setMemberUuid(memberEntity);
memberRoleEntity.setCreatedDttm(ZonedDateTime.now());
memberRoleRepository.save(memberRoleEntity);
}
/**
* 역할 삭제
*
* @param rolesDto
*/
public void deleteRoles(MembersDto.RolesDto rolesDto) {
MemberEntity memberEntity =
membersRepository
.findByUUID(rolesDto.getUuid())
.orElseThrow(() -> new MemberNotFoundException());
MemberRoleEntityId memberRoleEntityId = new MemberRoleEntityId();
memberRoleEntityId.setMemberUuid(rolesDto.getUuid());
memberRoleEntityId.setRoleName(rolesDto.getRoleName());
MemberRoleEntity memberRoleEntity = new MemberRoleEntity();
memberRoleEntity.setId(memberRoleEntityId);
memberRoleEntity.setMemberUuid(memberEntity);
memberRoleRepository.delete(memberRoleEntity);
}
/**
* 상태 수정
*
* @param statusDto
*/
public void updateStatus(UUID uuid, MembersDto.StatusDto statusDto) {
MemberEntity memberEntity =
membersRepository.findByUUID(uuid).orElseThrow(() -> new MemberNotFoundException());
memberEntity.setStatus(statusDto.getStatus());
memberEntity.setUpdatedDttm(ZonedDateTime.now());
membersRepository.save(memberEntity);
}
/**
* 회원 탈퇴
*
* @param uuid
*/
public void deleteAccount(UUID uuid) {
MemberEntity memberEntity =
membersRepository.findByUUID(uuid).orElseThrow(() -> new MemberNotFoundException());
MemberArchivedEntityId memberArchivedEntityId = new MemberArchivedEntityId();
memberArchivedEntityId.setUserId(memberEntity.getId());
memberArchivedEntityId.setUuid(memberEntity.getUuid());
MemberArchivedEntity memberArchivedEntity = new MemberArchivedEntity();
memberArchivedEntity.setId(memberArchivedEntityId);
memberArchivedEntity.setEmployeeNo(memberEntity.getEmployeeNo());
memberArchivedEntity.setName(memberEntity.getName());
memberArchivedEntity.setPassword(memberEntity.getPassword());
memberArchivedEntity.setEmail(memberEntity.getEmail());
memberArchivedEntity.setStatus(memberEntity.getStatus());
memberArchivedEntity.setCreatedDttm(memberEntity.getCreatedDttm());
memberArchivedEntity.setArchivedDttm(ZonedDateTime.now());
memberArchivedRepository.save(memberArchivedEntity);
memberEntity.setStatus("ARCHIVED");
memberEntity.setName("**********");
memberEntity.setEmployeeNo("**********");
memberEntity.setPassword("**********");
memberEntity.setEmail("**********");
memberEntity.setUpdatedDttm(ZonedDateTime.now());
membersRepository.save(memberEntity);
}
/**
* 패스워드 초기화
*
* @param id
*/
public void resetPassword(Long id) {
MemberEntity memberEntity =
membersRepository.findById(id).orElseThrow(() -> new MemberNotFoundException());
String salt =
BCryptSaltGenerator.generateSaltWithEmployeeNo(memberEntity.getEmployeeNo().trim());
// 패스워드 암호화, 초기 패스워드 고정
String hashedPassword = BCrypt.hashpw(password, salt);
memberEntity.setPassword(hashedPassword);
memberEntity.setStatus("INACTIVE");
memberEntity.setUpdatedDttm(ZonedDateTime.now());
membersRepository.save(memberEntity);
}
//
// /**
// * 역할 추가
// *
// * @param rolesDto
// */
// public void saveRoles(MembersDto.RolesDto rolesDto) {
//
// MemberEntity memberEntity =
// membersRepository
// .findByUUID(rolesDto.getUuid())
// .orElseThrow(() -> new MemberNotFoundException());
//
// if (memberRoleRepository.findByUuidAndRoleName(rolesDto)) {
// throw new MemberException.DuplicateMemberException(
// MemberException.DuplicateMemberException.Field.DEFAULT, "중복된 역할이 있습니다.");
// }
//
// MemberRoleEntityId memberRoleEntityId = new MemberRoleEntityId();
// memberRoleEntityId.setMemberUuid(rolesDto.getUuid());
// memberRoleEntityId.setRoleName(rolesDto.getRoleName());
//
// MemberRoleEntity memberRoleEntity = new MemberRoleEntity();
// memberRoleEntity.setId(memberRoleEntityId);
// memberRoleEntity.setMemberUuid(memberEntity);
// memberRoleEntity.setCreatedDttm(ZonedDateTime.now());
// memberRoleRepository.save(memberRoleEntity);
// }
//
// /**
// * 역할 삭제
// *
// * @param rolesDto
// */
// public void deleteRoles(MembersDto.RolesDto rolesDto) {
// MemberEntity memberEntity =
// membersRepository
// .findByUUID(rolesDto.getUuid())
// .orElseThrow(() -> new MemberNotFoundException());
//
// MemberRoleEntityId memberRoleEntityId = new MemberRoleEntityId();
// memberRoleEntityId.setMemberUuid(rolesDto.getUuid());
// memberRoleEntityId.setRoleName(rolesDto.getRoleName());
//
// MemberRoleEntity memberRoleEntity = new MemberRoleEntity();
// memberRoleEntity.setId(memberRoleEntityId);
// memberRoleEntity.setMemberUuid(memberEntity);
//
// memberRoleRepository.delete(memberRoleEntity);
// }
//
// /**
// * 상태 수정
// *
// * @param statusDto
// */
// public void updateStatus(UUID uuid, MembersDto.StatusDto statusDto) {
// MemberEntity memberEntity =
// membersRepository.findByUUID(uuid).orElseThrow(() -> new MemberNotFoundException());
//
// memberEntity.setStatus(statusDto.getStatus());
// memberEntity.setUpdatedDttm(ZonedDateTime.now());
// membersRepository.save(memberEntity);
// }
//
// /**
// * 회원 탈퇴
// *
// * @param uuid
// */
// public void deleteAccount(UUID uuid) {
// MemberEntity memberEntity =
// membersRepository.findByUUID(uuid).orElseThrow(() -> new MemberNotFoundException());
//
// MemberArchivedEntityId memberArchivedEntityId = new MemberArchivedEntityId();
// memberArchivedEntityId.setUserId(memberEntity.getId());
// memberArchivedEntityId.setUuid(memberEntity.getUuid());
//
// MemberArchivedEntity memberArchivedEntity = new MemberArchivedEntity();
// memberArchivedEntity.setId(memberArchivedEntityId);
// memberArchivedEntity.setEmployeeNo(memberEntity.getEmployeeNo());
// memberArchivedEntity.setName(memberEntity.getName());
// memberArchivedEntity.setPassword(memberEntity.getPassword());
// memberArchivedEntity.setEmail(memberEntity.getEmail());
// memberArchivedEntity.setStatus(memberEntity.getStatus());
// memberArchivedEntity.setCreatedDttm(memberEntity.getCreatedDttm());
// memberArchivedEntity.setArchivedDttm(ZonedDateTime.now());
// memberArchivedRepository.save(memberArchivedEntity);
//
// memberEntity.setStatus("ARCHIVED");
// memberEntity.setName("**********");
// memberEntity.setEmployeeNo("**********");
// memberEntity.setPassword("**********");
// memberEntity.setEmail("**********");
// memberEntity.setUpdatedDttm(ZonedDateTime.now());
// membersRepository.save(memberEntity);
// }
//
// /**
// * 패스워드 초기화
// *
// * @param id
// */
// public void resetPassword(Long id) {
// MemberEntity memberEntity =
// membersRepository.findById(id).orElseThrow(() -> new MemberNotFoundException());
//
// String salt =
// BCryptSaltGenerator.generateSaltWithEmployeeNo(memberEntity.getEmployeeNo().trim());
// // 패스워드 암호화, 초기 패스워드 고정
// String hashedPassword = BCrypt.hashpw(password, salt);
//
// memberEntity.setPassword(hashedPassword);
// memberEntity.setStatus("INACTIVE");
// memberEntity.setUpdatedDttm(ZonedDateTime.now());
// membersRepository.save(memberEntity);
// }
//
/**
* 회원목록 조회
@@ -208,7 +191,7 @@ public class MembersCoreService {
* @param searchReq
* @return
*/
public Page<MembersDto.Basic> findByMembers(MembersDto.SearchReq searchReq) {
return membersRepository.findByMembers(searchReq);
}
// public Page<Basic> findByMembers(MembersDto.SearchReq searchReq) {
// return membersRepository.findByMembers(searchReq);
// }
}

View File

@@ -5,13 +5,10 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
@@ -28,11 +25,24 @@ public class MemberEntity {
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "uuid", nullable = false, insertable = false)
private UUID uuid;
@NotNull
@ColumnDefault("gen_random_uuid()")
@Column(name = "uuid", nullable = false)
private UUID uuid = UUID.randomUUID();
@Size(max = 50)
@Column(name = "employee_no", length = 50)
@NotNull
@Column(name = "user_role", nullable = false, length = 50)
private String userRole;
@Size(max = 50)
@NotNull
@Column(name = "user_id", nullable = false, length = 50)
private String userId;
@Size(max = 50)
@NotNull
@Column(name = "employee_no", nullable = false, length = 50)
private String employeeNo;
@Size(max = 100)
@@ -40,26 +50,27 @@ public class MemberEntity {
@Column(name = "name", nullable = false, length = 100)
private String name;
@Size(max = 255)
@NotNull
@Column(name = "temp_password", nullable = false)
private String tempPassword;
@Size(max = 255)
@NotNull
@Column(name = "password", nullable = false)
private String password;
@Size(max = 100)
@Column(name = "email", length = 100)
private String email;
@Size(max = 20)
@ColumnDefault("'INACTIVE'")
@Column(name = "status", length = 20)
private String status = "INACTIVE";
@Column(name = "created_dttm", nullable = false, insertable = false)
private ZonedDateTime createdDttm;
@NotNull
@ColumnDefault("now()")
@Column(name = "created_dttm", nullable = false)
private ZonedDateTime createdDttm = ZonedDateTime.now();
@Column(name = "updated_dttm", nullable = false, insertable = false)
private ZonedDateTime updatedDttm;
@OneToMany(mappedBy = "memberUuid")
private Set<MemberRoleEntity> tbMemberRoles = new LinkedHashSet<>();
@ColumnDefault("now()")
@Column(name = "updated_dttm")
private ZonedDateTime updatedDttm = ZonedDateTime.now();
}

View File

@@ -1,37 +0,0 @@
package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.time.ZonedDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
@Getter
@Setter
@Entity
@Table(name = "tb_member_role")
public class MemberRoleEntity {
@EmbeddedId private MemberRoleEntityId id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(
name = "member_uuid",
referencedColumnName = "uuid",
insertable = false,
updatable = false)
private MemberEntity memberUuid;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private ZonedDateTime createdDttm;
}

View File

@@ -1,47 +0,0 @@
package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter
@Setter
@Embeddable
public class MemberRoleEntityId implements Serializable {
private static final long serialVersionUID = 9130416001060414347L;
@NotNull
@Column(name = "member_uuid", nullable = false)
private UUID memberUuid;
@Size(max = 50)
@NotNull
@Column(name = "role_name", nullable = false, length = 50)
private String roleName;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
MemberRoleEntityId entity = (MemberRoleEntityId) o;
return Objects.equals(this.memberUuid, entity.memberUuid)
&& Objects.equals(this.roleName, entity.roleName);
}
@Override
public int hashCode() {
return Objects.hash(memberUuid, roleName);
}
}

View File

@@ -45,5 +45,3 @@ token:
refresh-cookie-name: kamco-dev # 개발용 쿠키 이름
refresh-cookie-secure: false # 로컬 http 테스트면 false
member:
init_password: kamco1234!

View File

@@ -15,8 +15,8 @@ spring:
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
datasource:
url: jdbc:postgresql://192.168.2.127:15432/kamco_cds
#url: jdbc:postgresql://localhost:5432/kamco_cds
#url: jdbc:postgresql://192.168.2.127:15432/kamco_cds
url: jdbc:postgresql://localhost:5432/kamco_cds
username: kamco_cds
password: kamco_cds_Q!W@E#R$
hikari:
@@ -38,6 +38,4 @@ token:
refresh-cookie-name: kamco-local # 개발용 쿠키 이름
refresh-cookie-secure: false # 로컬 http 테스트면 false
member:
init_password: kamco1234!

View File

@@ -30,7 +30,5 @@ token:
refresh-cookie-name: kamco # 개발용 쿠키 이름
refresh-cookie-secure: true # 로컬 http 테스트면 false
member:
init_password: kamco1234!