Search in sources :

Example 11 with SuccessEnum

use of com.sohu.cache.web.enums.SuccessEnum in project cachecloud by sohutv.

the class RedisConfigTemplateController method update.

/**
     * 修改配置
     */
@RequestMapping(value = "/update")
public ModelAndView update(HttpServletRequest request, HttpServletResponse response, Model model) {
    AppUser appUser = getUserInfo(request);
    String id = request.getParameter("id");
    String configKey = request.getParameter("configKey");
    String configValue = request.getParameter("configValue");
    String info = request.getParameter("info");
    int status = NumberUtils.toInt(request.getParameter("status"), -1);
    if (StringUtils.isBlank(id) || !NumberUtils.isDigits(id) || StringUtils.isBlank(configKey) || status > 1 || status < 0) {
        model.addAttribute("status", SuccessEnum.FAIL.value());
        model.addAttribute("message", ErrorMessageEnum.PARAM_ERROR_MSG.getMessage() + "id=" + id + ",configKey=" + configKey + ",configValue=" + configValue + ",status=" + status);
        return new ModelAndView("");
    }
    //开始修改
    logger.warn("user {} want to change id={}'s configKey={}, configValue={}, info={}, status={}", appUser.getName(), id, configKey, configValue, info, status);
    SuccessEnum successEnum;
    InstanceConfig instanceConfig = redisConfigTemplateService.getById(NumberUtils.toLong(id));
    try {
        instanceConfig.setConfigValue(configValue);
        instanceConfig.setInfo(info);
        instanceConfig.setStatus(status);
        redisConfigTemplateService.saveOrUpdate(instanceConfig);
        successEnum = SuccessEnum.SUCCESS;
    } catch (Exception e) {
        successEnum = SuccessEnum.FAIL;
        model.addAttribute("message", ErrorMessageEnum.INNER_ERROR_MSG.getMessage());
        logger.error(e.getMessage(), e);
    }
    logger.warn("user {} want to change id={}'s configKey={}, configValue={}, info={}, status={}, result is {}", appUser.getName(), id, configKey, configValue, info, status, successEnum.value());
    //发送邮件通知
    appEmailUtil.sendRedisConfigTemplateChangeEmail(appUser, instanceConfig, successEnum, RedisConfigTemplateChangeEnum.UPDATE);
    model.addAttribute("status", successEnum.value());
    return new ModelAndView("");
}
Also used : InstanceConfig(com.sohu.cache.entity.InstanceConfig) ModelAndView(org.springframework.web.servlet.ModelAndView) AppUser(com.sohu.cache.entity.AppUser) SuccessEnum(com.sohu.cache.web.enums.SuccessEnum) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with SuccessEnum

use of com.sohu.cache.web.enums.SuccessEnum in project cachecloud by sohutv.

the class AppController method doUpdateAppDetail.

/**
     * 修改应用信息
     */
@RequestMapping(value = "/updateAppDetail")
public ModelAndView doUpdateAppDetail(HttpServletRequest request, HttpServletResponse response, Model model) {
    long appId = NumberUtils.toLong(request.getParameter("appId"), 0);
    AppUser appUser = getUserInfo(request);
    logger.warn("{} want to update appId={} info!", appUser.getName(), appId);
    String appDescName = request.getParameter("appDescName");
    String appDescIntro = request.getParameter("appDescIntro");
    String officer = request.getParameter("officer");
    SuccessEnum successEnum = SuccessEnum.SUCCESS;
    if (appId <= 0 || StringUtils.isBlank(appDescName) || StringUtils.isBlank(appDescIntro) || StringUtils.isBlank(officer)) {
        successEnum = SuccessEnum.FAIL;
    } else {
        try {
            AppDesc appDesc = appService.getByAppId(appId);
            appDesc.setName(appDescName);
            appDesc.setIntro(appDescIntro);
            appDesc.setOfficer(officer);
            appService.update(appDesc);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            successEnum = SuccessEnum.FAIL;
        }
    }
    write(response, String.valueOf(successEnum.value()));
    return null;
}
Also used : SuccessEnum(com.sohu.cache.web.enums.SuccessEnum) ParseException(java.text.ParseException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SuccessEnum (com.sohu.cache.web.enums.SuccessEnum)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ModelAndView (org.springframework.web.servlet.ModelAndView)9 AppUser (com.sohu.cache.entity.AppUser)8 InstanceConfig (com.sohu.cache.entity.InstanceConfig)3 InstanceAlert (com.sohu.cache.entity.InstanceAlert)2 ParseException (java.text.ParseException)2 AppAudit (com.sohu.cache.entity.AppAudit)1 SystemConfig (com.sohu.cache.entity.SystemConfig)1 HighchartPoint (com.sohu.cache.web.chart.model.HighchartPoint)1 HashMap (java.util.HashMap)1