主要功能模块:系统、用户、角色、考勤、流程、公告、邮件、任务、日程、计划、文件、笔记、通讯录、讨论区等多个模块管理 使用Maven进行项目管理,基于springboot框架开发的项目,mysql底层数据库,前端采用freemarker模板引擎,Bootstrap作为前端UI框架,集成了jpa、mybatis等框架。 显示菜单管理和 *** 作界面代码:
@Controller @RequestMapping("/") public class MenuSysController { Logger log = LoggerFactory.getLogger(getClass()); @Autowired private IndexDao iDao; @Autowired private MenuSysService menuService; @Autowired private UserDao uDao; @Autowired private RoleDao rdao; @Autowired private RolepowerlistDao rldao; @Autowired private RoleService roleService; @RequestMapping("testsysmenu") public String testsysmenu(HttpServletRequest req) { menuService.findAllMenuSys(req); return "systemcontrol/menumanage"; } @RequestMapping("menutable") public String menuTable(HttpServletRequest req){ if(!StringUtils.isEmpty(req.getParameter("name"))){ req.setAttribute("oneMenuAll", iDao.findByMenuNameLike("%"+req.getParameter("name")+"%")); } else{ menuService.findAllMenuSys(req); } return "systemcontrol/menutable"; } @RequestMapping("changeSortId") public String changeSortId(HttpServletRequest req,@SessionAttribute("userId")Long userId) { User user=uDao.findOne(userId); Long parentId = Long.parseLong(req.getParameter("parentid")); Long menuId = Long.parseLong(req.getParameter("menuid")); Integer sortId = Integer.parseInt(req.getParameter("sortid")); Integer arithNum = Integer.parseInt(req.getParameter("num")); log.info("parentId:{}", parentId); log.info("menuId:{}", menuId); log.info("sortId:{}", sortId); log.info("arithNum:{}", arithNum); if (arithNum == 1) { int a1 = menuService.changeSortId(sortId, arithNum, parentId); int a2 = menuService.changeSortId2(sortId, arithNum, menuId); log.info("a1:{}", a1); log.info("a2:{}", a2); } else { int a1 = menuService.changeSortId(sortId, arithNum, parentId); int a2 = menuService.changeSortId2(sortId, arithNum, menuId); log.info("a1:{}", a1); log.info("a2:{}", a2); } menuService.findMenuSys(req,user); return "redirect:/testsysmenu"; } @RequestMapping("menuedit") public String newpage(HttpServletRequest req) { if(!StringUtils.isEmpty(req.getAttribute("errormess"))){ req.setAttribute("errormess", req.getAttribute("errormess")); } if(!StringUtils.isEmpty(req.getAttribute("success"))){ req.setAttribute("success", req.getAttribute("success")); } List通讯录管理和 *** 作代码:parentList=iDao.findByParentIdOrderBySortId(0L); req.setAttribute("parentList", parentList); HttpSession session = req.getSession(); session.removeAttribute("getId"); if (!StringUtils.isEmpty(req.getParameter("id"))) { Long getId = Long.parseLong(req.getParameter("id")); SystemMenu menuObj = iDao.findOne(getId); if (!StringUtils.isEmpty(req.getParameter("add"))) { Long getAdd = menuObj.getMenuId(); String getName=menuObj.getMenuName(); req.setAttribute("getAdd", getAdd); req.setAttribute("getName", getName); log.info("getAdd:{}", getAdd); } else { session.setAttribute("getId", getId); log.info("getId:{}", getId); req.setAttribute("menuObj", menuObj); } } return "systemcontrol/menuedit"; } @RequestMapping("test111") public String testMess(HttpServletRequest req, @Valid SystemMenu menu, BindingResult br) { HttpSession session = req.getSession(); Long menuId = null; req.setAttribute("menuObj", menu); // 这里返回ResultVO对象,如果校验通过,ResultEnum.SUCCESS.getCode()返回的值为200;否则就是没有通过; ResultVO res = BindingResultVOUtil.hasErrors(br); // 校验失败 if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) { List
@Controller @RequestMapping("/") public class AddrController { @Autowired AddressDao addressDao; @Autowired AddressService addressService; @Autowired UserDao uDao; @Autowired AddreddUserService addressUserService; @Autowired AddressMapper am; @Autowired AddressUserDao auDao; @Autowired ProcessService proservice; @Autowired FileServices fileServices; @Autowired AttachService attachService; @Autowired AttachmentDao atDao; @Autowired private MailServices mservice; @Autowired private AttachmentDao AttDao; @RequestMapping("addrmanage") public String addrmanage(@SessionAttribute("userId") Long userId,Model model, @RequestParam(value="page",defaultValue="0") int page, @RequestParam(value="size",defaultValue="10") int size ) { User user=uDao.findOne(userId); Setcatalogs=auDao.findByUser(user); Pageable pa=new PageRequest(page, size,new Sort(Direction.ASC, "dept")); Page userspage=uDao.findAll(pa); List users=userspage.getContent(); List nothandles=auDao.findByUserAndShareuserNotNullAndHandle(user,false); model.addAttribute("count", nothandles.size()); model.addAttribute("catalogs", catalogs); model.addAttribute("users", users); model.addAttribute("page", userspage); model.addAttribute("url", "inaddresspaging"); return "address/addrmanage"; } @RequestMapping("changethistype") public @ResponseBody Boolean changeType(@RequestParam(value="did")Long did,@SessionAttribute("userId") Long userId,@RequestParam(value="catalog")String catalog){ System.out.println("did:"+did); System.out.println("catalog:"+catalog); User user=uDao.findOne(userId); Director d=addressDao.findOne(did); DirectorUser du=auDao.findByDirectorAndUser(d, user); du.setCatalogName(catalog); addressUserService.save(du); System.out.println("执行成功!"); return true; } @RequestMapping("changetypename") public String changeTypeName(@RequestParam(value="typename")String typename, @RequestParam(value="oldtypename")String oldtypename, @SessionAttribute("userId") Long userId ){ User user=uDao.findOne(userId); List dus=auDao.findByCatalogNameAndUser(oldtypename, user); for (DirectorUser directorUser : dus) { directorUser.setCatalogName(typename); } addressUserService.savaList(dus); return "redirect:/outaddresspaging"; } @RequestMapping("inmessshow") public String inMessShow(Model model,@RequestParam(value="userId")Long userId){ User user=uDao.findOne(userId); model.addAttribute("user", user); return "address/inmessshow"; } @RequestMapping("outmessshow") public String outMessShow(Model model,@RequestParam("director") Long director,@SessionAttribute("userId") Long userId){ Director d=addressDao.findOne(director); User user=uDao.findOne(userId); DirectorUser du=auDao.findByDirectorAndUser(d, user); if(Objects.isNull(d) || Objects.isNull(du)){ System.out.println("权限不匹配,不能 *** 作"); return "redirect:/notlimit"; } if(d.getAttachment()!=null){ model.addAttribute("imgpath", atDao.findOne(d.getAttachment()).getAttachmentPath()); }else{ model.addAttribute("imgpath", "/timg.jpg"); } model.addAttribute("d", d); return "address/outmessshow"; } @RequestMapping("addaddress") public String addAddress(HttpServletRequest req,@RequestParam(value="did",required=false) Long did,HttpSession session, @SessionAttribute("userId") Long userId, Model model){ User user=uDao.findOne(userId); Set calogs=auDao.findByUser(user); model.addAttribute("calogs", calogs); if(!StringUtils.isEmpty(did)){ Director director=addressDao.findOne(did); System.out.println(); if(Objects.isNull(director)|| !Objects.equals(director.getMyuser().getUserId(), userId)){ System.out.println("权限不匹配,不能 *** 作"); return "redirect:/notlimit"; } DirectorUser du=auDao.findByDirectorAndUser(director, user); model.addAttribute("director", director); model.addAttribute("du", du); session.setAttribute("did", did); } return "address/addressedit"; } @RequestMapping("savaaddress") public String savaAddress(@Valid Director director,DirectorUser directorUser,BindingResult br,@RequestParam("file")MultipartFile file,HttpSession session, Model model,@SessionAttribute("userId") Long userId,HttpServletRequest req) throws PinyinException, IllegalStateException, IOException{ User user=uDao.findOne(userId); ResultVO res = BindingResultVOUtil.hasErrors(br); if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) { System.out.println("输入信息有误!"); }else{ String pinyin=PinyinHelper.convertToPinyinString(director.getUserName(), "", PinyinFormat.WITHOUT_TONE); director.setPinyin(pinyin); director.setMyuser(user); if(!StringUtils.isEmpty(session.getAttribute("did"))){ Long did=Long.parseLong(session.getAttribute("did")+""); Director di=addressDao.findOne(did); director.setDirectorId(di.getDirectorId()); director.setAttachment(di.getAttachment()); DirectorUser dc=auDao.findByDirectorAndUser(director, user); directorUser.setDirectorUserId(dc.getDirectorUserId()); session.removeAttribute("did"); } //试一下 if(file.getSize()>0){ Attachment attaid=mservice.upload(file, user); attaid.setModel("aoa_bursement"); Attachment att=AttDao.save(attaid); director.setAttachment(att.getAttachmentId()); } directorUser.setHandle(true); directorUser.setDirector(director); directorUser.setUser(user); addressService.sava(director); addressUserService.save(directorUser); } return "redirect:/addrmanage"; } @RequestMapping("deletedirector") public String deleteDirector(@SessionAttribute("userId") Long userId,Model model,@RequestParam(value="did",required=false) Long did){ DirectorUser du=auDao.findOne(did); Director director=du.getDirector(); List dires=auDao.findByDirector(director); User user=uDao.findOne(userId); if(!Objects.equals(du.getUser().getUserId(), userId)){ System.out.println("权限不匹配,不能删除"); return "redirect:/notlimit"; } List dus=auDao.findByCatalogNameAndUser(du.getCatalogName(), user); if(dus.size()>1){ addressUserService.deleteObj(du); if(dires.size()==1){ addressService.deleteDirector(du.getDirector()); System.out.println("最后一个拥有的用户删掉了该联系人,即删掉该联系人的信息"); } }else{ du.setDirector(null); addressUserService.save(du); if(dires.size()==1){ addressService.deleteDirector(director); System.out.println("最后一个拥有的用户删掉了该联系人,即删掉该联系人的信息"); } } return "redirect:/outaddresspaging"; } @RequestMapping("deletetypename") public String deletetypename(@RequestParam(value="typename") String typename,@SessionAttribute("userId") Long userId){ User user=uDao.findOne(userId); List dus=auDao.findByCatalogNameAndUser(typename, user); for (DirectorUser directorUser : dus) { directorUser.setCatalogName(null); } addressUserService.savaList(dus); return "redirect:/outaddresspaging"; } @RequestMapping("addtypename") public String addTypename(@RequestParam(value="typename",required=false) String typename, @RequestParam(value="oldtypename",required=false) String oldtypename, @SessionAttribute("userId") Long userId,Model model){ System.out.println("进来这个了么?"); User user=uDao.findOne(userId); if(oldtypename!=null){ List dus=auDao.findByCatalogNameAndUser(oldtypename, user); for (DirectorUser directorUser : dus) { directorUser.setCatalogName(typename); } addressUserService.savaList(dus); }else{ DirectorUser dc=new DirectorUser(user, typename); addressUserService.save(dc); } Set catalogs=auDao.findByUser(user); System.out.println(catalogs); model.addAttribute("catalogs", catalogs); return "address/addtypename"; } @RequestMapping("sharemess") public String shareMess(@RequestParam(value="page",defaultValue="0")int page, @RequestParam(value="size",defaultValue="5")int size, @RequestParam(value="baseKey",required=false) String baseKey, @RequestParam(value="catalog",required=false)String catalog, @RequestParam(value="duid",required=false)Long duid, Model model,@SessionAttribute("userId") Long userId){ User user=uDao.findOne(userId); List orders=new ArrayList<>(); orders.add(new Order(Direction.ASC, "handle")); orders.add(new Order(Direction.DESC, "sharetime")); Sort sort=new Sort(orders); Pageable pa=new PageRequest(page, size, sort); Page duspage=auDao.findByShareuser(user, pa); if(!StringUtils.isEmpty(duid)){ DirectorUser du=auDao.findOne(duid); System.out.println(); du.setCatalogName(catalog); du.setHandle(true); addressUserService.save(du); } if(!StringUtils.isEmpty(baseKey)){ duspage=auDao.findbaseKey("%"+baseKey+"%",user,pa); model.addAttribute("sort", "&baseKey="+baseKey); }else{ duspage=auDao.findByUserAndShareuserNotNull(user, pa); } Set catalogs=auDao.findByUser(user); System.out.println(catalogs); model.addAttribute("catalogs", catalogs); List dus=duspage.getContent(); model.addAttribute("page", duspage); model.addAttribute("dus", dus); model.addAttribute("url", "sharemess"); return "address/sharemess"; } @RequestMapping("mesharemess") public String meShareMess(@RequestParam(value="page",defaultValue="0")int page, @RequestParam(value="size",defaultValue="5")int size, @RequestParam(value="baseKey",required=false) String baseKey, Model model,@SessionAttribute("userId") Long userId ){ User user=uDao.findOne(userId); Pageable pa=new PageRequest(page, size, new Sort(Direction.DESC, "sharetime")); Page duspage=auDao.findByShareuser(user, pa); if(!StringUtils.isEmpty(baseKey)){ duspage=auDao.findbaseKey("%"+baseKey+"%",user,pa); model.addAttribute("sort", "&baseKey="+baseKey); }else{ duspage=auDao.findByShareuser(user, pa); } List dus=duspage.getContent(); model.addAttribute("page", duspage); model.addAttribute("dus", dus); model.addAttribute("url", "mesharemess"); return "address/mesharemess"; } @RequestMapping("shareother") public String shareOther(@SessionAttribute("userId")Long userId,@RequestParam(value="directors[]") Long[] directors, Model model, @RequestParam(value="sharedirector") Long sharedirector){ User user=uDao.findOne(userId); Director director=addressDao.findOne(sharedirector); List users=new ArrayList<>(); List dus=new ArrayList<>(); for (int i = 0; i < directors.length; i++) { User shareuser=uDao.findOne(directors[i]); System.out.println("分享的用户:"+shareuser); DirectorUser du=auDao.findByDirectorAndUser(director, shareuser); if(Objects.isNull(du)){ System.out.println("没找到该对象、进行保存保存"); DirectorUser dir=new DirectorUser(); dir.setUser(shareuser); dir.setShareuser(user); dir.setDirector(director); dus.add(dir); }else{ System.out.println("该用户已存在该联系人,不用重复保存!"); users.add(shareuser); } } for (DirectorUser directorUser : dus) { System.out.println("中间表:"+directorUser); } for (User u : users) { System.out.println("已存有该联系人的用户:"+u); } addressUserService.savaList(dus); if(users.size()>0){ model.addAttribute("users", users); return "address/userhas"; } return "address/sharesuccess"; } @RequestMapping("modalshare") public String modalShare(@RequestParam(value="page",defaultValue="0") int page,Model model, @RequestParam(value="size",defaultValue="10") int size){ Pageable pa=new PageRequest(0, 10); Page userspage=uDao.findAll(pa); List users=userspage.getContent(); model.addAttribute("modalurl", "modalpaging"); model.addAttribute("modalpage", userspage); model.addAttribute("users", users); return "address/modalshare"; } @RequestMapping("modalpaging") public String modalPaging(@RequestParam(value="page",defaultValue="0") int page,Model model, @RequestParam(value="size",defaultValue="10") int size, @RequestParam(value="baseKey",required=false) String baseKey){ Pageable pa=new PageRequest(page, size); Page userspage=null; List users=null; if(!StringUtils.isEmpty(baseKey)){ System.out.println(baseKey); userspage=uDao.findUsers("%"+baseKey+"%", baseKey+"%", pa); model.addAttribute("baseKey", baseKey); model.addAttribute("sort", "&baseKey="+baseKey); }else{ userspage=uDao.findAll(pa); } users=userspage.getContent(); model.addAttribute("modalurl", "modalpaging"); model.addAttribute("modalpage", userspage); model.addAttribute("users", users); return "address/shareuser"; } @RequestMapping("outaddresspaging") public String outAddress(@RequestParam(value="pageNum",defaultValue="1") int page,Model model, @RequestParam(value="baseKey",required=false) String baseKey, @RequestParam(value="outtype",required=false) String outtype, @RequestParam(value="alph",defaultValue="ALL") String alph, @SessionAttribute("userId") Long userId ){ PageHelper.startPage(page, 10); List
通讯录管理控制器:
@Controller @RequestMapping("/") public class AddrController { @Autowired AddressDao addressDao; @Autowired AddressService addressService; @Autowired UserDao uDao; @Autowired AddreddUserService addressUserService; @Autowired AddressMapper am; @Autowired AddressUserDao auDao; @Autowired ProcessService proservice; @Autowired FileServices fileServices; @Autowired AttachService attachService; @Autowired AttachmentDao atDao; @Autowired private MailServices mservice; @Autowired private AttachmentDao AttDao; @RequestMapping("addrmanage") public String addrmanage(@SessionAttribute("userId") Long userId,Model model, @RequestParam(value="page",defaultValue="0") int page, @RequestParam(value="size",defaultValue="10") int size ) { User user=uDao.findOne(userId); Setcatalogs=auDao.findByUser(user); Pageable pa=new PageRequest(page, size,new Sort(Direction.ASC, "dept")); Page userspage=uDao.findAll(pa); List users=userspage.getContent(); List nothandles=auDao.findByUserAndShareuserNotNullAndHandle(user,false); model.addAttribute("count", nothandles.size()); model.addAttribute("catalogs", catalogs); model.addAttribute("users", users); model.addAttribute("page", userspage); model.addAttribute("url", "inaddresspaging"); return "address/addrmanage"; } @RequestMapping("changethistype") public @ResponseBody Boolean changeType(@RequestParam(value="did")Long did,@SessionAttribute("userId") Long userId,@RequestParam(value="catalog")String catalog){ System.out.println("did:"+did); System.out.println("catalog:"+catalog); User user=uDao.findOne(userId); Director d=addressDao.findOne(did); DirectorUser du=auDao.findByDirectorAndUser(d, user); du.setCatalogName(catalog); addressUserService.save(du); System.out.println("执行成功!"); return true; } @RequestMapping("changetypename") public String changeTypeName(@RequestParam(value="typename")String typename, @RequestParam(value="oldtypename")String oldtypename, @SessionAttribute("userId") Long userId ){ User user=uDao.findOne(userId); List dus=auDao.findByCatalogNameAndUser(oldtypename, user); for (DirectorUser directorUser : dus) { directorUser.setCatalogName(typename); } addressUserService.savaList(dus); return "redirect:/outaddresspaging"; } @RequestMapping("inmessshow") public String inMessShow(Model model,@RequestParam(value="userId")Long userId){ User user=uDao.findOne(userId); model.addAttribute("user", user); return "address/inmessshow"; } @RequestMapping("outmessshow") public String outMessShow(Model model,@RequestParam("director") Long director,@SessionAttribute("userId") Long userId){ Director d=addressDao.findOne(director); User user=uDao.findOne(userId); DirectorUser du=auDao.findByDirectorAndUser(d, user); if(Objects.isNull(d) || Objects.isNull(du)){ System.out.println("权限不匹配,不能 *** 作"); return "redirect:/notlimit"; } if(d.getAttachment()!=null){ model.addAttribute("imgpath", atDao.findOne(d.getAttachment()).getAttachmentPath()); }else{ model.addAttribute("imgpath", "/timg.jpg"); } model.addAttribute("d", d); return "address/outmessshow"; } @RequestMapping("addaddress") public String addAddress(HttpServletRequest req,@RequestParam(value="did",required=false) Long did,HttpSession session, @SessionAttribute("userId") Long userId, Model model){ User user=uDao.findOne(userId); Set calogs=auDao.findByUser(user); model.addAttribute("calogs", calogs); if(!StringUtils.isEmpty(did)){ Director director=addressDao.findOne(did); System.out.println(); if(Objects.isNull(director)|| !Objects.equals(director.getMyuser().getUserId(), userId)){ System.out.println("权限不匹配,不能 *** 作"); return "redirect:/notlimit"; } DirectorUser du=auDao.findByDirectorAndUser(director, user); model.addAttribute("director", director); model.addAttribute("du", du); session.setAttribute("did", did); } return "address/addressedit"; } @RequestMapping("savaaddress") public String savaAddress(@Valid Director director,DirectorUser directorUser,BindingResult br,@RequestParam("file")MultipartFile file,HttpSession session, Model model,@SessionAttribute("userId") Long userId,HttpServletRequest req) throws PinyinException, IllegalStateException, IOException{ User user=uDao.findOne(userId); ResultVO res = BindingResultVOUtil.hasErrors(br); if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) { System.out.println("输入信息有误!"); }else{ String pinyin=PinyinHelper.convertToPinyinString(director.getUserName(), "", PinyinFormat.WITHOUT_TONE); director.setPinyin(pinyin); director.setMyuser(user); if(!StringUtils.isEmpty(session.getAttribute("did"))){ Long did=Long.parseLong(session.getAttribute("did")+""); Director di=addressDao.findOne(did); director.setDirectorId(di.getDirectorId()); director.setAttachment(di.getAttachment()); DirectorUser dc=auDao.findByDirectorAndUser(director, user); directorUser.setDirectorUserId(dc.getDirectorUserId()); session.removeAttribute("did"); } //试一下 if(file.getSize()>0){ Attachment attaid=mservice.upload(file, user); attaid.setModel("aoa_bursement"); Attachment att=AttDao.save(attaid); director.setAttachment(att.getAttachmentId()); } directorUser.setHandle(true); directorUser.setDirector(director); directorUser.setUser(user); addressService.sava(director); addressUserService.save(directorUser); } return "redirect:/addrmanage"; } @RequestMapping("deletedirector") public String deleteDirector(@SessionAttribute("userId") Long userId,Model model,@RequestParam(value="did",required=false) Long did){ DirectorUser du=auDao.findOne(did); Director director=du.getDirector(); List dires=auDao.findByDirector(director); User user=uDao.findOne(userId); if(!Objects.equals(du.getUser().getUserId(), userId)){ System.out.println("权限不匹配,不能删除"); return "redirect:/notlimit"; } List dus=auDao.findByCatalogNameAndUser(du.getCatalogName(), user); if(dus.size()>1){ addressUserService.deleteObj(du); if(dires.size()==1){ addressService.deleteDirector(du.getDirector()); System.out.println("最后一个拥有的用户删掉了该联系人,即删掉该联系人的信息"); } }else{ du.setDirector(null); addressUserService.save(du); if(dires.size()==1){ addressService.deleteDirector(director); System.out.println("最后一个拥有的用户删掉了该联系人,即删掉该联系人的信息"); } } return "redirect:/outaddresspaging"; } @RequestMapping("deletetypename") public String deletetypename(@RequestParam(value="typename") String typename,@SessionAttribute("userId") Long userId){ User user=uDao.findOne(userId); List dus=auDao.findByCatalogNameAndUser(typename, user); for (DirectorUser directorUser : dus) { directorUser.setCatalogName(null); } addressUserService.savaList(dus); return "redirect:/outaddresspaging"; } @RequestMapping("addtypename") public String addTypename(@RequestParam(value="typename",required=false) String typename, @RequestParam(value="oldtypename",required=false) String oldtypename, @SessionAttribute("userId") Long userId,Model model){ System.out.println("进来这个了么?"); User user=uDao.findOne(userId); if(oldtypename!=null){ List dus=auDao.findByCatalogNameAndUser(oldtypename, user); for (DirectorUser directorUser : dus) { directorUser.setCatalogName(typename); } addressUserService.savaList(dus); }else{ DirectorUser dc=new DirectorUser(user, typename); addressUserService.save(dc); } Set catalogs=auDao.findByUser(user); System.out.println(catalogs); model.addAttribute("catalogs", catalogs); return "address/addtypename"; } @RequestMapping("sharemess") public String shareMess(@RequestParam(value="page",defaultValue="0")int page, @RequestParam(value="size",defaultValue="5")int size, @RequestParam(value="baseKey",required=false) String baseKey, @RequestParam(value="catalog",required=false)String catalog, @RequestParam(value="duid",required=false)Long duid, Model model,@SessionAttribute("userId") Long userId){ User user=uDao.findOne(userId); List orders=new ArrayList<>(); orders.add(new Order(Direction.ASC, "handle")); orders.add(new Order(Direction.DESC, "sharetime")); Sort sort=new Sort(orders); Pageable pa=new PageRequest(page, size, sort); Page duspage=auDao.findByShareuser(user, pa); if(!StringUtils.isEmpty(duid)){ DirectorUser du=auDao.findOne(duid); System.out.println(); du.setCatalogName(catalog); du.setHandle(true); addressUserService.save(du); } if(!StringUtils.isEmpty(baseKey)){ duspage=auDao.findbaseKey("%"+baseKey+"%",user,pa); model.addAttribute("sort", "&baseKey="+baseKey); }else{ duspage=auDao.findByUserAndShareuserNotNull(user, pa); } Set catalogs=auDao.findByUser(user); System.out.println(catalogs); model.addAttribute("catalogs", catalogs); List dus=duspage.getContent(); model.addAttribute("page", duspage); model.addAttribute("dus", dus); model.addAttribute("url", "sharemess"); return "address/sharemess"; } @RequestMapping("mesharemess") public String meShareMess(@RequestParam(value="page",defaultValue="0")int page, @RequestParam(value="size",defaultValue="5")int size, @RequestParam(value="baseKey",required=false) String baseKey, Model model,@SessionAttribute("userId") Long userId ){ User user=uDao.findOne(userId); Pageable pa=new PageRequest(page, size, new Sort(Direction.DESC, "sharetime")); Page duspage=auDao.findByShareuser(user, pa); if(!StringUtils.isEmpty(baseKey)){ duspage=auDao.findbaseKey("%"+baseKey+"%",user,pa); model.addAttribute("sort", "&baseKey="+baseKey); }else{ duspage=auDao.findByShareuser(user, pa); } List dus=duspage.getContent(); model.addAttribute("page", duspage); model.addAttribute("dus", dus); model.addAttribute("url", "mesharemess"); return "address/mesharemess"; } @RequestMapping("shareother") public String shareOther(@SessionAttribute("userId")Long userId,@RequestParam(value="directors[]") Long[] directors, Model model, @RequestParam(value="sharedirector") Long sharedirector){ User user=uDao.findOne(userId); Director director=addressDao.findOne(sharedirector); List users=new ArrayList<>(); List dus=new ArrayList<>(); for (int i = 0; i < directors.length; i++) { User shareuser=uDao.findOne(directors[i]); System.out.println("分享的用户:"+shareuser); DirectorUser du=auDao.findByDirectorAndUser(director, shareuser); if(Objects.isNull(du)){ System.out.println("没找到该对象、进行保存保存"); DirectorUser dir=new DirectorUser(); dir.setUser(shareuser); dir.setShareuser(user); dir.setDirector(director); dus.add(dir); }else{ System.out.println("该用户已存在该联系人,不用重复保存!"); users.add(shareuser); } } for (DirectorUser directorUser : dus) { System.out.println("中间表:"+directorUser); } for (User u : users) { System.out.println("已存有该联系人的用户:"+u); } addressUserService.savaList(dus); if(users.size()>0){ model.addAttribute("users", users); return "address/userhas"; } return "address/sharesuccess"; } @RequestMapping("modalshare") public String modalShare(@RequestParam(value="page",defaultValue="0") int page,Model model, @RequestParam(value="size",defaultValue="10") int size){ Pageable pa=new PageRequest(0, 10); Page userspage=uDao.findAll(pa); List users=userspage.getContent(); model.addAttribute("modalurl", "modalpaging"); model.addAttribute("modalpage", userspage); model.addAttribute("users", users); return "address/modalshare"; } @RequestMapping("modalpaging") public String modalPaging(@RequestParam(value="page",defaultValue="0") int page,Model model, @RequestParam(value="size",defaultValue="10") int size, @RequestParam(value="baseKey",required=false) String baseKey){ Pageable pa=new PageRequest(page, size); Page userspage=null; List users=null; if(!StringUtils.isEmpty(baseKey)){ System.out.println(baseKey); userspage=uDao.findUsers("%"+baseKey+"%", baseKey+"%", pa); model.addAttribute("baseKey", baseKey); model.addAttribute("sort", "&baseKey="+baseKey); }else{ userspage=uDao.findAll(pa); } users=userspage.getContent(); model.addAttribute("modalurl", "modalpaging"); model.addAttribute("modalpage", userspage); model.addAttribute("users", users); return "address/shareuser"; } @RequestMapping("outaddresspaging") public String outAddress(@RequestParam(value="pageNum",defaultValue="1") int page,Model model, @RequestParam(value="baseKey",required=false) String baseKey, @RequestParam(value="outtype",required=false) String outtype, @RequestParam(value="alph",defaultValue="ALL") String alph, @SessionAttribute("userId") Long userId ){ PageHelper.startPage(page, 10); List > directors=am.allDirector(userId, alph, outtype, baseKey); List > adds=addressService.fengzhaung(directors); PageInfo > pageinfo=new PageInfo<>(directors); if(!StringUtils.isEmpty(outtype)){ model.addAttribute("outtype", outtype); } Pageable pa=new PageRequest(0, 10); Page userspage=uDao.findAll(pa); List users=userspage.getContent(); model.addAttribute("modalurl", "modalpaging"); model.addAttribute("modalpage", userspage); model.addAttribute("users", users); model.addAttribute("userId", userId); model.addAttribute("baseKey", baseKey); model.addAttribute("directors", adds); model.addAttribute("page", pageinfo); model.addAttribute("url", "outaddresspaging"); return "address/outaddrss"; } @RequestMapping("inaddresspaging") public String inAddress(@RequestParam(value="page",defaultValue="0") int page,Model model, @RequestParam(value="size",defaultValue="10") int size, @RequestParam(value="baseKey",required=false) String baseKey, @RequestParam(value="alph",defaultValue="ALL") String alph ){ Page userspage=null; Pageable pa=new PageRequest(page, size); if(StringUtils.isEmpty(baseKey)){ if("ALL".equals(alph)){ userspage=uDao.findAll(pa); }else{ userspage=uDao.findByPinyinLike(alph+"%",pa); } }else{ if("ALL".equals(alph)){ userspage=uDao.findUsers("%"+baseKey+"%",baseKey+"%", pa); }else{ userspage=uDao.findSelectUsers("%"+baseKey+"%", alph+"%",pa); } } if(!StringUtils.isEmpty(baseKey)){ model.addAttribute("baseKey", baseKey); model.addAttribute("sort", "&alph="+alph+"&baseKey="+baseKey); }else{ model.addAttribute("sort", "&alph="+alph); } List users=userspage.getContent(); model.addAttribute("users", users); model.addAttribute("page", userspage); model.addAttribute("url", "inaddresspaging"); return "address/inaddrss"; } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)