251222_04_ENH : RequestBody에 Valid 적용 및 중괄호 스타일 통일
This commit is contained in:
@@ -34,14 +34,14 @@ public class UserService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Transactional
|
||||
public void createUser(UserInfoDto userInfo, String regUser, LocalDateTime regDt){
|
||||
public void createUser(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
|
||||
List<RoleInfoDto> roleList = roleService.getRoleList();
|
||||
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
|
||||
|
||||
userInfo.setUserId(userInfo.getUserId().toLowerCase());
|
||||
|
||||
List<DataVerificationDto> failList = validateUserDto(userInfo, roleList, intranetUserList).stream().filter(dto -> !dto.isSuccess()).toList();
|
||||
if(!failList.isEmpty()){
|
||||
if(!failList.isEmpty()) {
|
||||
DataVerificationDto firstFail = failList.get(0);
|
||||
throw BusinessException.badRequest("WRONG_USER_DATA", firstFail.getErrMessage());
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class UserService {
|
||||
.orElse(null);
|
||||
|
||||
UserInfoDto dto = UserInfoDto.from(uploadDto, roleCd, regUser);
|
||||
if(!forceCmpn.isBlank()){
|
||||
if(!forceCmpn.isBlank()) {
|
||||
dto.setUserCmpn(forceCmpn);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
public byte[] exportUserTemplate(){
|
||||
public byte[] exportUserTemplate() {
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(Collections.emptyList(), UserUploadDto.class);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
@@ -136,7 +136,7 @@ public class UserService {
|
||||
return this.verifyUserId(userId, intranetUserList);
|
||||
}
|
||||
|
||||
public UserInfoDto getUser(String userId){
|
||||
public UserInfoDto getUser(String userId) {
|
||||
TUserEntity user = userRepository.findByUserIdAndDelFalse(userId)
|
||||
.orElseThrow(() ->
|
||||
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
|
||||
@@ -148,7 +148,7 @@ public class UserService {
|
||||
return userInfoDto;
|
||||
}
|
||||
|
||||
public TUserEntity getUser(String userId, String userPw){
|
||||
public TUserEntity getUser(String userId, String userPw) {
|
||||
return userRepository.findByUserIdAndUserPwAndDelFalse(userId, userPw)
|
||||
.orElseThrow(() ->
|
||||
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
|
||||
@@ -156,15 +156,15 @@ public class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
public List<UserInfoDto> getUserList(){
|
||||
public List<UserInfoDto> getUserList() {
|
||||
return userRepository.findByDelFalse().stream()
|
||||
.map(UserInfoDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<UserInfoDto> getFieldworkUserListWithCmpn(String searchCmpn){
|
||||
public List<UserInfoDto> getFieldworkUserListWithCmpn(String searchCmpn) {
|
||||
List<TUserEntity> userList;
|
||||
if(searchCmpn == null || searchCmpn.isBlank()){
|
||||
if(searchCmpn == null || searchCmpn.isBlank()) {
|
||||
userList = userRepository.findByUserRoleGreaterThanEqualAndDelFalse(ContactConstant.FIELDWORK_USER_ROLE);
|
||||
}
|
||||
else{
|
||||
@@ -176,7 +176,7 @@ public class UserService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<UserInfoDto> getOutsourceList(){
|
||||
public List<UserInfoDto> getOutsourceList() {
|
||||
List<TUserEntity> userList = userRepository.findByRoleRangeAndDelFalse(
|
||||
ContactConstant.OUTSOURCE_USER_ROLE,
|
||||
ContactConstant.OUTSOURCE_USER_ROLE + 1000
|
||||
@@ -187,12 +187,12 @@ public class UserService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<String> getUserCmpnList(){
|
||||
public List<String> getUserCmpnList() {
|
||||
return userRepository.findDistinctUserCmpnAndDelFalse();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateUser(UserInfoDto dto, String modUser, LocalDateTime modDt){
|
||||
public void updateUser(UserInfoDto dto, String modUser, LocalDateTime modDt) {
|
||||
// dirty checking 업데이트
|
||||
TUserEntity entity = userRepository.findByUserIdAndDelFalse(dto.getUserId())
|
||||
.orElseThrow(() ->
|
||||
@@ -204,18 +204,18 @@ public class UserService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteUser(String userId, String delUser){
|
||||
public void deleteUser(String userId, String delUser) {
|
||||
int deleteCount = userRepository.softDeleteByUserId(userId, delUser, DateTimeUtil.nowKstLocalDateTime());
|
||||
|
||||
if(deleteCount == 0){
|
||||
if(deleteCount == 0) {
|
||||
throw BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.")
|
||||
.with("userId", userId);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************private*******************************/
|
||||
private DataVerificationDto verifyUserId(String userId, List<String> intranetUserList){
|
||||
if(userId == null || userId.isBlank()){
|
||||
private DataVerificationDto verifyUserId(String userId, List<String> intranetUserList) {
|
||||
if(userId == null || userId.isBlank()) {
|
||||
return new DataVerificationDto(false, "사용자 ID", "사용자 ID가 비었습니다.");
|
||||
}
|
||||
if (userId.length() < 3 || userId.length() > 16 ) {
|
||||
@@ -224,10 +224,10 @@ public class UserService {
|
||||
if (!userId.matches("^[a-z가-힣][a-z0-9가-힣]+$")) {
|
||||
return new DataVerificationDto(false,"사용자 ID", "사용자 ID는 한글, 영소문자, 숫자만 허용합니다.");
|
||||
}
|
||||
if(userRepository.existsByUserIdAndDelFalse(userId)){
|
||||
if(userRepository.existsByUserIdAndDelFalse(userId)) {
|
||||
return new DataVerificationDto(false,"사용자 ID", "이미 사용중인 ID입니다.");
|
||||
}
|
||||
if(intranetUserList.contains(userId) || intranetUserList.contains(String.format("%s@kric.com", userId))){
|
||||
if(intranetUserList.contains(userId) || intranetUserList.contains(String.format("%s@kric.com", userId))) {
|
||||
return new DataVerificationDto(false,"사용자 ID", "이미 사용중인 직원 ID입니다.");
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public class UserService {
|
||||
List<DataVerificationDto> validateUserList = this.validateUserDto(dto, roleList, intranetUserList);
|
||||
|
||||
validateUserList.forEach(validateResult -> {
|
||||
if(!validateResult.isSuccess()){
|
||||
if(!validateResult.isSuccess()) {
|
||||
errors.add(UserUploadErrorDto.of(
|
||||
rowNumber,
|
||||
validateResult.getFieldName(),
|
||||
|
||||
Reference in New Issue
Block a user