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