Search in sources :

Example 6 with AppUser

use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.

the class RedisConfigTemplateController method remove.

/**
     * 删除配置
     */
@RequestMapping(value = "/remove")
public ModelAndView remove(HttpServletRequest request, HttpServletResponse response, Model model) {
    AppUser appUser = getUserInfo(request);
    String idParam = request.getParameter("id");
    long id = NumberUtils.toLong(idParam);
    if (id <= 0) {
        model.addAttribute("status", SuccessEnum.FAIL.value());
        model.addAttribute("message", ErrorMessageEnum.PARAM_ERROR_MSG.getMessage() + "id=" + idParam);
        return new ModelAndView("");
    }
    logger.warn("user {} want to delete id={}'s config", appUser.getName(), id);
    SuccessEnum successEnum;
    InstanceConfig instanceConfig = redisConfigTemplateService.getById(id);
    try {
        redisConfigTemplateService.remove(id);
        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 delete id={}'s config, result is {}", appUser.getName(), id, successEnum.value());
    //发送邮件通知
    appEmailUtil.sendRedisConfigTemplateChangeEmail(appUser, instanceConfig, successEnum, RedisConfigTemplateChangeEnum.DELETE);
    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 7 with AppUser

use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.

the class UserController method doAddUser.

/**
     * 注册用户申请
     */
@RequestMapping(value = "/apply")
public ModelAndView doAddUser(HttpServletRequest request, HttpServletResponse response, Model model, String name, String chName, String email, String mobile, Integer type, Long userId) {
    SuccessEnum success = SuccessEnum.SUCCESS;
    try {
        //保存用户(type=-1为无效用户,需要审批)
        AppUser appUser = AppUser.buildFrom(userId, name, chName, email, mobile, type);
        userService.save(appUser);
        //提交审批
        AppAudit appAudit = appService.saveRegisterUserApply(appUser, AppAuditType.REGISTER_USER_APPLY);
        appEmailUtil.noticeUserResult(appUser, appAudit);
    } catch (Exception e) {
        success = SuccessEnum.FAIL;
        logger.error(e.getMessage(), e);
    }
    return new ModelAndView("redirect:/user/register?success=" + success.value());
}
Also used : AppAudit(com.sohu.cache.entity.AppAudit) 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 8 with AppUser

use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.

the class AppAndInstanceAuthorityInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    // 1. 获取用户
    long userId = userLoginStatusService.getUserIdFromLoginStatus(request);
    AppUser user = userService.get(userId);
    // 2. 管理员直接跳过
    if (AppUserTypeEnum.ADMIN_USER.value().equals(user.getType())) {
        return true;
    }
    // 3. 应用id
    String appId = request.getParameter("appId");
    if (StringUtils.isNotBlank(appId)) {
        checkUserAppPower(response, request.getSession(true), user, NumberUtils.toLong(appId));
    }
    // 4. 实例权限检测(其实也是应用)
    String instanceId = request.getParameter("instanceId");
    if (StringUtils.isNotBlank(instanceId)) {
        InstanceInfo instanceInfo = instanceStatsCenter.getInstanceInfo(Long.parseLong(instanceId));
        checkUserAppPower(response, request.getSession(true), user, instanceInfo.getAppId());
    }
    return true;
}
Also used : AppUser(com.sohu.cache.entity.AppUser) InstanceInfo(com.sohu.cache.entity.InstanceInfo)

Example 9 with AppUser

use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.

the class FrontUserLoginInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    long userId = userLoginStatusService.getUserIdFromLoginStatus(request);
    AppUser user = userService.get(userId);
    if (user == null) {
        String redirectUrl = LoginInterceptorUtil.getLoginRedirectUrl(request);
        response.sendRedirect(redirectUrl);
        return false;
    }
    request.setAttribute("userInfo", user);
    request.setAttribute("uri", request.getRequestURI());
    return true;
}
Also used : AppUser(com.sohu.cache.entity.AppUser)

Example 10 with AppUser

use of com.sohu.cache.entity.AppUser in project cachecloud by sohutv.

the class UserManageController method doAddAuditStatus.

@RequestMapping(value = "/addAuditStatus")
public ModelAndView doAddAuditStatus(HttpServletRequest request, HttpServletResponse response, Model model, Integer status, Long appAuditId, String refuseReason) {
    AppAudit appAudit = appService.getAppAuditById(appAuditId);
    AppUser appUser = userService.get(appAudit.getUserId());
    // 通过或者驳回并记录日志
    appService.updateUserAuditStatus(appAuditId, status);
    // 记录驳回原因
    if (AppCheckEnum.APP_REJECT.value().equals(status)) {
        appAudit.setRefuseReason(refuseReason);
        appService.updateRefuseReason(appAudit, getUserInfo(request));
        userService.delete(appUser.getId());
    }
    // 发邮件统计
    if (AppCheckEnum.APP_PASS.value().equals(status) || AppCheckEnum.APP_REJECT.value().equals(status)) {
        appUser.setType(AppUserTypeEnum.REGULAR_USER.value());
        appAudit.setStatus(status);
        userService.update(appUser);
        appEmailUtil.noticeUserResult(appUser, appAudit);
    }
    // 批准成功直接跳转
    if (AppCheckEnum.APP_PASS.value().equals(status)) {
        return new ModelAndView("redirect:/manage/app/auditList");
    }
    write(response, String.valueOf(SuccessEnum.SUCCESS.value()));
    return null;
}
Also used : AppAudit(com.sohu.cache.entity.AppAudit) ModelAndView(org.springframework.web.servlet.ModelAndView) AppUser(com.sohu.cache.entity.AppUser) 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