fix decrypt password
This commit is contained in:
		| @@ -2,7 +2,6 @@ package com.iconplus.smartproc.configuration; | ||||
|  | ||||
| import com.iconplus.smartproc.model.token.TokenContent; | ||||
| import io.jsonwebtoken.*; | ||||
| import org.apache.commons.lang3.ObjectUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.security.authentication.BadCredentialsException; | ||||
| import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||||
|   | ||||
| @@ -5,9 +5,7 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.MetodePengadaanRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListMetodePengadaanResponse; | ||||
| import com.iconplus.smartproc.model.response.MetodePengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.MetodePengadaanRepository; | ||||
| import com.iconplus.smartproc.service.metodepengadaan.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package com.iconplus.smartproc.helper.context; | ||||
|  | ||||
| import brave.internal.Platform; | ||||
| import com.iconplus.smartproc.helper.service.TokenUtils; | ||||
| import lombok.extern.log4j.Log4j2; | ||||
| import org.springframework.http.HttpHeaders; | ||||
|   | ||||
| @@ -5,7 +5,6 @@ import lombok.AllArgsConstructor; | ||||
| import lombok.Builder; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
| import org.hibernate.annotations.GeneratorType; | ||||
| import org.hibernate.annotations.Type; | ||||
|  | ||||
| import javax.persistence.*; | ||||
|   | ||||
| @@ -5,7 +5,6 @@ import lombok.AllArgsConstructor; | ||||
| import lombok.Builder; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
| import org.hibernate.annotations.GenericGenerator; | ||||
| import org.hibernate.annotations.Type; | ||||
|  | ||||
| import javax.persistence.*; | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package com.iconplus.smartproc.model.projection; | ||||
|  | ||||
| import java.sql.Clob; | ||||
|  | ||||
| public interface TokenManagementView { | ||||
|  | ||||
|   | ||||
| @@ -8,7 +8,6 @@ import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| import org.springframework.stereotype.Repository; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| @Repository | ||||
| @@ -28,4 +27,6 @@ public interface BidangRepository extends JpaRepository<Bidang, LokasiRepository | ||||
|     Page<BidangView> getListBidang(String search, Pageable pageable); | ||||
|  | ||||
|     Optional<Bidang> findByIdAndIsDeleteFalse(Long id); | ||||
|  | ||||
|     Optional<Bidang> findByBidangAndIsDeleteFalse(String bidang); | ||||
| } | ||||
|   | ||||
| @@ -9,7 +9,6 @@ import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| import org.springframework.stereotype.Repository; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| @Repository | ||||
|   | ||||
| @@ -4,7 +4,11 @@ import com.iconplus.smartproc.exception.BusinessException; | ||||
| import com.iconplus.smartproc.model.entity.TokenManagement; | ||||
| import com.iconplus.smartproc.model.request.UsersRequest; | ||||
| import com.iconplus.smartproc.repository.*; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import com.iconplus.smartproc.util.EncryptDecryptUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
| @@ -13,18 +17,18 @@ import java.time.Instant; | ||||
| @Service | ||||
| public class CommonService { | ||||
|  | ||||
|     private UsersRepository usersRepository; | ||||
|     @Value("${config.password.privateKey}") | ||||
|     private String privateKey; | ||||
|  | ||||
|     private RolesRepository rolesRepository; | ||||
|     private BidangRepository bidangRepository; | ||||
|     private InstansiRepository instansiRepository; | ||||
|     private TokenManagementRepository tokenManagementRepository; | ||||
|  | ||||
|     public CommonService(UsersRepository usersRepository, | ||||
|                                 RolesRepository rolesRepository, | ||||
|                                 BidangRepository bidangRepository, | ||||
|                                 InstansiRepository instansiRepository, | ||||
|                                 TokenManagementRepository tokenManagementRepository) { | ||||
|         this.usersRepository = usersRepository; | ||||
|     public CommonService(RolesRepository rolesRepository, | ||||
|                          BidangRepository bidangRepository, | ||||
|                          InstansiRepository instansiRepository, | ||||
|                          TokenManagementRepository tokenManagementRepository) { | ||||
|         this.rolesRepository = rolesRepository; | ||||
|         this.bidangRepository = bidangRepository; | ||||
|         this.instansiRepository = instansiRepository; | ||||
| @@ -35,17 +39,26 @@ public class CommonService { | ||||
|  | ||||
|         var roles= rolesRepository.findByIdAndIsDeleteFalse(input.getRoleId()); | ||||
|         if (roles.isEmpty()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, "Role", input.getId())); | ||||
|         } | ||||
|  | ||||
|         var bidang= bidangRepository.findByIdAndIsDeleteFalse(input.getBidangId()); | ||||
|         if (bidang.isEmpty()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, "Bidang", input.getId())); | ||||
|         } | ||||
|  | ||||
|         var instansi= instansiRepository.findByIdAndIsDeleteFalse(input.getInstansiId()); | ||||
|         if (instansi.isEmpty()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, "Instansi", input.getId())); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -81,4 +94,15 @@ public class CommonService { | ||||
|                     .build()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public String getPassword(String password) { | ||||
|         try { | ||||
|             return EncryptDecryptUtils.decrypt(password, privateKey); | ||||
|         } catch (Exception ex) { | ||||
|             throw new BusinessException(Constants.ERR_CODE_10010, | ||||
|                     Constants.ERR_TTL_10010, | ||||
|                     Constants.ERR_MSG_10010); | ||||
|         } | ||||
|  | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,11 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.ForgotPasswordRequest; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import com.iconplus.smartproc.service.CommonService; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -14,25 +18,47 @@ public class ForgotPasswordService implements BaseService<ForgotPasswordRequest, | ||||
|  | ||||
|     private ApiContext apiContext; | ||||
|     private UsersRepository usersRepository; | ||||
|     private CommonService commonService; | ||||
|     public ForgotPasswordService(UsersRepository usersRepository, | ||||
|                                  ApiContext apiContext) { | ||||
|                                  ApiContext apiContext, | ||||
|                                  CommonService commonService) { | ||||
|         this.usersRepository = usersRepository; | ||||
|         this.apiContext = apiContext; | ||||
|         this.commonService = commonService; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public EmptyResponse execute(ForgotPasswordRequest input) { | ||||
|  | ||||
|         Long id = Long.valueOf(apiContext.getUserId()); | ||||
|         var users = usersRepository.findByIdAndIsDeleteFalse(id).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var users = usersRepository.findByIdAndIsDeleteFalse(id) | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "User", id))); | ||||
|  | ||||
|         if (!StringUtils.equalsIgnoreCase(input.getCurrentPassword(), users.getPassword()) || | ||||
|                 StringUtils.equalsIgnoreCase(input.getNewPassword(), users.getPassword()) || | ||||
|                 !StringUtils.equalsIgnoreCase(input.getConfirmationPassword(), input.getNewPassword())) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|         String password = commonService.getPassword(input.getCurrentPassword()); | ||||
|         BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); | ||||
|         boolean isValidCurrentPassword = bCryptPasswordEncoder.matches(password, users.getPassword()); | ||||
|  | ||||
|         if (!isValidCurrentPassword) { | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10009, | ||||
|                     Constants.ERR_TTL_10009, | ||||
|                     Constants.ERR_MSG_10009); | ||||
|         } | ||||
|  | ||||
|         users.setPassword(input.getNewPassword()); | ||||
|         String newPassword = commonService.getPassword(input.getNewPassword()); | ||||
|         String confirmationPassword = commonService.getPassword(input.getNewPassword()); | ||||
|  | ||||
|  | ||||
|         if (!StringUtils.equalsIgnoreCase(newPassword, confirmationPassword)) { | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10007, | ||||
|                     Constants.ERR_TTL_10007, | ||||
|                     Constants.ERR_MSG_10007); | ||||
|         } | ||||
|  | ||||
|         users.setPassword(bCryptPasswordEncoder.encode(newPassword)); | ||||
|         usersRepository.save(users); | ||||
|  | ||||
|         return new EmptyResponse(); | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| @@ -54,7 +55,11 @@ public class LoginService implements BaseService<LoginRequest, LoginResponse> { | ||||
|                         Constants.ERR_TTL_10003, | ||||
|                         String.format(Constants.ERR_MSG_10003, input.getEmail()))); | ||||
|  | ||||
|         if (!StringUtils.equalsIgnoreCase(input.getPassword(), userRoleView.getPassword())) { | ||||
|         String password = commonService.getPassword(input.getPassword()); | ||||
|         BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); | ||||
|         boolean isValidPassword = bCryptPasswordEncoder.matches(password, userRoleView.getPassword()); | ||||
|  | ||||
|         if (!isValidPassword) { | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10004, | ||||
|                     Constants.ERR_TTL_10004, | ||||
| @@ -84,7 +89,9 @@ public class LoginService implements BaseService<LoginRequest, LoginResponse> { | ||||
|  | ||||
|         if (StringUtils.isBlank(accessToken) || StringUtils.isBlank(refreshToken)) { | ||||
|             log.error("token null"); | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(Constants.ERR_CODE_10008, | ||||
|                     Constants.ERR_TTL_10008, | ||||
|                     Constants.ERR_MSG_10008); | ||||
|         } | ||||
|  | ||||
|         commonService.saveUserToken(TokenManagement.builder() | ||||
| @@ -93,7 +100,6 @@ public class LoginService implements BaseService<LoginRequest, LoginResponse> { | ||||
|                 .refreshToken(refreshToken) | ||||
|                 .build(), accessTokenExp); | ||||
|  | ||||
|  | ||||
|     return LoginResponse.builder() | ||||
|             .accessToken(accessToken) | ||||
|             .validity(accessTokenExp * 60) | ||||
|   | ||||
| @@ -7,18 +7,17 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.entity.TokenManagement; | ||||
| import com.iconplus.smartproc.repository.TokenManagementRepository; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @Service | ||||
| public class LogoutService implements BaseService<EmptyRequest, EmptyResponse> { | ||||
|  | ||||
|     private ApiContext apiContext; | ||||
|     private TokenManagementRepository  tokenManagementRepository; | ||||
|     private LogoutService(ApiContext apiContext, | ||||
|  | ||||
|     public LogoutService(ApiContext apiContext, | ||||
|                           TokenManagementRepository tokenManagementRepository) { | ||||
|         this.apiContext = apiContext; | ||||
|         this.tokenManagementRepository = tokenManagementRepository; | ||||
| @@ -35,10 +34,10 @@ public class LogoutService implements BaseService<EmptyRequest, EmptyResponse> { | ||||
|     } | ||||
|  | ||||
|     private TokenManagement getTokenManagement(String accessToken) { | ||||
|         var tokenManagement = tokenManagementRepository.findByAccessTokenAndIsDeleteFalse(accessToken); | ||||
|         if (tokenManagement.isEmpty()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|         } | ||||
|         return tokenManagement.get(); | ||||
|         return tokenManagementRepository.findByAccessTokenAndIsDeleteFalse(accessToken) | ||||
|         .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                 Constants.ERR_CODE_40038, | ||||
|                 Constants.ERR_TITLE_40038, | ||||
|                 Constants.ERR_MESSAGE_40038)); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import com.iconplus.smartproc.model.projection.TokenManagementView; | ||||
| import com.iconplus.smartproc.model.request.PostAccessTokenRequest; | ||||
| import com.iconplus.smartproc.model.response.PostAccessTokenResponse; | ||||
| import com.iconplus.smartproc.repository.TokenManagementRepository; | ||||
| import com.iconplus.smartproc.util.CommonUtil; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,9 @@ import com.iconplus.smartproc.model.token.TokenContent; | ||||
| import com.iconplus.smartproc.repository.TokenManagementRepository; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import com.iconplus.smartproc.service.CommonService; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -49,21 +51,24 @@ public class TokenManagementService implements BaseService<RefreshTokenRequest, | ||||
|         try { | ||||
|             jwtTokenUtil.validateTokenOnly(input.getRefreshToken()); | ||||
|         } catch (Exception e) { | ||||
|             throw new BusinessException(HttpStatus.UNAUTHORIZED, "err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.UNAUTHORIZED, | ||||
|                     Constants.ERR_CODE_40051, | ||||
|                     Constants.TITLE_INVALID_NEXT_STEP, | ||||
|                     Constants.REFRESH_TOKEN_EXPIRED); | ||||
|         } | ||||
|  | ||||
|         var decodeToken = TokenUtils.decodeToken(input.getRefreshToken()); | ||||
|         Long userId = Long.valueOf(decodeToken.get("userId")); | ||||
|  | ||||
|         var  tokenManagement1 = tokenManagementRepository.findByRefreshToken(input.getRefreshToken()); | ||||
|  | ||||
|         TokenManagement tokenManagement = tokenManagementRepository.findByRefreshToken(input.getRefreshToken()) | ||||
|                 .map(c -> verifyRefreshToken(c, userId)) | ||||
|                 .orElseThrow(() -> { | ||||
|                     log.error("failed validate token to existing db"); | ||||
|                     return new BusinessException( | ||||
|                             HttpStatus.UNAUTHORIZED, "err", "err", | ||||
|                             "err"); | ||||
|                             HttpStatus.UNAUTHORIZED, | ||||
|                             Constants.ERR_CODE_80007, | ||||
|                             Constants.TITLE_INVALID_NEXT_STEP, | ||||
|                             Constants.REFRESH_TOKEN_NOT_VALID); | ||||
|                 }); | ||||
|  | ||||
|         var userRoleView = usersRepository.getUserByIdAndDeletedFase(userId).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
| @@ -83,6 +88,14 @@ public class TokenManagementService implements BaseService<RefreshTokenRequest, | ||||
|  | ||||
|         final String accessToken = jwtTokenUtil.generateToken(String.valueOf(userRoleView.getId()), tokenContent, accessTokenExp * 60000); | ||||
|  | ||||
|         if (StringUtils.isBlank(accessToken)) { | ||||
|             log.error("token null"); | ||||
|             throw new BusinessException(HttpStatus.UNAUTHORIZED, | ||||
|                     Constants.ERR_CODE_40042, | ||||
|                     Constants.ERR_TTL_40042, | ||||
|                     Constants.ERR_MSG_40042); | ||||
|         } | ||||
|  | ||||
|         tokenManagement.setAccessToken(accessToken); | ||||
|         tokenManagement.setRefreshToken(input.getRefreshToken()); | ||||
|         commonService.saveUserToken(tokenManagement, accessTokenExp); | ||||
| @@ -97,9 +110,9 @@ public class TokenManagementService implements BaseService<RefreshTokenRequest, | ||||
|     private TokenManagement verifyRefreshToken(TokenManagement tokenManagement, Long userId) { | ||||
|         if (!Objects.equals(userId, tokenManagement.getUserId())) { | ||||
|             throw new BusinessException(HttpStatus.UNAUTHORIZED, | ||||
|                     "err", | ||||
|                     "err", | ||||
|                     "err"); | ||||
|                     Constants.ERR_CODE_80007, | ||||
|                     Constants.TITLE_INVALID_NEXT_STEP, | ||||
|                     Constants.REFRESH_TOKEN_NOT_VALID); | ||||
|         } | ||||
|         return tokenManagement; | ||||
|     } | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.BidangRequest; | ||||
| import com.iconplus.smartproc.repository.BidangRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +20,10 @@ public class DeleteBidangService implements BaseService<BidangRequest, EmptyResp | ||||
|     @Override | ||||
|     public EmptyResponse execute(BidangRequest input) { | ||||
|  | ||||
|         var bidang = bidangRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var bidang = bidangRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Bidang", input.getId()))); | ||||
|  | ||||
|         bidang.setIsDelete(true); | ||||
|         bidangRepository.save(bidang); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.BidangRequest; | ||||
| import com.iconplus.smartproc.model.response.BidangResponse; | ||||
| import com.iconplus.smartproc.repository.BidangRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +20,11 @@ public class GetBidangService implements BaseService<BidangRequest, BidangRespon | ||||
|     @Override | ||||
|     public BidangResponse execute(BidangRequest input) { | ||||
|  | ||||
|         var bidang = bidangRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var bidang = bidangRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Bidang", input.getId()))); | ||||
|  | ||||
|         return BidangResponse.builder() | ||||
|                 .id(bidang.getId()) | ||||
|                 .instansiId(bidang.getInstansiId()) | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import com.iconplus.smartproc.helper.model.Pagination; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.projection.BidangView; | ||||
| import com.iconplus.smartproc.model.request.BidangRequest; | ||||
| import com.iconplus.smartproc.model.request.InstansiRequest; | ||||
| import com.iconplus.smartproc.model.response.BidangResponse; | ||||
| import com.iconplus.smartproc.model.response.GetListBidangResponse; | ||||
| import com.iconplus.smartproc.repository.BidangRepository; | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| package com.iconplus.smartproc.service.bidang; | ||||
|  | ||||
| import com.iconplus.smartproc.exception.BusinessException; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.entity.Bidang; | ||||
| import com.iconplus.smartproc.model.request.BidangRequest; | ||||
| import com.iconplus.smartproc.model.response.BidangResponse; | ||||
| import com.iconplus.smartproc.repository.BidangRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -18,7 +21,16 @@ public class PostCreateBidangService implements BaseService<BidangRequest, Bidan | ||||
|  | ||||
|     @Override | ||||
|     public BidangResponse execute(BidangRequest input) { | ||||
|         Bidang bidang = Bidang.builder() | ||||
|  | ||||
|         var bidang = bidangRepository.findByBidangAndIsDeleteFalse(input.getBidang()); | ||||
|         if (bidang.isPresent()) { | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "Bidang", input.getBidang())); | ||||
|         } | ||||
|  | ||||
|         Bidang bidangEntity = Bidang.builder() | ||||
|                 .id(input.getId()) | ||||
|                 .instansiId(input.getInstansiId()) | ||||
|                 .bidang(input.getBidang()) | ||||
| @@ -27,7 +39,7 @@ public class PostCreateBidangService implements BaseService<BidangRequest, Bidan | ||||
|                 .isDelete(false) | ||||
|                 .build(); | ||||
|  | ||||
|         var result = bidangRepository.save(bidang); | ||||
|         var result = bidangRepository.save(bidangEntity); | ||||
|         return BidangResponse.builder() | ||||
|                 .id(result.getId()) | ||||
|                 .build(); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.BidangRequest; | ||||
| import com.iconplus.smartproc.model.response.BidangResponse; | ||||
| import com.iconplus.smartproc.repository.BidangRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +20,11 @@ public class PutUpdateBidangService implements BaseService<BidangRequest, Bidang | ||||
|     @Override | ||||
|     public BidangResponse execute(BidangRequest input) { | ||||
|  | ||||
|         var bidang = bidangRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var bidang = bidangRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Bidang", input.getId()))); | ||||
|  | ||||
|         bidang.setInstansiId(input.getInstansiId()); | ||||
|         bidang.setBidang(input.getBidang()); | ||||
|         bidang.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.InstansiRequest; | ||||
| import com.iconplus.smartproc.repository.InstansiRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -20,7 +21,9 @@ public class DeleteInstansiService implements BaseService<InstansiRequest, Empty | ||||
|     public EmptyResponse execute(InstansiRequest input) { | ||||
|  | ||||
|         var instansi = instansiRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "instansi", input.getId()))); | ||||
|  | ||||
|         instansi.setIsDelete(true); | ||||
|         instansiRepository.save(instansi); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.InstansiRequest; | ||||
| import com.iconplus.smartproc.model.response.InstansiResponse; | ||||
| import com.iconplus.smartproc.repository.InstansiRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -20,7 +21,9 @@ public class GetInstansiByIdService implements BaseService<InstansiRequest, Inst | ||||
|     public InstansiResponse execute(InstansiRequest input) { | ||||
|  | ||||
|         var instansi= instansiRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "instansi", input.getId()))); | ||||
|  | ||||
|         return InstansiResponse.builder() | ||||
|                 .id(instansi.getId()) | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import com.iconplus.smartproc.helper.model.Pagination; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.projection.InstansiView; | ||||
| import com.iconplus.smartproc.model.request.InstansiRequest; | ||||
| import com.iconplus.smartproc.model.request.UsersRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListInstansiResponse; | ||||
| import com.iconplus.smartproc.model.response.InstansiResponse; | ||||
| import com.iconplus.smartproc.repository.InstansiRepository; | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import com.iconplus.smartproc.model.entity.Instansi; | ||||
| import com.iconplus.smartproc.model.request.InstansiRequest; | ||||
| import com.iconplus.smartproc.model.response.InstansiResponse; | ||||
| import com.iconplus.smartproc.repository.InstansiRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -22,7 +24,10 @@ public class PostCreateInstansiService implements BaseService<InstansiRequest, I | ||||
|  | ||||
|         var instansi = instansiRepository.findByInstansiAndIsDeleteFalse(input.getInstansi()); | ||||
|         if (instansi.isPresent()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "Instansi", input.getInstansi())); | ||||
|         } | ||||
|  | ||||
|         Instansi instansiEntity = Instansi.builder() | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.InstansiRequest; | ||||
| import com.iconplus.smartproc.model.response.InstansiResponse; | ||||
| import com.iconplus.smartproc.repository.InstansiRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -20,7 +21,9 @@ public class PutUpdateInstansiService implements BaseService<InstansiRequest, In | ||||
|     public InstansiResponse execute(InstansiRequest input) { | ||||
|  | ||||
|         var instansi = instansiRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "instansi", input.getId()))); | ||||
|  | ||||
|         instansi.setInstansi(input.getInstansi()); | ||||
|         instansi.setAlamat(input.getAlamat()); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.JabatanRequest; | ||||
| import com.iconplus.smartproc.repository.JabatanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -17,7 +18,10 @@ public class DeleteJabatanService implements BaseService<JabatanRequest, EmptyRe | ||||
|     @Override | ||||
|     public EmptyResponse execute(JabatanRequest input) { | ||||
|         var jabatan = jabatanRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jabatan", input.getId()))); | ||||
|          | ||||
|         jabatan.setIsDelete(true); | ||||
|         jabatanRepository.save(jabatan); | ||||
|         return new EmptyResponse(); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.JabatanRequest; | ||||
| import com.iconplus.smartproc.model.response.JabatanResponse; | ||||
| import com.iconplus.smartproc.repository.JabatanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +20,9 @@ public class GetJabatanService implements BaseService<JabatanRequest, JabatanRes | ||||
|     public JabatanResponse execute(JabatanRequest input) { | ||||
|  | ||||
|         var jabatan = jabatanRepository.getJabatanDetails(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jabatan", input.getId()))); | ||||
|  | ||||
|         return JabatanResponse.builder() | ||||
|                 .id(jabatan.getId()) | ||||
|   | ||||
| @@ -2,10 +2,8 @@ package com.iconplus.smartproc.service.jabatan; | ||||
|  | ||||
| import com.iconplus.smartproc.helper.model.Pagination; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.entity.Jabatan; | ||||
| import com.iconplus.smartproc.model.projection.JabatanView; | ||||
| import com.iconplus.smartproc.model.request.JabatanRequest; | ||||
| import com.iconplus.smartproc.model.request.JenisAnggaranRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListJabatanResponse; | ||||
| import com.iconplus.smartproc.model.response.JabatanResponse; | ||||
| import com.iconplus.smartproc.repository.JabatanRepository; | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import com.iconplus.smartproc.model.entity.Jabatan; | ||||
| import com.iconplus.smartproc.model.request.JabatanRequest; | ||||
| import com.iconplus.smartproc.model.response.JabatanResponse; | ||||
| import com.iconplus.smartproc.repository.JabatanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -21,7 +23,10 @@ public class PostCreateJabatanService implements BaseService<JabatanRequest, Jab | ||||
|  | ||||
|         var jabatan = jabatanRepository.findByJabatanAndIsDeleteFalse(input.getJabatan()); | ||||
|         if (jabatan.isPresent()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "Jabatan", input.getJabatan())); | ||||
|         } | ||||
|  | ||||
|         Jabatan jabatanEntity = Jabatan.builder() | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.JabatanRequest; | ||||
| import com.iconplus.smartproc.model.response.JabatanResponse; | ||||
| import com.iconplus.smartproc.repository.JabatanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +20,9 @@ public class PutUpdateJabatanService implements BaseService<JabatanRequest, Jaba | ||||
|     public JabatanResponse execute(JabatanRequest input) { | ||||
|  | ||||
|         var jabatan = jabatanRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jabatan", input.getId()))); | ||||
|  | ||||
|         jabatan.setJabatan(input.getJabatan()); | ||||
|         jabatan.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteJenisAnggaranService implements BaseService<JenisAnggaranRequ | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Anggaran", input.getId()))); | ||||
|  | ||||
|         jenisAnggaran.setIsDelete(true); | ||||
|         jenisAnggaranRepository.save(jenisAnggaran); | ||||
|   | ||||
| @@ -26,7 +26,7 @@ public class GetJenisAnggaranByIdService implements BaseService<JenisAnggaranReq | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Jenis Anggaran", input.getId())); | ||||
|         } | ||||
|  | ||||
|         jenisAnggaranResponse.setJenisAnggaran(jenisAnggaranView.get().getJenisAnggaran()); | ||||
|   | ||||
| @@ -11,8 +11,6 @@ import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| @Service | ||||
| @Slf4j | ||||
| public class PostCreateJenisAnggaranService implements BaseService<JenisAnggaranRequest, JenisAnggaranResponse> { | ||||
| @@ -31,7 +29,7 @@ public class PostCreateJenisAnggaranService implements BaseService<JenisAnggaran | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, input.getJenisAnggaran())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Jenis Anggaran", input.getJenisAnggaran())); | ||||
|         } | ||||
|  | ||||
|         JenisAnggaran jenisAnggaran = JenisAnggaran.builder() | ||||
|   | ||||
| @@ -30,7 +30,7 @@ public class PutUpdateJenisAnggaranService implements BaseService<JenisAnggaranR | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Anggaran", input.getId()))); | ||||
|  | ||||
|         jenisAnggaran.setJenisAnggaran(input.getJenisAnggaran()); | ||||
|         jenisAnggaran.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteJenisKontrakService implements BaseService<JenisKontrakReques | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Kontrak", input.getId()))); | ||||
|  | ||||
|         jenisKontrak.setIsDelete(true); | ||||
|         jenisKontrakRepository.save(jenisKontrak); | ||||
|   | ||||
| @@ -26,7 +26,7 @@ public class GetJenisKontrakByIdService implements BaseService<JenisKontrakReque | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Jenis Kontrak", input.getId())); | ||||
|         } | ||||
|  | ||||
|         return JenisKontrakResponse.builder() | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class PostCreateJenisKontrakService implements BaseService<JenisKontrakRe | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, existJenisKontrak.get().getId())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Jenis Kontrak", input.getJenisKontrak())); | ||||
|         } | ||||
|  | ||||
|         JenisKontrak jenisKontrak = JenisKontrak.builder() | ||||
|   | ||||
| @@ -7,12 +7,9 @@ import com.iconplus.smartproc.model.response.JenisKontrakResponse; | ||||
| import com.iconplus.smartproc.repository.JenisKontrakRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.BooleanUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
|  | ||||
| @Service | ||||
| @Slf4j | ||||
| @@ -31,7 +28,7 @@ public class PutUpdateJenisKontrakService implements BaseService<JenisKontrakReq | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Kontrak", input.getId()))); | ||||
|  | ||||
|         jenisKontrak.setJenisKontrak(input.getJenisKontrak()); | ||||
|         jenisKontrak.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.JenisPengadaanRequest; | ||||
| import com.iconplus.smartproc.repository.JenisPengadaanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -18,7 +20,10 @@ public class DeleteJenisPengadaanService implements BaseService<JenisPengadaanRe | ||||
|     @Override | ||||
|     public EmptyResponse execute(JenisPengadaanRequest input) { | ||||
|         var jenisPengadaan = jenisPengadaanRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Pengadaan", input.getId()))); | ||||
|         jenisPengadaan.setIsDelete(true); | ||||
|         jenisPengadaanRepository.save(jenisPengadaan); | ||||
|         return new EmptyResponse(); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.JenisPengadaanRequest; | ||||
| import com.iconplus.smartproc.model.response.JenisPengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.JenisPengadaanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +21,10 @@ public class GetJenisPengadaanService implements BaseService<JenisPengadaanReque | ||||
|     public JenisPengadaanResponse execute(JenisPengadaanRequest input) { | ||||
|  | ||||
|         var jenisPengadaan = jenisPengadaanRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Pengadaan", input.getId()))); | ||||
|  | ||||
|         return JenisPengadaanResponse.builder() | ||||
|                 .id(jenisPengadaan.getId()) | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import com.iconplus.smartproc.model.entity.JenisPengadaan; | ||||
| import com.iconplus.smartproc.model.request.JenisPengadaanRequest; | ||||
| import com.iconplus.smartproc.model.response.JenisPengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.JenisPengadaanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -20,7 +22,10 @@ public class PostCreateJenisPengadaanService implements BaseService<JenisPengada | ||||
|     public JenisPengadaanResponse execute(JenisPengadaanRequest input) { | ||||
|         var jenisPengadaan = jenisPengadaanRepository.findByJenisPengadaanAndIsDeleteFalse(input.getJenisPengadaan()); | ||||
|         if (jenisPengadaan.isPresent()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "Jenis Pengadaan", input.getJenisPengadaan())); | ||||
|         } | ||||
|  | ||||
|         JenisPengadaan jenisPengadaanEntity = JenisPengadaan.builder() | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.JenisPengadaanRequest; | ||||
| import com.iconplus.smartproc.model.response.JenisPengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.JenisPengadaanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -18,7 +20,10 @@ public class PutUpdateJenisPengadaanService implements BaseService<JenisPengadaa | ||||
|     @Override | ||||
|     public JenisPengadaanResponse execute(JenisPengadaanRequest input) { | ||||
|         var jenisPengadaan = jenisPengadaanRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Jenis Pengadaan", input.getId()))); | ||||
|         jenisPengadaan.setJenisPengadaan(input.getJenisPengadaan()); | ||||
|         jenisPengadaan.setKeterangan(input.getKeterangan()); | ||||
|         jenisPengadaan.setIsActive(input.getIsActive()); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteLokasiService implements BaseService<LokasiRequest, EmptyResp | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Lokasi", input.getId()))); | ||||
|  | ||||
|         lokasi.setIsDelete(true); | ||||
|         lokasiRepository.save(lokasi); | ||||
|   | ||||
| @@ -26,7 +26,7 @@ public class GetLokasiByIdService implements BaseService<LokasiRequest, LokasiRe | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Lokasi", input.getId())); | ||||
|         } | ||||
|  | ||||
|         lokasiResponse.setLokasi(lokasiView.get().getLokasi()); | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class PostCreateLokasiService implements BaseService<LokasiRequest, Lokas | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, input.getLokasi())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Lokasi", input.getLokasi())); | ||||
|         } | ||||
|  | ||||
|         Lokasi lokasi = Lokasi.builder() | ||||
|   | ||||
| @@ -30,7 +30,7 @@ public class PutUpdateLokasiService implements BaseService<LokasiRequest, Lokasi | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Lokasi", input.getId()))); | ||||
|  | ||||
|         lokasi.setLokasi(input.getLokasi()); | ||||
|         lokasi.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.UsersRequest; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -20,7 +22,10 @@ public class DeleteUserService implements BaseService<UsersRequest, EmptyRespons | ||||
|     public EmptyResponse execute(UsersRequest input) { | ||||
|  | ||||
|         var users = usersRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "User", input.getId()))); | ||||
|  | ||||
|         users.setIsDelete(true); | ||||
|         usersRepository.save(users); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.UsersRequest; | ||||
| import com.iconplus.smartproc.model.response.UsersResponse; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -20,7 +22,10 @@ public class GetUserByIdService implements BaseService<UsersRequest, UsersRespon | ||||
|     public UsersResponse execute(UsersRequest input) { | ||||
|  | ||||
|         var userRoleView = usersRepository.getUserByIdAndDeletedFase(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "User", input.getId()))); | ||||
|  | ||||
|         return UsersResponse.builder() | ||||
|                 .id(userRoleView.getId()) | ||||
|   | ||||
| @@ -8,6 +8,10 @@ import com.iconplus.smartproc.model.request.UsersRequest; | ||||
| import com.iconplus.smartproc.model.response.UsersResponse; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import com.iconplus.smartproc.service.CommonService; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import com.iconplus.smartproc.util.EncryptDecryptUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -27,10 +31,20 @@ public class PostCreateUserService implements BaseService<UsersRequest, UsersRes | ||||
|  | ||||
|         var users = usersRepository.findByEmailAndIsDeleteFalse(input.getEmail()); | ||||
|         if (users.isPresent()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "User", input.getEmail())); | ||||
|         } | ||||
|  | ||||
|         commonService.validateUserRequst(input); | ||||
|  | ||||
|         String password = commonService.getPassword(input.getPassword()); | ||||
|  | ||||
|         BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); | ||||
|         String encryptedPassword = encoder.encode(password); | ||||
|         input.setPassword(encryptedPassword); | ||||
|  | ||||
|         Users usersEntity = Users.builder() | ||||
|                 .instansiId(input.getInstansiId()) | ||||
|                 .bidangId(input.getBidangId()) | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import com.iconplus.smartproc.model.request.UsersRequest; | ||||
| import com.iconplus.smartproc.model.response.UsersResponse; | ||||
| import com.iconplus.smartproc.repository.UsersRepository; | ||||
| import com.iconplus.smartproc.service.CommonService; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -23,7 +25,10 @@ public class PutUpdateUserService implements BaseService<UsersRequest, UsersResp | ||||
|     public UsersResponse execute(UsersRequest input) { | ||||
|  | ||||
|         var users = usersRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "User", input.getId()))); | ||||
|  | ||||
|         commonService.validateUserRequst(input); | ||||
|  | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteMetodePengadaanService implements BaseService<MetodePengadaan | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Metode Pengadaan", input.getId()))); | ||||
|  | ||||
|         metodePengadaan.setIsDelete(true); | ||||
|         metodePengadaanRepository.save(metodePengadaan); | ||||
|   | ||||
| @@ -26,7 +26,7 @@ public class GetMetodePengadaanByIdService implements BaseService<MetodePengadaa | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Metode Pengadaan", input.getId())); | ||||
|         } | ||||
|  | ||||
|         return MetodePengadaanResponse.builder() | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class PostCreateMetodePengadaanService implements BaseService<MetodePenga | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, input.getMetodePengadaan())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Metode Pengadaan", input.getMetodePengadaan())); | ||||
|         } | ||||
|  | ||||
|         MetodePengadaan metodePengadaan = MetodePengadaan.builder() | ||||
|   | ||||
| @@ -7,12 +7,9 @@ import com.iconplus.smartproc.model.response.MetodePengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.MetodePengadaanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.BooleanUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| @Service | ||||
| @Slf4j | ||||
| public class PutUpdateMetodePengadaanService implements BaseService<MetodePengadaanRequest, MetodePengadaanResponse> { | ||||
| @@ -30,7 +27,7 @@ public class PutUpdateMetodePengadaanService implements BaseService<MetodePengad | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Metode Pengadaan", input.getId()))); | ||||
|  | ||||
|         metodePengadaan.setMetodePengadaan(input.getMetodePengadaan()); | ||||
|         metodePengadaan.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteMetodePenyampaianService implements BaseService<MetodePenyamp | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Metode Penyampaian", input.getId()))); | ||||
|  | ||||
|         metodePenyampaian.setIsDelete(true); | ||||
|         metodePenyampaianRepository.save(metodePenyampaian); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ public class GetMetodePenyampaianByIdService implements BaseService<MetodePenyam | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Metode Penyampaian", input.getId())); | ||||
|         } | ||||
|  | ||||
|         return MetodePenyampaianResponse.builder() | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class PostCreateMetodePenyampaianService implements BaseService<MetodePen | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, input.getMetodePenyampaian())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Metode Penyampaian", input.getMetodePenyampaian())); | ||||
|         } | ||||
|  | ||||
|         MetodePenyampaian metodePenyampaian = MetodePenyampaian.builder() | ||||
|   | ||||
| @@ -7,12 +7,9 @@ import com.iconplus.smartproc.model.response.MetodePenyampaianResponse; | ||||
| import com.iconplus.smartproc.repository.MetodePenyampaianRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.BooleanUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| @Service | ||||
| @Slf4j | ||||
| public class PutUpdateMetodePenyampaianService implements BaseService<MetodePenyampaianRequest, MetodePenyampaianResponse> { | ||||
| @@ -30,7 +27,7 @@ public class PutUpdateMetodePenyampaianService implements BaseService<MetodePeny | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Metode Penyampaian", input.getId()))); | ||||
|  | ||||
|         metodePenyampaian.setMetodePenyampaian(input.getMetodePenyampaian()); | ||||
|         metodePenyampaian.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteStrategiPengadaanService implements BaseService<StrategiPenga | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Strategi Pengadaan", input.getId()))); | ||||
|  | ||||
|         strategiPengadaan.setIsDelete(true); | ||||
|         strategiPengadaanRepository.save(strategiPengadaan); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ public class GetStrategiPengadaanByIdService implements BaseService<StrategiPeng | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Strategi Pengadaan", input.getId())); | ||||
|         } | ||||
|  | ||||
|         return StrategiPengadaanResponse.builder() | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class PostCreateStrategiPengadaanService implements BaseService<StrategiP | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, input.getStrategiPengadaan())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Strategi Pengadaan", input.getStrategiPengadaan())); | ||||
|         } | ||||
|  | ||||
|         StrategiPengadaan strategiPengadaan = StrategiPengadaan.builder() | ||||
|   | ||||
| @@ -7,12 +7,9 @@ import com.iconplus.smartproc.model.response.StrategiPengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.StrategiPengadaanRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.BooleanUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| @Service | ||||
| @Slf4j | ||||
| public class PutUpdateStrategiPengadaanService implements BaseService<StrategiPengadaanRequest, StrategiPengadaanResponse> { | ||||
| @@ -30,7 +27,7 @@ public class PutUpdateStrategiPengadaanService implements BaseService<StrategiPe | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Strategi Pengadaan", input.getId()))); | ||||
|  | ||||
|         strategiPengadaan.setStrategiPengadaan(input.getStrategiPengadaan()); | ||||
|         strategiPengadaan.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.SumberDanaRequest; | ||||
| import com.iconplus.smartproc.repository.SumberDanaRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -18,7 +20,11 @@ public class DeleteSumberDanaService implements BaseService<SumberDanaRequest, E | ||||
|  | ||||
|     @Override | ||||
|     public EmptyResponse execute(SumberDanaRequest input) { | ||||
|         var sumberDana = sumberDanaRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var sumberDana = sumberDanaRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Sumber Dana", input.getId()))); | ||||
|         sumberDana.setIsDelete(true); | ||||
|         sumberDanaRepository.save(sumberDana); | ||||
|         return new EmptyResponse(); | ||||
|   | ||||
| @@ -3,7 +3,6 @@ package com.iconplus.smartproc.service.sumberdana; | ||||
| import com.iconplus.smartproc.helper.model.Pagination; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.projection.SumberDanaView; | ||||
| import com.iconplus.smartproc.model.request.RolesRequest; | ||||
| import com.iconplus.smartproc.model.request.SumberDanaRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListSumberDanaResponse; | ||||
| import com.iconplus.smartproc.model.response.SumberDanaResponse; | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.SumberDanaRequest; | ||||
| import com.iconplus.smartproc.model.response.SumberDanaResponse; | ||||
| import com.iconplus.smartproc.repository.SumberDanaRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +21,11 @@ public class GetSumberDanaService implements BaseService<SumberDanaRequest, Sumb | ||||
|     @Override | ||||
|     public SumberDanaResponse execute(SumberDanaRequest input) { | ||||
|  | ||||
|         var sumberDana = sumberDanaRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var sumberDana = sumberDanaRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Sumber Dana", input.getId()))); | ||||
|         return SumberDanaResponse.builder() | ||||
|                 .id(sumberDana.getId()) | ||||
|                 .sumberDana(sumberDana.getSumberDana()) | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import com.iconplus.smartproc.model.entity.SumberDana; | ||||
| import com.iconplus.smartproc.model.request.SumberDanaRequest; | ||||
| import com.iconplus.smartproc.model.response.SumberDanaResponse; | ||||
| import com.iconplus.smartproc.repository.SumberDanaRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -22,7 +24,10 @@ public class PostCreateSumberDanaService implements BaseService<SumberDanaReques | ||||
|  | ||||
|         var sumberDana = sumberDanaRepository.findBySumberDanaAndIsDeleteFalse(input.getSumberDana()); | ||||
|         if (sumberDana.isPresent()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "Sumber Dana", input.getSumberDana())); | ||||
|         } | ||||
|         SumberDana sumberDanaEntity = SumberDana.builder() | ||||
|                 .sumberDana(input.getSumberDana()) | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.SumberDanaRequest; | ||||
| import com.iconplus.smartproc.model.response.SumberDanaResponse; | ||||
| import com.iconplus.smartproc.repository.SumberDanaRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +21,11 @@ public class PutSumberDanaService implements BaseService<SumberDanaRequest, Sumb | ||||
|     @Override | ||||
|     public SumberDanaResponse execute(SumberDanaRequest input) { | ||||
|  | ||||
|         var sumberDana = sumberDanaRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var sumberDana = sumberDanaRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Sumber Dana", input.getId()))); | ||||
|         sumberDana.setSumberDana(input.getSumberDana()); | ||||
|         sumberDana.setKeterangan(input.getKeterangan()); | ||||
|         sumberDana.setIsActive(input.getIsActive()); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class DeleteSupplyPositioningMatrixService implements BaseService<SupplyP | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Supply Posotioning Matrix", input.getId()))); | ||||
|  | ||||
|         supplyPositioningMatrix.setIsDelete(true); | ||||
|         supplyPositioningMatrixRepository.save(supplyPositioningMatrix); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ public class GetSupplyPositioningMatrixByIdService implements BaseService<Supply | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10001, | ||||
|                     Constants.ERR_TTL_10001, | ||||
|                     String.format(Constants.ERR_MSG_10001, input.getId())); | ||||
|                     String.format(Constants.ERR_MSG_10001, "Supply Positioning Matrix", input.getId())); | ||||
|         } | ||||
|  | ||||
|         return SupplyPositioningMatrixResponse.builder() | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class PostCreateSupplyPositioningMatrixService implements BaseService<Sup | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, input.getSupplyPositioningMatrix())); | ||||
|                     String.format(Constants.ERR_MSG_10002, "Supply Positioning Matrix", input.getSupplyPositioningMatrix())); | ||||
|         } | ||||
|  | ||||
|         SupplyPositioningMatrix supplyPositioningMatrix = SupplyPositioningMatrix.builder() | ||||
|   | ||||
| @@ -7,12 +7,9 @@ import com.iconplus.smartproc.model.response.SupplyPositioningMatrixResponse; | ||||
| import com.iconplus.smartproc.repository.SupplyPositioningMatrixRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.BooleanUtils; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| @Service | ||||
| @Slf4j | ||||
| public class PutUpdateSupplyPositioningMatrixService implements BaseService<SupplyPositioningMatrixRequest, SupplyPositioningMatrixResponse> { | ||||
| @@ -30,7 +27,7 @@ public class PutUpdateSupplyPositioningMatrixService implements BaseService<Supp | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, input.getId()))); | ||||
|                         String.format(Constants.ERR_MSG_10001, "Supply Positioning Matrix", input.getId()))); | ||||
|  | ||||
|         supplyPositioningMatrix.setSupplyPositioningMatrix(input.getSupplyPositioningMatrix()); | ||||
|         supplyPositioningMatrix.setKeterangan(input.getKeterangan()); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.UnitInisiatorRequest; | ||||
| import com.iconplus.smartproc.repository.UnitInisiatorRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +21,11 @@ public class DeleteUnitInisiatorService implements BaseService<UnitInisiatorRequ | ||||
|     @Override | ||||
|     public EmptyResponse execute(UnitInisiatorRequest input) { | ||||
|  | ||||
|         var unitInisiator = unitInisiatorRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var unitInisiator = unitInisiatorRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Unit Inisiator", input.getId()))); | ||||
|         unitInisiator.setIsDelete(true); | ||||
|         unitInisiatorRepository.save(unitInisiator); | ||||
|         return new EmptyResponse(); | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.UnitInisiatorRequest; | ||||
| import com.iconplus.smartproc.model.response.UnitInisiatorResponse; | ||||
| import com.iconplus.smartproc.repository.UnitInisiatorRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +21,11 @@ public class GetUnitInisiatorService implements BaseService<UnitInisiatorRequest | ||||
|     @Override | ||||
|     public UnitInisiatorResponse execute(UnitInisiatorRequest input) { | ||||
|  | ||||
|         var unitInisiator = unitInisiatorRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var unitInisiator = unitInisiatorRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Unit Inisiator", input.getId()))); | ||||
|         return UnitInisiatorResponse.builder() | ||||
|                 .id(unitInisiator.getId()) | ||||
|                 .unitInisiator(unitInisiator.getUnitInisiator()) | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import com.iconplus.smartproc.model.entity.UnitInisiator; | ||||
| import com.iconplus.smartproc.model.request.UnitInisiatorRequest; | ||||
| import com.iconplus.smartproc.model.response.UnitInisiatorResponse; | ||||
| import com.iconplus.smartproc.repository.UnitInisiatorRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -21,7 +23,10 @@ public class PostCreateUnitInisiatorService implements BaseService<UnitInisiator | ||||
|  | ||||
|         var unitInisiator = unitInisiatorRepository.findByUnitInisiatorAndIsDeleteFalse(input.getUnitInisiator()); | ||||
|         if (unitInisiator.isPresent()) { | ||||
|             throw new BusinessException("err", "err", "err"); | ||||
|             throw new BusinessException(HttpStatus.CONFLICT, | ||||
|                     Constants.ERR_CODE_10002, | ||||
|                     Constants.ERR_TTL_10002, | ||||
|                     String.format(Constants.ERR_MSG_10002, "Unit Inisiator", input.getUnitInisiator())); | ||||
|         } | ||||
|  | ||||
|         UnitInisiator unitInisiatorEntity = UnitInisiator.builder() | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import com.iconplus.smartproc.helper.service.BaseService; | ||||
| import com.iconplus.smartproc.model.request.UnitInisiatorRequest; | ||||
| import com.iconplus.smartproc.model.response.UnitInisiatorResponse; | ||||
| import com.iconplus.smartproc.repository.UnitInisiatorRepository; | ||||
| import com.iconplus.smartproc.util.Constants; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @Service | ||||
| @@ -19,7 +21,11 @@ public class PutUpdateUnitInisiatorService implements BaseService<UnitInisiatorR | ||||
|     @Override | ||||
|     public UnitInisiatorResponse execute(UnitInisiatorRequest input) { | ||||
|  | ||||
|         var unitInisiator = unitInisiatorRepository.findByIdAndIsDeleteFalse(input.getId()).orElseThrow(() -> new BusinessException("err", "err", "err")); | ||||
|         var unitInisiator = unitInisiatorRepository.findByIdAndIsDeleteFalse(input.getId()) | ||||
|                 .orElseThrow(() -> new BusinessException(HttpStatus.CONFLICT, | ||||
|                         Constants.ERR_CODE_10001, | ||||
|                         Constants.ERR_TTL_10001, | ||||
|                         String.format(Constants.ERR_MSG_10001, "Unit Inisiator", input.getId()))); | ||||
|         unitInisiator.setUnitInisiator(input.getUnitInisiator()); | ||||
|         unitInisiator.setKeterangan(input.getKeterangan()); | ||||
|         unitInisiator.setIsActive(input.getIsActive()); | ||||
|   | ||||
| @@ -6,11 +6,11 @@ public class Constants { | ||||
|  | ||||
|     public static final String ERR_CODE_10001 = "10001"; | ||||
|     public static final String ERR_TTL_10001 = "Data tidak ditemukan"; | ||||
|     public static final String ERR_MSG_10001 = "Jenis Anggaran dengan id : %s tidak ditemukan"; | ||||
|     public static final String ERR_MSG_10001 = "%s dengan id : %s tidak ditemukan"; | ||||
|  | ||||
|     public static final String ERR_CODE_10002 = "10002"; | ||||
|     public static final String ERR_TTL_10002 = "Data tersedia"; | ||||
|     public static final String ERR_MSG_10002 = "Jenis Anggaran : %s sudah tersedia"; | ||||
|     public static final String ERR_MSG_10002 = "%s : %s sudah tersedia"; | ||||
|  | ||||
|     public static final String ERR_CODE_10003 = "10003"; | ||||
|     public static final String ERR_TTL_10003 = "Data tidak tersedia"; | ||||
| @@ -28,6 +28,22 @@ public class Constants { | ||||
|     public static final String ERR_TTL_10006 = "Data tersedia"; | ||||
|     public static final String ERR_MSG_10006 = "Role : %s sudah tersedia"; | ||||
|  | ||||
|     public static final String ERR_CODE_10007 = "10007"; | ||||
|     public static final String ERR_TTL_10007 = "Proses Gagal"; | ||||
|     public static final String ERR_MSG_10007 = "Silahkan periksa kembali password baru yg anda input"; | ||||
|  | ||||
|     public static final String ERR_CODE_10008 = "10008"; | ||||
|     public static final String ERR_TTL_10008 = "Proses Gagal"; | ||||
|     public static final String ERR_MSG_10008 = "Gagal generate token"; | ||||
|  | ||||
|     public static final String ERR_CODE_10009 = "10009"; | ||||
|     public static final String ERR_TTL_10009 = "Proses Gagal"; | ||||
|     public static final String ERR_MSG_10009 = "Periksa kembali password sekrang anda"; | ||||
|  | ||||
|     public static final String ERR_CODE_10010 = "10010"; | ||||
|     public static final String ERR_TTL_10010 = "Proses Gagal"; | ||||
|     public static final String ERR_MSG_10010 = "Gagal decrypt password, masukkan password yg ter-encrypt"; | ||||
|  | ||||
|     public static final String ERR_CODE_40041 = "40041"; | ||||
|     public static final String ERR_TTL_40041 = "Terjadi Gangguan"; | ||||
|     public static final String ERR_MSG_40041 = "Masalah Koneksi System"; | ||||
| @@ -35,6 +51,22 @@ public class Constants { | ||||
|     public static final String ERR_CODE_40051 = "40051"; | ||||
|     public static final String ERR_CODE_80007 = "80007"; | ||||
|     public static final String TITLE_INVALID_NEXT_STEP = "Proses tidak dapat dilanjutkan"; | ||||
|     public static final String REFRESH_TOKEN_EXPIRED = "Refresh token expired"; | ||||
|     public static final String REFRESH_TOKEN_NOT_VALID = "Refresh token tidak valid"; | ||||
|  | ||||
|     public static final String ERR_CODE_40042 = "40042"; | ||||
|     public static final String ERR_TTL_40042 = "Terjadi gangguan"; | ||||
|     public static final String ERR_MSG_40042 = "Proses generate token gagal dengan response: null"; | ||||
|  | ||||
|     public static final String ERR_CODE_40038 = "40038"; | ||||
|     public static final String ERR_TITLE_40038 = "Data Sedang Tidak Tersedia"; | ||||
|     public static final String ERR_MESSAGE_40038 = "Data User Tidak Ditemukan."; | ||||
|  | ||||
|     public static final String ERR_CODE_80000 = "80000"; | ||||
|     public static final String N0_SUCH_ALGORITHM_EXCEPTION = "NoSuchAlgorithmException : "; | ||||
|     public static final String N0_SUCH_PADDING_EXCEPTION = "NoSuchPaddingException : "; | ||||
|     public static final String INVALID_KEY_EXCEPTION = "InvalidKeyException : "; | ||||
|     public static final String ILEGAL_BLOCK_SIZE_EXCEPTION = "IllegalBlockSizeException : "; | ||||
|     public static final String BAD_PADDING_EXCEPTION = "BadPaddingException : "; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,52 @@ | ||||
| package com.iconplus.smartproc.util; | ||||
|  | ||||
| import com.iconplus.smartproc.exception.TechnicalException; | ||||
| import org.apache.logging.log4j.LogManager; | ||||
| import org.apache.logging.log4j.Logger; | ||||
|  | ||||
| import javax.crypto.BadPaddingException; | ||||
| import javax.crypto.Cipher; | ||||
| import javax.crypto.IllegalBlockSizeException; | ||||
| import javax.crypto.NoSuchPaddingException; | ||||
| import java.security.InvalidKeyException; | ||||
| import java.security.NoSuchAlgorithmException; | ||||
| import java.security.PrivateKey; | ||||
| import java.util.Base64; | ||||
|  | ||||
| public class EncryptDecryptUtils { | ||||
|  | ||||
|     private static final Logger log = LogManager.getLogger(EncryptDecryptUtils.class); | ||||
|  | ||||
|     private EncryptDecryptUtils() { | ||||
|     } | ||||
|  | ||||
|     public static String decrypt(String data, String base64PrivateKey) { | ||||
|         return decryptChipper(Base64.getDecoder().decode(data.getBytes()), RSAUtil.getPrivateKey(base64PrivateKey)); | ||||
|     } | ||||
|  | ||||
|     private static String decryptChipper(byte[] data, PrivateKey privateKey) { | ||||
|         var result = ""; | ||||
|         try { | ||||
|             var cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); | ||||
|             cipher.init(2, privateKey); | ||||
|             result = new String(cipher.doFinal(data)); | ||||
|         } catch (NoSuchAlgorithmException var3) { | ||||
|             log.error("NoSuchAlgorithmException : {}", var3.getMessage()); | ||||
|             throw new TechnicalException(Constants.ERR_CODE_80000, Constants.N0_SUCH_ALGORITHM_EXCEPTION + var3.getMessage()); | ||||
|         } catch (NoSuchPaddingException var4) { | ||||
|             log.error("NoSuchPaddingException : {}", var4.getMessage()); | ||||
|             throw new TechnicalException(Constants.ERR_CODE_80000,  Constants.N0_SUCH_PADDING_EXCEPTION + var4.getMessage()); | ||||
|         } catch (InvalidKeyException var5) { | ||||
|             log.error("InvalidKeyException : {}", var5.getMessage()); | ||||
|             throw new TechnicalException(Constants.ERR_CODE_80000, Constants.INVALID_KEY_EXCEPTION + var5.getMessage()); | ||||
|         } catch (IllegalBlockSizeException var6) { | ||||
|             log.error("IllegalBlockSizeException : {}", var6.getMessage()); | ||||
|             throw new TechnicalException(Constants.ERR_CODE_80000, Constants.ILEGAL_BLOCK_SIZE_EXCEPTION + var6.getMessage()); | ||||
|         } catch (BadPaddingException var7) { | ||||
|             log.error("BadPaddingException : {}", var7.getMessage()); | ||||
|             throw new TechnicalException(Constants.ERR_CODE_80000, Constants.BAD_PADDING_EXCEPTION + var7.getMessage()); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user