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("");
}
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;
}
Aggregations