/** * do login * @param user userInfo * @param request requestInfo * @param response responseInfo * @param map data * @return login result * @throws IOException */ @RequestMapping(value="login",method = RequestMethod.POST) public String doLogin(User user, HttpServletRequest request, HttpServletResponse response,ModelMap map) throws IOException{ if(!StringUtils.isEmpty(user.getName())){ request.getSession().setAttribute(Constant.SESSION_USER_KEY,user); //login success, redirect to home controller, change the url also. if return viewName,can't change url. response.sendRedirect("/home"); return null; }else{ map.put("welcomeMsg",this.msg); return "login"; //login failure, return login page } }
@PostMapping(value="/user/update") public ExecutionStatus updateUser(ModelMap model, @RequestBody User reqUser) { User user = new User(); user.setId(reqUser.getId()); user.setFirstName(reqUser.getFirstname()); user.setLastname(reqUser.getLastname()); user.setContactNumber(reqUser.getContactNumber()); user.setAlternateContactNumber(reqUser.getAlternateContactNumber()); user.setCityCode(reqUser.getCityCode()); user.setStateCode(reqUser.getStateCode()); user.setCountryCode(reqUser.getCountryCode()); user.setAge(reqUser.getAge()); user.setGender(reqUser.getGender()); userService.update(user); return new ExecutionStatus("USER_ACCOUNT_UPDATED", "User account successfully updated"); }
@RequestMapping("performance") public ModelAndView performancePortal(ModelMap modelMap, HttpSession session, @RequestParam(value = "serviceName", required = false) String serviceNamePort, @RequestParam(value = "project", required = false) String project, @RequestParam(value = "life", required = false) String life, @RequestParam(value = CSAP.HOST_PARAM, required = false) String hostName) throws IOException { setCommonAttributes( modelMap, session, "Analytics Portal" ); modelMap.put( "project", project ); modelMap.put( "life", life ); modelMap.addAttribute( "metricLabels", buildMetricLabels() ); return new ModelAndView( "performance/perf-main" ); }
@RequestMapping(value = "/signin", method = { RequestMethod.POST}) public String signin(ModelMap map, User user, HttpServletRequest request) { String error; UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPasswd()); token.setRememberMe(null != request.getParameter("rememberme") ? true : false); try { Subject subject = SecurityUtils.getSubject(); subject.login(token); subject.getSession().setAttribute("curUser", userService.findByUsername((String) subject.getPrincipal())); return "redirect:/dashboard/console"; } catch (UnknownAccountException uae) { error = "用户名错误!"; } catch (IncorrectCredentialsException ice) { error = "密码错误!"; } catch (LockedAccountException lae) { error = "用户被锁定!"; } map.addAttribute("error", error); return "signin"; }
@ApiOperation(value = "修改角色菜单") @PostMapping(value = "/role/update/menu") @RequiresPermissions("sys.permisson.roleMenu.update") public Object roleMenu(ModelMap modelMap, @RequestBody List<SysRoleMenu> list) { Long roleId = null; Long userId = WebUtil.getCurrentUser(); for (SysRoleMenu sysRoleMenu : list) { if (sysRoleMenu.getRoleId() != null) { if (roleId != null && roleId != sysRoleMenu.getRoleId()) { throw new IllegalParameterException("参数错误."); } roleId = sysRoleMenu.getRoleId(); } sysRoleMenu.setCreateBy(userId); sysRoleMenu.setUpdateBy(userId); } sysAuthorizeService.updateRoleMenu(list); return setSuccessModelMap(modelMap); }
@ApiOperation(value = "修改用户头像") @PostMapping(value = "/update/avatar") public Object updateAvatar(HttpServletRequest request, ModelMap modelMap) { List<String> fileNames = UploadUtil.uploadImage(request); if (fileNames.size() > 0) { SysUser param = new SysUser(); param.setId(WebUtil.getCurrentUser()); String filePath = UploadUtil.getUploadDir(request) + fileNames.get(0); // String avatar = UploadUtil.remove2DFS("sysUser", "user" + // sysUser.getId(), filePath).getRemotePath(); // String avatar = UploadUtil.remove2Sftp(filePath, "user" + // sysUser.getId()); param.setAvatar(filePath); return super.update(modelMap, param); } else { setModelMap(modelMap, HttpCode.BAD_REQUEST); modelMap.put("msg", "请选择要上传的文件!"); return modelMap; } }
@ApiOperation(value = "用户注册") @PostMapping("app/regin") public Object regin(ModelMap modelMap, @RequestBody SysUser sysUser) { Assert.notNull(sysUser.getAccount(), "ACCOUNT"); Assert.notNull(sysUser.getPassword(), "PASSWORD"); sysUser.setPassword(SecurityUtil.encryptPassword(sysUser.getPassword())); provider.execute(new Parameter("sysUserService", "update").setModel(sysUser)); try { String token = SecurityUtil.encryptPassword(sysUser.getAccount() + DateUtil.getDateTime("yyyyMMddHHmmss")); TokenUtil.setTokenInfo(token, sysUser.getAccount()); modelMap.put("token", token); } catch (Exception e) { logger.error("", e); } throw new IllegalArgumentException(Resources.getMessage("LOGIN_FAIL")); }
@RequestMapping("/file") @ApiOperation(value = "上传文件") public Object uploadFile2Ftp(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) { List<String> fileNames = UploadUtil.uploadFile(request); if (fileNames.size() > 0) { List<String> resultList = InstanceUtil.newArrayList(); for (int i = 0; i < fileNames.size(); i++) { String filePath = UploadUtil.getUploadDir(request) + fileNames.get(i); String objectId = UUID.randomUUID().toString().replaceAll("-", ""); String file = UploadUtil.remove2DFS("file", objectId, filePath).getRemotePath(); resultList.add(file); } modelMap.put("fileNames", resultList); return setSuccessModelMap(modelMap); } else { setModelMap(modelMap, HttpCode.BAD_REQUEST); modelMap.put("msg", "请选择要上传的文件!"); return modelMap; } }
@RequestMapping("/imageData") @ApiOperation(value = "上传图片") public Object uploadImageData2Ftp(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) { List<String> fileNames = UploadUtil.uploadImageData(request); if (fileNames.size() > 0) { List<String> resultList = InstanceUtil.newArrayList(); for (int i = 0; i < fileNames.size(); i++) { String filePath = UploadUtil.getUploadDir(request) + fileNames.get(i); String objectId = UUID.randomUUID().toString().replaceAll("-", ""); String file = UploadUtil.remove2DFS("image", objectId, filePath).getRemotePath(); resultList.add(file); } modelMap.put("fileNames", resultList); return setSuccessModelMap(modelMap); } else { setModelMap(modelMap, HttpCode.BAD_REQUEST); modelMap.put("msg", "请选择要上传的文件!"); return modelMap; } }
@ApiOperation(value = "修改专题") @RequiresPermissions("cms:topic:update") @RequestMapping(value = "/update/{id}", method = RequestMethod.GET) public String update(@PathVariable("id") int id, ModelMap modelMap) { CmsTopic topic = cmsTopicService.selectByPrimaryKey(id); modelMap.put("topic", topic); return "/manage/topic/update.jsp"; }
@ApiOperation(value = "修改权限") @RequiresPermissions("upms:permission:update") @RequestMapping(value = "/update/{id}", method = RequestMethod.GET) public String update(@PathVariable("id") int id, ModelMap modelMap) { UpmsSystemExample upmsSystemExample = new UpmsSystemExample(); upmsSystemExample.createCriteria() .andStatusEqualTo((byte) 1); List<UpmsSystem> upmsSystems = upmsSystemService.selectByExample(upmsSystemExample); UpmsPermission permission = upmsPermissionService.selectByPrimaryKey(id); modelMap.put("permission", permission); modelMap.put("upmsSystems", upmsSystems); return "/manage/permission/update.jsp"; }
/** * This is the way that ajax calls will need to work. * '@ResponseBody' is pretty cool maybe? * * @param modelMap * @return */ @RequestMapping("/test") @ResponseBody public String test(ModelMap modelMap, HttpServletRequest request) { promptPassword(request); return "[0, 1, 2, 3]"; }
@RequestMapping("/login") public String doLogin(ModelMap map, HttpSession httpSession, String account, String password) { System.out.println("1--login--账户是:\t" + account); System.out.println("1--login--密码是:\t" + password); httpSession.setAttribute("account", account); httpSession.setAttribute("password", password); map.addAttribute("account", account); return "thymeleaf/index"; }
/** * 进入角色资源权限页面 * @param id * @param map * @return */ @RequestMapping(value = "menu",method = RequestMethod.GET) public String toMenu(int id,ModelMap map){ map.put("menus",new Gson().toJson(roleMenuService.selectByRoleId(id))); map.put("roleid",id); return "role/menu"; }
@PostMapping("/close") @ApiOperation(value = "暂停任务") @RequiresPermissions("sys.task.scheduled.close") public Object close(@RequestBody TaskScheduled scheduled, ModelMap modelMap) { Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP"); Assert.notNull(scheduled.getTaskName(), "TASKNAME"); Parameter parameter = new Parameter(getService(), "closeTask").setModel(scheduled); provider.execute(parameter); return setSuccessModelMap(modelMap); }
@RequestMapping(value = "/") public ModelAndView IndexView( ModelMap model ) { List<UndergroundLine> undergroundLinesList = undergroundLinesRepository.findAll(); List<UndergroundStation> undergroundStationsList = undergroundStationsRepository.findAll(); ModelAndView modelAndView = new ModelAndView("index"); modelAndView.addObject("undergroundLinesList", undergroundLinesList); modelAndView.addObject("undergroundStationsList", undergroundStationsList); return modelAndView; }
@ApiOperation(value = "获取角色操作权限") @PutMapping(value = "role/read/permission") @RequiresPermissions("sys.permisson.role.read") public Object queryRolePermissions(ModelMap modelMap, @RequestBody SysRoleMenu record) { Parameter parameter = new Parameter(getService(), "queryRolePermissions").setModel(record); logger.info("{} execute queryRolePermissions start...", parameter.getNo()); List<?> menuIds = provider.execute(parameter).getList(); logger.info("{} execute queryRolePermissions end.", parameter.getNo()); return setSuccessModelMap(modelMap, menuIds); }
@ApiOperation(value = "修改单页") @RequiresPermissions("cms:page:update") @RequestMapping(value = "/update/{id}", method = RequestMethod.GET) public String update(@PathVariable("id") int id, ModelMap modelMap) { CmsPage page = cmsPageService.selectByPrimaryKey(id); modelMap.put("page", page); return "/manage/page/update.jsp"; }
@RequestMapping("/text1") public void getText1(HttpServletRequest request, HttpServletResponse response, ModelMap model) { try { response.setContentType("text/html;charset=UTF-8"); response.getWriter().write("hello"); } catch (IOException e) { logger.error("getText1 error:", e); } }
@ApiOperation(value = "用户登出") @PostMapping("app/logout") public Object logout(HttpServletRequest request, ModelMap modelMap) { String token = request.getHeader("token"); if (StringUtils.isNotBlank(token)) { TokenUtil.delToken(token); } return setSuccessModelMap(modelMap); }
@RequestMapping(value = "/se_role_edit.do") public ModelAndView seRoleEditPageHandler(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws ServletException { Map<String, Object> info = new HashMap<>(); Map<String, Object> param = new HashMap<>(); String rolecode = request.getParameter("rolecode"); if (!Utils.strIsNull(rolecode)) { param.put("rolecode", rolecode); SeRole seRole = seRoleService.get(param); info.put("seRole", seRole); } return new ModelAndView("system/role/se_role_edit", "info", info); }
@RequestMapping(value = "/view", method = RequestMethod.GET) public String view(ModelMap model, @RequestParam(value = "id", required = true) Long id) { Bug bug = bugService.selectById(id); model.addAttribute("bug", bug); model.addAttribute("project", getProject(bug.getpId())); //获取评论 List<BugComment> comments = bugCommentService.findByBugId(id); model.addAttribute("comments", comments); return "bug/view"; }
@ApiOperation(value = "用户注册") @PostMapping("/regin") public Object regin(HttpServletRequest request, ModelMap modelMap, @RequestBody SysUser sysUser) { Assert.notNull(sysUser.getAccount(), "ACCOUNT"); Assert.notNull(sysUser.getPassword(), "PASSWORD"); sysUser.setPassword(SecurityUtil.encryptPassword(sysUser.getPassword())); provider.execute(new Parameter("sysUserService", "update").setModel(sysUser)); if (LoginHelper.login(request, sysUser.getAccount(), sysUser.getPassword())) { return setSuccessModelMap(modelMap); } throw new IllegalArgumentException(Resources.getMessage("LOGIN_FAIL")); }
@RequestMapping("/callback/qq") @ApiOperation(value = "QQ登录回调", httpMethod = "GET") public String qqCallback(HttpServletRequest request, ModelMap modelMap) { String host = request.getHeader("host"); try { String code = request.getParameter("code"); if (StringUtils.isNotBlank(code)) {// 如果不为空 // 获取token和openid Map<String, String> map = ThirdPartyLoginHelper.getQQTokenAndOpenid(code, host); String openId = map.get("openId"); if (StringUtils.isNotBlank(openId)) {// 如果openID存在 // 获取第三方用户信息存放到session中 ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getQQUserinfo(map.get("access_token"), openId); thirdUser.setProvider("QQ"); thirdPartyLogin(thirdUser); // 跳转到登录成功界面 modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success")); } else {// 如果未获取到OpenID modelMap.put("retUrl", "-1"); } } else {// 如果没有返回令牌,则直接返回到登录页面 modelMap.put("retUrl", "-1"); } } catch (Exception e) { modelMap.put("retUrl", "-1"); e.printStackTrace(); } return "/sns/redirect"; }
@RequestMapping("/showBookForm.htm") public ModelAndView showBookForm(ModelMap map) throws Exception { Book book = new Book(); map.addAttribute(book); return new ModelAndView("bookForm"); }
@RequestMapping(value = "/addStudent",method = RequestMethod.POST) public String addStudent(@ModelAttribute("SpringWeb")Student student, ModelMap model){ model.addAttribute("id",student.getId()); model.addAttribute("name",student.getName()); model.addAttribute("age",student.getAge()); return "result"; }
@PutMapping("/read/tasks") @ApiOperation(value = "任务列表") @RequiresPermissions("sys.task.scheduled.read") public Object list(ModelMap modelMap) { Parameter parameter = new Parameter(getService(), "getAllTaskDetail"); List<?> records = provider.execute(parameter).getList(); modelMap.put("recordsTotal", records.size()); modelMap.put("total", records.size()); modelMap.put("current", 1); modelMap.put("size", records.size()); return setSuccessModelMap(modelMap, records); }
@RequestMapping("") public String index(HttpSession session, ModelMap map, HttpServletRequest request){ // User user = (User) session.getAttribute("user"); System.out.println(request.getUserPrincipal().getName()); System.out.println(SecurityUtils.getSubject().getPrincipal()); User loginUser = userService.getLoginUser(); System.out.println(JSONObject.toJSONString(loginUser)); map.put("user",loginUser); return "home"; }
@ApiOperation(value = "修改组织") @RequiresPermissions("upms:organization:update") @RequestMapping(value = "/update/{id}", method = RequestMethod.GET) public String update(@PathVariable("id") int id, ModelMap modelMap) { UpmsOrganization organization = upmsOrganizationService.selectByPrimaryKey(id); modelMap.put("organization", organization); return "/manage/organization/update.jsp"; }
@RequestMapping("/callback/wx") @ApiOperation(value = "微信登录回调", httpMethod = "GET") public String wxCallback(HttpServletRequest request, ModelMap modelMap) { String host = request.getHeader("host"); try { String code = request.getParameter("code"); if (StringUtils.isNotBlank(code)) {// 如果不为空 // 获取token和openid Map<String, String> map = ThirdPartyLoginHelper.getWxTokenAndOpenid(code, host); String openId = map.get("openId"); if (StringUtils.isNotBlank(openId)) {// 如果openID存在 // 获取第三方用户信息存放到session中 ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getWxUserinfo(map.get("access_token"), openId); thirdUser.setProvider("WX"); thirdPartyLogin(thirdUser); // 跳转到登录成功界面 modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success")); } else {// 如果未获取到OpenID modelMap.put("retUrl", "-1"); } } else {// 如果没有返回令牌,则直接返回到登录页面 modelMap.put("retUrl", "-1"); } } catch (Exception e) { modelMap.put("retUrl", "-1"); e.printStackTrace(); } return "/sns/redirect"; }
@RequestMapping(value = "/user/repass", method = RequestMethod.POST) public String repass(RepassBean repassBean, ModelMap modelMap) { userService.updatePassword(repassBean); User user = userService.selectUserById(repassBean.getUid()); modelMap.put("user", user); modelMap.put("msg", "修改成功"); return "user/set"; }
@RequestMapping(value="/admin", method = RequestMethod.GET) public String handleAdmin(ModelMap model, Principal principal ) { System.out.println("***********LoginController handleAdmin Called***********"); String name = principal.getName(); model.addAttribute("username", name); model.addAttribute("message", "This is admin area"); return "admin"; }
@GetMapping("/article/new") public Article newArticle(ModelMap modelMap) { Article article = new Article(); modelMap.addAttribute("article", article); return article; }
@RequestMapping(value="/loginfailed", method = RequestMethod.GET) public String loginerror(ModelMap model) { System.out.println("***********LoginController loginerror() Called***********"); model.addAttribute("error", "true"); return "login"; }
/** * This method will provide the medium to add a new user. */ @RequestMapping(value = {"/newuser"}, method = RequestMethod.GET) public String newUser(ModelMap model) { AdmUser user = new AdmUser(); model.addAttribute("user", user); model.addAttribute("edit", false); model.addAttribute("loggedinuser", getPrincipal()); return "registration"; }
@PostMapping(value="/signup") public ExecutionStatus processSignup(ModelMap model, @RequestBody User reqUser) { User user = null; try { user = userService.doesUserExist(reqUser.getEmail()); } catch (UserNotFoundException e) { } if(user != null) { return new ExecutionStatus("USER_ACCOUNT_EXISTS", "User account with same email address exists. Please try again!"); } user = new User(); user.setEmail(reqUser.getEmail()); user.setPassword(reqUser.getPassword()); user.setFirstName(reqUser.getFirstname()); user.setLastname(reqUser.getLastname()); user.setContactNumber(reqUser.getContactNumber()); user.setAlternateContactNumber(reqUser.getAlternateContactNumber()); user.setCityCode(reqUser.getCityCode()); user.setStateCode(reqUser.getStateCode()); user.setCountryCode(reqUser.getCountryCode()); user.setAge(reqUser.getAge()); user.setGender(reqUser.getGender()); user.setRole(reqUser.getRole()); User persistedUser = userService.save(user); // // Add entry in doctor table if user is a doctor // docService.addDoctor(user); return new ExecutionStatus("USER_ACCOUNT_CREATED", "User account successfully created"); }
@ApiOperation(value = "修改菜单") @RequiresPermissions("cms:menu:update") @RequestMapping(value = "/update/{id}", method = RequestMethod.GET) public String update(@PathVariable("id") int id, ModelMap modelMap) { CmsMenu menu = cmsMenuService.selectByPrimaryKey(id); modelMap.put("menu", menu); return "/manage/menu/update.jsp"; }
public Object get(ModelMap modelMap, BaseModel param) { Parameter parameter = new Parameter(getService(), "queryById").setId(param.getId()); logger.info("{} execute queryById start...", parameter.getNo()); BaseModel result = provider.execute(parameter).getModel(); logger.info("{} execute queryById end.", parameter.getNo()); return setSuccessModelMap(modelMap, result); }
/** * 处理 "/users/{id}" 的 PUT 请求,用来更新 User 信息 * */ @RequestMapping(value = "/update", method = RequestMethod.POST) public String putUser(ModelMap map, @ModelAttribute @Valid User user, BindingResult bindingResult) { if (bindingResult.hasErrors()) { map.addAttribute("action", "update"); return "userForm"; } userService.update(user); return "redirect:/users/"; }
@RequestMapping("/accountInfo") public String accountInfo(String name, ModelMap modelMap) { Cache cache = cacheManager.getCache(TEST_REDIS); putCache(cache,"test_aa","111111"); List<AccountInfo> accountInfoList = accountInfoServerImpl.selectByName(name); modelMap.addAttribute("accountList", accountInfoList); System.out.println(getFromCache(cache,"test_aa")); return "userinfo/accountInfo"; }