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