Search in sources :

Example 1 with AppUser

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

the class AppUserDaoTest method testAppDao.

@Test
public void testAppDao() {
    AppUser appUser = AppUser.buildFrom(null, "11", "fff", "leifu@sohu-inc.com", "13820794024", -1);
    appUserDao.save(appUser);
    logger.info("{}", appUser);
}
Also used : AppUser(com.sohu.cache.entity.AppUser) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Example 2 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 3 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 4 with AppUser

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

the class AppDataMigrateController method start.

/**
     * 开始迁移
     * @return
     */
@RequestMapping(value = "/start")
public ModelAndView start(HttpServletRequest request, HttpServletResponse response, Model model) {
    //相关参数
    String migrateMachineIp = request.getParameter("migrateMachineIp");
    String sourceRedisMigrateIndex = request.getParameter("sourceRedisMigrateIndex");
    AppDataMigrateEnum sourceRedisMigrateEnum = AppDataMigrateEnum.getByIndex(NumberUtils.toInt(sourceRedisMigrateIndex, -1));
    String sourceServers = request.getParameter("sourceServers");
    String targetRedisMigrateIndex = request.getParameter("targetRedisMigrateIndex");
    AppDataMigrateEnum targetRedisMigrateEnum = AppDataMigrateEnum.getByIndex(NumberUtils.toInt(targetRedisMigrateIndex, -1));
    String targetServers = request.getParameter("targetServers");
    long sourceAppId = NumberUtils.toLong(request.getParameter("sourceAppId"));
    long targetAppId = NumberUtils.toLong(request.getParameter("targetAppId"));
    String redisSourcePass = request.getParameter("redisSourcePass");
    String redisTargetPass = request.getParameter("redisTargetPass");
    AppUser appUser = getUserInfo(request);
    long userId = appUser == null ? 0 : appUser.getId();
    // 不需要对格式进行检验,check已经做过了,开始迁移
    boolean isSuccess = appDataMigrateCenter.migrate(migrateMachineIp, sourceRedisMigrateEnum, sourceServers, targetRedisMigrateEnum, targetServers, sourceAppId, targetAppId, redisSourcePass, redisTargetPass, userId);
    model.addAttribute("status", isSuccess ? 1 : 0);
    return new ModelAndView("");
}
Also used : AppDataMigrateEnum(com.sohu.cache.constant.AppDataMigrateEnum) ModelAndView(org.springframework.web.servlet.ModelAndView) AppUser(com.sohu.cache.entity.AppUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AppUser

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

the class InstanceAlertValueController method remove.

/**
     * 删除配置
     */
@RequestMapping(value = "/remove")
public ModelAndView remove(HttpServletRequest request, HttpServletResponse response, Model model) {
    AppUser appUser = getUserInfo(request);
    String configKey = request.getParameter("configKey");
    if (StringUtils.isBlank(configKey)) {
        model.addAttribute("status", SuccessEnum.FAIL.value());
        model.addAttribute("message", ErrorMessageEnum.PARAM_ERROR_MSG.getMessage() + "configKey=" + configKey);
        return new ModelAndView("");
    }
    logger.warn("user {} want to delete configKey {}", appUser.getName(), configKey);
    SuccessEnum successEnum;
    try {
        instanceAlertValueService.remove(configKey);
        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 configKey {} , result is {}", appUser.getName(), configKey, successEnum.info());
    model.addAttribute("status", successEnum.value());
    return new ModelAndView("");
}
Also used : 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