Search in sources :

Example 11 with AppUser

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");
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) AppUser(com.sohu.cache.entity.AppUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with AppUser

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;
}
Also used : AppUser(com.sohu.cache.entity.AppUser) AppToUser(com.sohu.cache.entity.AppToUser)

Example 13 with AppUser

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);
}
Also used : InstanceAlertValueResult(com.sohu.cache.entity.InstanceAlertValueResult) AppUser(com.sohu.cache.entity.AppUser) AppDailyData(com.sohu.cache.entity.AppDailyData)

Example 14 with AppUser

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;
}
Also used : ArrayList(java.util.ArrayList) AppUser(com.sohu.cache.entity.AppUser)

Example 15 with AppUser

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());
}
Also used : SystemConfig(com.sohu.cache.entity.SystemConfig) HashMap(java.util.HashMap) 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)

Aggregations

AppUser (com.sohu.cache.entity.AppUser)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 ModelAndView (org.springframework.web.servlet.ModelAndView)15 SuccessEnum (com.sohu.cache.web.enums.SuccessEnum)8 AppAudit (com.sohu.cache.entity.AppAudit)3 InstanceConfig (com.sohu.cache.entity.InstanceConfig)3 AppDesc (com.sohu.cache.entity.AppDesc)2 AppToUser (com.sohu.cache.entity.AppToUser)2 InstanceAlert (com.sohu.cache.entity.InstanceAlert)2 BaseTest (com.sohu.test.BaseTest)2 Date (java.util.Date)2 Test (org.junit.Test)2 AppDataMigrateEnum (com.sohu.cache.constant.AppDataMigrateEnum)1 AppDailyData (com.sohu.cache.entity.AppDailyData)1 InstanceAlertValueResult (com.sohu.cache.entity.InstanceAlertValueResult)1 InstanceInfo (com.sohu.cache.entity.InstanceInfo)1 LoginResult (com.sohu.cache.entity.LoginResult)1 SystemConfig (com.sohu.cache.entity.SystemConfig)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1