use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.
the class UserManageController method doUserInit.
/**
* 用户初始化
* @param id 用户id
* @return
*/
@RequestMapping(value = "/init")
public ModelAndView doUserInit(HttpServletRequest request, HttpServletResponse response, Model model, Long id) {
if (id != null) {
AppUser user = userService.get(id);
model.addAttribute("user", user);
model.addAttribute("modify", true);
}
return new ModelAndView("manage/user/initUser");
}
use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.
the class UserServiceImpl method getByAppId.
@Override
public List<AppUser> getByAppId(Long appId) {
if (appId == null || appId < 0) {
return Collections.emptyList();
}
List<AppUser> resultList = new ArrayList<AppUser>();
List<AppToUser> appToUsers = appToUserDao.getByAppId(appId);
if (appToUsers != null && appToUsers.size() > 0) {
for (AppToUser appToUser : appToUsers) {
Long userId = appToUser.getUserId();
if (userId == null) {
continue;
}
AppUser user = appUserDao.get(userId);
if (user == null) {
continue;
}
resultList.add(user);
}
}
return resultList;
}
use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.
the class AppEmailUtil method noticeAppResult.
/**
* 应用状态通知
* @param appDesc
* @param appAudit
*/
public void noticeAppResult(AppDesc appDesc, AppAudit appAudit) {
List<String> ccEmailList = getCCEmailList(appDesc, appAudit);
String mailContent = VelocityUtils.createText(velocityEngine, appDesc, appAudit, new AppDailyData(), new ArrayList<InstanceAlertValueResult>(), "appAudit.vm", "UTF-8");
AppUser appUser = userService.get(appDesc.getUserId());
emailComponent.sendMail("【CacheCloud】状态通知", mailContent, Arrays.asList(appUser.getEmail()), ccEmailList);
}
use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.
the class AppEmailUtil method noticeAllUser.
/**
* 系统通知
* @param noticeContent
* @return
*/
public boolean noticeAllUser(String noticeContent) {
if (StringUtils.isBlank(noticeContent)) {
return false;
}
try {
String mailTitle = "【CacheCloud】-系统通知";
StringBuffer mailContent = new StringBuffer();
String[] noticeArray = noticeContent.split(ConstUtils.NEXT_LINE);
for (String noticeLine : noticeArray) {
mailContent.append(noticeLine).append("<br/>");
}
List<String> emailList = new ArrayList<String>();
List<AppUser> appUserList = userService.getUserList(null);
if (CollectionUtils.isEmpty(appUserList)) {
return false;
}
for (AppUser appUser : appUserList) {
String email = appUser.getEmail();
if (StringUtils.isBlank(email)) {
continue;
}
emailList.add(email);
}
return emailComponent.sendMail(mailTitle, mailContent.toString(), emailList, Arrays.asList(emailComponent.getAdminEmail().split(ConstUtils.COMMA)));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.
the class ConfigManageController method update.
/**
* 修改配置
*
* @param request
* @param response
* @param model
* @return
*/
@RequestMapping(value = "/update")
public ModelAndView update(HttpServletRequest request, HttpServletResponse response, Model model) {
AppUser appUser = getUserInfo(request);
logger.warn("user {} want to change config!", appUser.getName());
List<SystemConfig> oldConfigList = configService.getConfigList(1);
SuccessEnum successEnum;
Map<String, String> configMap = new HashMap<String, String>();
try {
Map<String, String[]> paramMap = request.getParameterMap();
for (Entry<String, String[]> entry : paramMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue()[0];
if (StringUtils.isNotBlank(key)) {
configMap.put(key, value);
}
}
if (MapUtils.isEmpty(configMap)) {
logger.error("params {} may be empty!!", paramMap);
}
successEnum = configService.updateConfig(configMap);
if (successEnum.equals(SuccessEnum.SUCCESS)) {
configService.reloadSystemConfig();
}
} catch (Exception e) {
successEnum = SuccessEnum.FAIL;
logger.error(e.getMessage(), e);
}
Map<String, String> systemDifConfigMap = getDifConfigMap(oldConfigList, configMap);
appEmailUtil.sendSystemConfigDifEmail(appUser, systemDifConfigMap, successEnum);
logger.warn("user {} change config result is {}!", appUser.getName(), successEnum.value());
return new ModelAndView("redirect:/manage/config/init?success=" + successEnum.value());
}
Aggregations