Search in sources :

Example 1 with SystemConfig

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

the class SystemConfigServiceImpl method findByKeyName.

@Override
public GeneralResponse<?> findByKeyName(String keyName) throws UnExpectedRequestException {
    SystemConfig systemConfigInDb = systemConfigDao.findByKeyName(keyName);
    if (null == systemConfigInDb) {
        throw new UnExpectedRequestException("key name {&DOES_NOT_EXIST}");
    }
    LOGGER.info("{&SUCCEED_TO_FIND_SYSTEM_CONFIG}. key:{}, value: {}", systemConfigInDb.getKeyName(), systemConfigInDb.getValue());
    return new GeneralResponse<>("200", "{&SUCCEED_TO_FIND_SYSTEM_CONFIG}", systemConfigInDb);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) SystemConfig(com.webank.wedatasphere.qualitis.entity.SystemConfig)

Example 2 with SystemConfig

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

the class SystemConfigServiceImpl method modifySystemConfig.

@Override
@Transactional(rollbackFor = Exception.class)
public GeneralResponse<?> modifySystemConfig(ModifySystemConfigRequest request) throws UnExpectedRequestException {
    // Check Argument
    ModifySystemConfigRequest.checkRequest(request);
    checkKeyName(request.getKeyName());
    // Find System Config by key name
    String keyName = request.getKeyName();
    String value = request.getValue();
    SystemConfig systemConfigInDb = systemConfigDao.findByKeyName(keyName);
    if (null == systemConfigInDb) {
        throw new UnExpectedRequestException("key name {&DOES_NOT_EXIST}");
    }
    LOGGER.info("{&SUCCEED_TO_FIND_SYSTEM_CONFIG}. key:{}, value: {}", systemConfigInDb.getKeyName(), systemConfigInDb.getValue());
    // 修改url并保存
    systemConfigInDb.setValue(value);
    SystemConfig savedSystemConfig = systemConfigDao.saveSystemConfig(systemConfigInDb);
    LOGGER.info("{&SUCCEED_TO_MODIFY_SYSTEM_CONFIG}. key: {}, value: {}", savedSystemConfig.getKeyName(), savedSystemConfig.getValue());
    return new GeneralResponse<>("200", "{&SUCCEED_TO_MODIFY_SYSTEM_CONFIG}", null);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) SystemConfig(com.webank.wedatasphere.qualitis.entity.SystemConfig) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SystemConfig (com.webank.wedatasphere.qualitis.entity.SystemConfig)2 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)2 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)2 Transactional (org.springframework.transaction.annotation.Transactional)1