Search in sources :

Example 1 with EcBaseServiceResult

use of com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult in project dq-easy-cloud by dq-open-cloud.

the class EcBaseBusinessException method getMessage.

@Override
public String getMessage() {
    if (!isFormated) {
        if (EcStringUtils.isNotEmpty(errorMsg) && EcArrayUtils.isNotEmpty(this.formatValues)) {
            this.errorMsg = String.format(errorMsg, this.formatValues);
            this.isFormated = true;
        }
    }
    EcBaseServiceResult result = EcBaseServiceResult.newInstance();
    result.buildErrorCodeAndMsg(errorCode, errorMsg);
    result.buildResult(exceptionDetail);
    return EcJSONUtils.parseObject(result, String.class);
}
Also used : EcBaseServiceResult(com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult)

Example 2 with EcBaseServiceResult

use of com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult in project dq-easy-cloud by dq-open-cloud.

the class EcBaseExceptionHandle method handleAndReturnData.

/**
 * 基于@ExceptionHandler异常处理
 */
@ExceptionHandler
@ResponseBody
public EcBaseServiceResult handleAndReturnData(HttpServletRequest request, HttpServletResponse response, Exception ex) {
    logger.error(ex.getMessage(), ex);
    EcBaseServiceResult ecBaseServiceResult = EcBaseServiceResult.newInstance();
    EcBaseServiceResultException serviceResultException = EcBaseServiceResultException.newInstance();
    String path = request.getRequestURL().toString();
    if (ex instanceof EcBaseBusinessException) {
        EcBaseBusinessException dbbException = (EcBaseBusinessException) ex;
        ecBaseServiceResult.buildErrorCodeAndMsg(dbbException.getErrorCode(), dbbException.getErrorMsg());
    } else if (ex instanceof RuntimeException) {
        ecBaseServiceResult.buildDqBaseErrorCodeInf(EcBaseErrorCodeEnum.RUNTIME_EXCEPTION);
    } else {
        ecBaseServiceResult.buildDqBaseErrorCodeInf(EcBaseErrorCodeEnum.SYS_EXCEPTION);
    }
    serviceResultException.setException(ex.getClass().getName());
    serviceResultException.setFailureDetails(ex.getMessage());
    serviceResultException.setTimstamp(EcDateUtils.getCurrentDate());
    serviceResultException.setPath(path);
    ecBaseServiceResult.buildServiceResultException(serviceResultException);
    EcLogUtils.error("异常统一处理日志", ecBaseServiceResult, logger);
    return ecBaseServiceResult;
}
Also used : EcBaseServiceResultException(com.easy.cloud.core.exception.dto.EcBaseServiceResultException) EcBaseServiceResult(com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with EcBaseServiceResult

use of com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult in project dq-easy-cloud by dq-open-cloud.

the class SysFilterConfigLogic method updateSysFilterConfig.

@Transactional(rollbackFor = Exception.class)
public EcBaseServiceResult updateSysFilterConfig(SysFilterConfigDTO sysFilterConfigDTO) {
    EcBaseServiceResult serviceResult = sysFilterConfigService.updateSysFilterConfig(sysFilterConfigDTO);
    authorityManager.updateFilterChains(sysFilterConfigService.loadFilterChainDefinitions());
    return serviceResult;
}
Also used : EcBaseServiceResult(com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with EcBaseServiceResult

use of com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult in project dq-easy-cloud by dq-open-cloud.

the class UserServiceImpl method register.

@Override
@Transactional
public EcBaseServiceResult register(UserDTO userDTO) {
    EcBaseServiceResult dqBaseServiceResult = EcBaseServiceResult.newInstanceOfSuccess();
    if (EcBaseUtils.isNull(userDTO)) {
        throw EcBaseBusinessException.newInstance(UserErrorCodeEnum.USER_CANT_NULL);
    }
    if (EcStringUtils.isEmpty(userDTO.getUserName())) {
        throw EcBaseBusinessException.newInstance(UserErrorCodeEnum.USER_NAME_CANT_EMPTY);
    }
    if (EcStringUtils.isEmpty(userDTO.getPassword())) {
        throw EcBaseBusinessException.newInstance(UserErrorCodeEnum.USER_PASSWOR_CANT_EMPTY);
    }
    if (EcStringUtils.isEmpty(userDTO.getEmail())) {
        throw EcBaseBusinessException.newInstance(UserErrorCodeEnum.USER_EMAIL_CANT_EMPTY);
    }
    UserEntity userEntity = userRepository.saveUserInfo(EcJSONUtils.parseObject(userDTO, UserEntity.class));
    return dqBaseServiceResult.buildResult(userEntity);
}
Also used : EcBaseServiceResult(com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult) UserEntity(com.easy.cloud.user.base.pojo.entity.UserEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with EcBaseServiceResult

use of com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult in project dq-easy-cloud by dq-open-cloud.

the class UserServiceImpl method saveUser.

@Override
@Transactional
public EcBaseServiceResult saveUser(UserDTO userDTO) {
    EcBaseServiceResult dqBaseServiceResult = EcBaseServiceResult.newInstanceOfSuccess();
    if (EcBaseUtils.isNull(userDTO)) {
        dqBaseServiceResult.buildErrorCode(UserErrorCodeEnum.USER_CANT_NULL);
        return dqBaseServiceResult;
    }
    if (EcStringUtils.isEmpty(userDTO.getUserName())) {
        dqBaseServiceResult.buildErrorCode(UserErrorCodeEnum.USER_NAME_CANT_EMPTY);
        return dqBaseServiceResult;
    }
    if (EcStringUtils.isEmpty(userDTO.getPassword())) {
        dqBaseServiceResult.buildErrorCode(UserErrorCodeEnum.USER_PASSWOR_CANT_EMPTY);
        return dqBaseServiceResult;
    }
    UserEntity userEntity = userRepository.saveUserInfo(EcJSONUtils.parseObject(userDTO, UserEntity.class));
    return dqBaseServiceResult.buildResult(userEntity);
}
Also used : EcBaseServiceResult(com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult) UserEntity(com.easy.cloud.user.base.pojo.entity.UserEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

EcBaseServiceResult (com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult)7 Transactional (org.springframework.transaction.annotation.Transactional)4 UserEntity (com.easy.cloud.user.base.pojo.entity.UserEntity)2 EcBaseBusinessException (com.easy.cloud.core.exception.bo.EcBaseBusinessException)1 EcBaseServiceResultException (com.easy.cloud.core.exception.dto.EcBaseServiceResultException)1 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1