<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
環境設定:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支援)
專案技術:
JSP + Servlert + html+ css + JavaScript + JQuery + Ajax 等等;
/** * 個人中心Controller */ @Controller public class UserInforController { @Autowired private UserInforServiceImpl userInforService = null; /** * 修改密碼操作 * @param oldPassword * @param newPassword * @param rePassword * @param httpSession * @return */ @RequestMapping("changePassword.do") @ResponseBody public Map<String, String> changePassword(String oldPassword, String newPassword, String rePassword, HttpSession httpSession){ HashMap<String, String> map = new HashMap<String, String>(); if (newPassword.equals(rePassword)){ SystemManager admin = (SystemManager) httpSession.getAttribute("admin"); String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword); if (encodeByMD5.equals(admin.getSmPassword())){ String newPasswords = MD5Utils.encodeByMD5(newPassword); admin.setSmPassword(newPasswords); userInforService.updateSystemManagePassword(admin.getSmId(),admin); map.put("type","success"); map.put("msg","密碼修改成功"); return map; }else{ map.put("type","error"); map.put("msg","原密碼錯誤"); return map; } }else{ map.put("type","error"); map.put("msg","兩次密碼不一致"); return map; } } /** * 員工修改個人密碼 * @param oldPassword * @param newPassword * @param rePassword * @param httpSession * @return */ @RequestMapping("changeEmployeePassword.do") @ResponseBody public Map<String, String> changeEmployeePassword(String oldPassword, String newPassword, String rePassword, HttpSession httpSession){ HashMap<String, String> map = new HashMap<String, String>(); if (newPassword.equals(rePassword)){ Integer eid = (Integer) httpSession.getAttribute("employeeId"); try { userInforService.updateEmployeePassword(eid, oldPassword, newPassword); map.put("type","success"); map.put("msg","密碼修改成功"); return map; } catch (CustomException e) { map.put("type","error"); map.put("msg","原密碼錯誤"); return map; } }else{ map.put("type","error"); map.put("msg","兩次密碼不一致"); return map; } } /** * 檢視個人資訊 * @param httpSession * @return */ @RequestMapping("inforEmployee.do") public @ResponseBody EmployeeCustomVo getInforEmployee(HttpSession httpSession){ Integer id = (Integer) httpSession.getAttribute("employeeId"); EmployeeCustomVo employeeCustomVo = userInforService.getInforEmployee(id); return employeeCustomVo; } /** * 修改個人資訊 * @param httpSession * @param employee * @return */ @ResponseBody @RequestMapping("updateInforEmployee.do") public Message updateInforEmployee(HttpSession httpSession, Employee employee){ Integer id = (Integer) httpSession.getAttribute("employeeId"); employee.seteId(id); if(userInforService.updateEmploueeById(id,employee)<=0) { return Message.error("修改資訊失敗"); } return Message.success(); } /** * 個人工資資訊 * @param pageNum * @param limit * @param year * @param httpSession * @return * @throws Exception */ @RequestMapping("employeeSalaryList.do") @ResponseBody public EmployeeSalaryVO findSelective( @RequestParam(value="page", defaultValue="1")int pageNum, @RequestParam(value="limit", defaultValue="10") int limit, @RequestParam(value="year", defaultValue="1") String year, HttpSession httpSession) throws Exception { Integer eId = (Integer) httpSession.getAttribute("employeeId"); //pageNum:起始頁面 pageSize:每頁的大小 PageHelper.startPage(pageNum,limit); //查詢條件,一定要緊跟在startPage後 List<Salary> salaryList = userInforService.getEmployeeSalaryList(eId, year); PageInfo pageResult = new PageInfo(salaryList); //設定前臺需要的資料 EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO(); employeeSalaryVO.setCode(0); employeeSalaryVO.setMsg(""); employeeSalaryVO.setCount((int) pageResult.getTotal()); employeeSalaryVO.setData(pageResult.getList()); return employeeSalaryVO; } }
/** * @Author: admin * @Description: 管理員和員工登陸控制 **/ @Controller public class LoginController { @Autowired private LoginServiceImpl loginService = null; /** * @Author: admin * @Description: 驗證碼變更 * @Date: 14:33 2021/10/5 * @Param: [request, response] * @Return: void **/ @RequestMapping(value = "/changeCode.do") @ResponseBody public void getIdentifyingCode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 驗證碼儲存在session的identifyingCode,屬性中 CaptchaUtil.outputCaptcha(request, response); } // 獲取員工登陸介面 @RequestMapping("/") public String getLoginPage(){ return "employee/login.html"; } // 獲取管理員登陸介面 @RequestMapping("/admin.do") public String getAdminLoginPage(HttpServletRequest request){ String realPath = request.getServletContext().getRealPath("/"); request.getSession().setAttribute("realPath", realPath); return "admin/adminLogin.html"; } /** * 員工登入操作 * @param model * @param httpSession * @param username * @param password * @param identifyingcode * @return */ @RequestMapping(value = "/employeeLogin.do") @ResponseBody public Message employeeLogin(HttpSession httpSession, String username, String password, String identifyingcode) { if(StringUtils.isEmpty(username)) { return Message.error("請填寫工號"); } if(StringUtils.isEmpty(password)) { return Message.error("請填寫密碼"); } if(StringUtils.isEmpty(identifyingcode)) { return Message.error("請填寫驗證碼"); } String code = (String) httpSession.getAttribute("identifyingCode"); if(!identifyingcode.equalsIgnoreCase(code)){ return Message.error("驗證碼錯誤"); } Employee employee = loginService.findEmployeeByIdAndPassword(username, password); if(employee==null) { return Message.error("工號或密碼錯誤"); } httpSession.setAttribute("employeeId",employee.geteId()); return Message.success("員工登入成功"); } @RequestMapping(value = "/loginSuccess.do") public String loginSucceses(Model model) throws Exception { return "employee/index.html"; } /** * 管理員登入操作 * @param model * @param httpSession * @param username * @param password * @param identifyingcode * @return */ @RequestMapping(value = "/adminLogin.do") @ResponseBody public Message adminLogin(HttpSession httpSession, String username, String password, String identifyingcode) { if(StringUtils.isEmpty(username)) { return Message.error("請填寫賬號"); } if(StringUtils.isEmpty(password)) { return Message.error("請填寫密碼"); } if(StringUtils.isEmpty(identifyingcode)) { return Message.error("請填寫驗證碼"); } String code = (String) httpSession.getAttribute("identifyingCode"); if(identifyingcode.equalsIgnoreCase(code)){ SystemManager manager = loginService.findSystemManagerByIdAndPassword(username, password); if(manager==null) { return Message.error("賬號或密碼錯誤"); } // 儲存到session httpSession.setAttribute("admin",manager); return Message.success("登入成功"); }else { return Message.error("驗證碼錯誤"); } } @RequestMapping(value = "/getAdminAccount.do") @ResponseBody public String getAdminAccount(HttpSession httpSession){ SystemManager systemManager = (SystemManager) httpSession.getAttribute("admin"); // SystemManager manager = loginService.findSystemManagerById(id); return systemManager.getSmAccount(); } @RequestMapping(value = "/getEmployeeAccount.do") @ResponseBody public Map<String,String> getEmployeeAccount(HttpSession httpSession){ Integer id = (Integer) httpSession.getAttribute("employeeId"); Employee employee = loginService.findEmployeeById(id); HashMap<String, String> map = new HashMap<String, String>(); map.put("account",employee.geteAccount()); map.put("name",employee.geteName()); return map; } @RequestMapping(value = "/logout.do") public String logout(HttpSession httpSession){ httpSession.removeAttribute("employeeId"); return "redirect:/"; } @RequestMapping(value = "/logoutAdmin.do") public String logoutAdmin(HttpSession httpSession){ httpSession.removeAttribute("admin"); return "redirect:/admin.do"; } }
/** * 使用者管理操作 */ @Controller @RequestMapping("/user") public class UserController { @Autowired private UserService userService; /** * 使用者新增頁面 * @return */ @GetMapping("/add") public String create() { return "user/add"; } /** * 使用者新增操作 * @param user * @return */ @PostMapping("/add") @ResponseBody public Map<String, Object> add(@RequestBody User user) { if(StringUtils.isEmpty(user.getUserName())){ return MapControl.getInstance().error("請填寫使用者名稱").getMap(); } if(StringUtils.isEmpty(user.getName())){ return MapControl.getInstance().error("請填寫名稱").getMap(); } if(StringUtils.isEmpty(user.getUserPwd())){ return MapControl.getInstance().error("請填寫密碼").getMap(); } int result = userService.create(user); if (result <= 0) { return MapControl.getInstance().error().getMap(); } return MapControl.getInstance().success().getMap(); } /** * 根據id刪除 * @param id * @return */ @PostMapping("/delete/{id}") @ResponseBody public Map<String, Object> delete(@PathVariable("id") Integer id) { int result = userService.delete(id); if (result <= 0) { return MapControl.getInstance().error().getMap(); } return MapControl.getInstance().success().getMap(); } //批次刪除 @PostMapping("/delete") @ResponseBody public Map<String, Object> delete(String ids) { int result = userService.delete(ids); if (result <= 0) { return MapControl.getInstance().error().getMap(); } return MapControl.getInstance().success().getMap(); } /** * 編輯使用者資訊操作 * @param user * @return */ @PostMapping("/edit") @ResponseBody public Map<String, Object> edit(@RequestBody User user) { if(StringUtils.isEmpty(user.getUserName())){ return MapControl.getInstance().error("請填寫使用者名稱").getMap(); } if(StringUtils.isEmpty(user.getName())){ return MapControl.getInstance().error("請填寫名稱").getMap(); } if(StringUtils.isEmpty(user.getUserPwd())){ return MapControl.getInstance().error("請填寫密碼").getMap(); } int result = userService.update(user); if (result <= 0) { return MapControl.getInstance().error().getMap(); } return MapControl.getInstance().success().getMap(); } /** * 根據id查詢,跳轉修改頁面 * @param id * @param modelMap * @return */ @GetMapping("/edit/{id}") public String edit(@PathVariable("id") Integer id, ModelMap modelMap) { User user = userService.detail(id); modelMap.addAttribute("user", user); return "user/edit"; } //查詢所有 @PostMapping("/query") @ResponseBody public Map<String, Object> query(@RequestBody User user) { List<User> list = userService.query(user); Integer count = userService.count(user); return MapControl.getInstance().success().page(list, count).getMap(); } //跳轉列表頁面 @GetMapping("/list") public String list() { return "user/list"; } }
以上就是Java實戰之火車票預訂系統的實現的詳細內容,更多關於Java火車票預訂系統的資料請關注it145.com其它相關文章!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45