Search in sources :

Example 6 with ProxyUser

use of com.webank.wedatasphere.qualitis.entity.ProxyUser in project Qualitis by WeBankFinTech.

the class ProxyUserServiceImpl method modifyProxyUser.

@Override
@Transactional(rollbackFor = { RuntimeException.class, UnExpectedRequestException.class })
public GeneralResponse<?> modifyProxyUser(ModifyProxyUserRequest request) throws UnExpectedRequestException {
    // Check Arguments
    ModifyProxyUserRequest.checkRequest(request);
    // Check existence of proxy user
    ProxyUser proxyUserInDb = proxyUserRepository.findById(request.getProxyUserId()).orElse(null);
    if (proxyUserInDb == null) {
        throw new UnExpectedRequestException("ProxyUser id: [" + request.getProxyUserId() + "] {&DOES_NOT_EXIST}");
    }
    String oldProxyUserName = proxyUserInDb.getProxyUserName();
    // Modify proxy user name
    proxyUserInDb.setProxyUserName(request.getProxyUserName());
    proxyUserRepository.save(proxyUserInDb);
    LOGGER.info("Succeed to modify proxy user. old proxy_user name: {}, new proxy_user name: {}", oldProxyUserName, proxyUserInDb.getProxyUserName());
    return new GeneralResponse<>("200", "{&SUCCEED_TO_MODIFY_PROXY_USER_NAME}", null);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) ProxyUser(com.webank.wedatasphere.qualitis.entity.ProxyUser) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ProxyUser (com.webank.wedatasphere.qualitis.entity.ProxyUser)6 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)6 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)5 Transactional (org.springframework.transaction.annotation.Transactional)4 UserProxyUser (com.webank.wedatasphere.qualitis.entity.UserProxyUser)2 AddProxyUserResponse (com.webank.wedatasphere.qualitis.response.AddProxyUserResponse)2 AddUserProxyUserResponse (com.webank.wedatasphere.qualitis.response.AddUserProxyUserResponse)2 GetAllResponse (com.webank.wedatasphere.qualitis.response.GetAllResponse)2 ArrayList (java.util.ArrayList)2 Pageable (org.springframework.data.domain.Pageable)2 Sort (org.springframework.data.domain.Sort)2 User (com.webank.wedatasphere.qualitis.entity.User)1