Search in sources :

Example 6 with SystemConfig

use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.

the class SystemConfigServiceImplTest method initSystemConfig.

private SystemConfig initSystemConfig(String property, String value) {
    SystemConfig systemConfig = new SystemConfig();
    systemConfig.setProperty(property);
    systemConfig.setValue(value);
    return systemConfig;
}
Also used : SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig)

Example 7 with SystemConfig

use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.

the class RegistryCenterServiceImpl method notifyRefreshRegCenter.

@Override
public void notifyRefreshRegCenter() throws SaturnJobConsoleException {
    SystemConfig systemConfig = new SystemConfig();
    systemConfig.setProperty(SystemConfigProperties.REFRESH_REGISTRY_CENTER_UUID);
    systemConfig.setValue(UUID.randomUUID().toString());
    systemConfigService.insertOrUpdate(systemConfig);
}
Also used : SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig)

Example 8 with SystemConfig

use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.

the class SystemConfigServiceImpl method createConfig.

@Override
public Integer createConfig(SystemConfig systemConfig) throws SaturnJobConsoleException {
    List<String> properties = new ArrayList<>();
    properties.add(systemConfig.getProperty());
    List<SystemConfig> systemConfigs = systemConfig4SqlService.selectByProperty(systemConfig.getProperty());
    boolean found = false;
    if (systemConfigs != null) {
        for (int i = 0; i < systemConfigs.size(); i++) {
            SystemConfig config = systemConfigs.get(i);
            if (StringUtils.equals(config.getProperty(), systemConfig.getProperty())) {
                found = true;
                break;
            }
        }
    }
    if (found) {
        throw new SaturnJobConsoleException(String.format("systemConfig %s already existed", systemConfig.getProperty()));
    }
    int result = systemConfig4SqlService.insert(systemConfig);
    updateCacheIfNeed(systemConfig, result);
    return result;
}
Also used : SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException)

Example 9 with SystemConfig

use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.

the class SystemConfigController method insertOrUpdate.

@RequestMapping(value = "system_config/insertOrUpdate", method = RequestMethod.POST)
@ResponseBody
public RequestResult insertOrUpdate(HttpServletRequest request, String property2, String value2) {
    RequestResult requestResult = new RequestResult();
    try {
        if (property2 == null) {
            throw new SaturnJobConsoleException("property cannot be null");
        }
        SystemConfig systemConfig = new SystemConfig();
        systemConfig.setProperty(property2);
        systemConfig.setValue(value2);
        systemConfigService.insertOrUpdate(systemConfig);
        requestResult.setSuccess(true);
    } catch (SaturnJobConsoleException e) {
        requestResult.setSuccess(false);
        requestResult.setMessage(e.getMessage());
        return requestResult;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        requestResult.setSuccess(false);
        requestResult.setMessage(e.toString());
    }
    return requestResult;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with SystemConfig

use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.

the class SystemConfigController method queryValue.

@RequestMapping(value = "system_config/queryValue", method = RequestMethod.POST)
@ResponseBody
public RequestResult queryValue(HttpServletRequest request, String property1) {
    RequestResult requestResult = new RequestResult();
    try {
        List<String> properties = new ArrayList<>();
        if (property1 != null) {
            String[] split = property1.split(",");
            if (split != null) {
                for (String s : split) {
                    if (s != null && s.trim().length() > 0) {
                        String tmp = s.trim();
                        if (!properties.contains(tmp)) {
                            properties.add(tmp);
                        }
                    }
                }
            }
        }
        List<SystemConfig> systemConfigs = systemConfigService.getSystemConfigsDirectly(properties);
        requestResult.setSuccess(true);
        requestResult.setObj(systemConfigs);
    } catch (SaturnJobConsoleException e) {
        requestResult.setSuccess(false);
        requestResult.setMessage(e.getMessage());
        return requestResult;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        requestResult.setSuccess(false);
        requestResult.setMessage(e.toString());
    }
    return requestResult;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) ArrayList(java.util.ArrayList) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

SystemConfig (com.vip.saturn.job.console.mybatis.entity.SystemConfig)15 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)7 Audit (com.vip.saturn.job.console.aop.annotation.Audit)4 SuccessResponseEntity (com.vip.saturn.job.console.controller.SuccessResponseEntity)4 ApiResponses (io.swagger.annotations.ApiResponses)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 SystemConfigVo (com.vip.saturn.job.console.domain.SystemConfigVo)3 JobConfigMeta (com.vip.saturn.job.console.domain.JobConfigMeta)2 RequestResult (com.vip.saturn.job.console.domain.RequestResult)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 JSONObject (com.alibaba.fastjson.JSONObject)1 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1