0


Java项目:YY酒店管理系统(java+JSP+Easyui+Echars+ssm+mysql)

源码获取:博客首页 "资源" 里下载!

基础环境

搭建环境

  • Tomcat 8.5
  • Java 1.8+
  • Mysql 5.7

涉及技术

Spring、Mybatis、MySql、easyui、h-ui、Jsp、echars

项目介绍

酒店管理系统的目标是为用户提供高效的服务,减少手工处理的繁琐与误差,及时准确地反映酒店工作情况、经营信息,从而提高酒店工作质量,获得更好的经济效益,实现客房管理的规范化、自动化。具体目标包括:

  • 高效的客房预订及订单处理。
  • 准确无误地记录客人每笔消费信息。
  • 实时、快速、准确提供客房动态。
  • 酒店收益的最终统计。
  • 系统运行稳定可靠、各项维护功能齐全、易于维护。
  • 简单、友好的操作界面

前台页面:
模块主要功能酒店信息展示客房信息展示、房间状态查询、房间预定、客房信息检索、会员用户预订会员注册登录、用户中心、订单查询、用户信息修改、用户密码修改
后台页面:
模块主要功能系统设置菜单管理、角色管理、修改密码用户管理用户列表管理系统日志日志列表酒店管理楼层管理、房型管理、房间管理、客户管理、预订管理、入住管理营业统计统计图标

客户管理后台控制器:

  1. /**
  2. * 客户管理后台控制器
  3. * @author yy
  4. *
  5. */
  6. @RequestMapping("/admin/account")
  7. @Controller
  8. public class AccountController {
  9. @Autowired
  10. private AccountService accountService;
  11. /**
  12. * 客户管理列表页面
  13. * @param model
  14. * @return
  15. */
  16. @RequestMapping(value="/list",method=RequestMethod.GET)
  17. public ModelAndView list(ModelAndView model){
  18. model.setViewName("account/list");
  19. return model;
  20. }
  21. /**
  22. * 客户信息添加操作
  23. * @param account
  24. * @return
  25. */
  26. @RequestMapping(value="/add",method=RequestMethod.POST)
  27. @ResponseBody
  28. public Map<String, String> add(Account account){
  29. Map<String, String> ret = new HashMap<String, String>();
  30. if(account == null){
  31. ret.put("type", "error");
  32. ret.put("msg", "请填写正确的客户信息!");
  33. return ret;
  34. }
  35. if(StringUtils.isEmpty(account.getName())){
  36. ret.put("type", "error");
  37. ret.put("msg", "客户名称不能为空!");
  38. return ret;
  39. }
  40. if(StringUtils.isEmpty(account.getPassword())){
  41. ret.put("type", "error");
  42. ret.put("msg", "客户密码不能为空!");
  43. return ret;
  44. }
  45. if(isExist(account.getName(), 0l)){
  46. ret.put("type", "error");
  47. ret.put("msg", "该用户名已经存在!");
  48. return ret;
  49. }
  50. if(accountService.add(account) <= 0){
  51. ret.put("type", "error");
  52. ret.put("msg", "添加失败,请联系管理员!");
  53. return ret;
  54. }
  55. ret.put("type", "success");
  56. ret.put("msg", "添加成功!");
  57. return ret;
  58. }
  59. /**
  60. * 客户信息编辑操作
  61. * @param account
  62. * @return
  63. */
  64. @RequestMapping(value="/edit",method=RequestMethod.POST)
  65. @ResponseBody
  66. public Map<String, String> edit(Account account){
  67. Map<String, String> ret = new HashMap<String, String>();
  68. if(account == null){
  69. ret.put("type", "error");
  70. ret.put("msg", "请填写正确的客户信息!");
  71. return ret;
  72. }
  73. if(StringUtils.isEmpty(account.getName())){
  74. ret.put("type", "error");
  75. ret.put("msg", "客户名称不能为空!");
  76. return ret;
  77. }
  78. if(StringUtils.isEmpty(account.getPassword())){
  79. ret.put("type", "error");
  80. ret.put("msg", "客户密码不能为空!");
  81. return ret;
  82. }
  83. if(isExist(account.getName(), account.getId())){
  84. ret.put("type", "error");
  85. ret.put("msg", "该用户名已经存在!");
  86. return ret;
  87. }
  88. if(accountService.edit(account) <= 0){
  89. ret.put("type", "error");
  90. ret.put("msg", "添加失败,请联系管理员!");
  91. return ret;
  92. }
  93. ret.put("type", "success");
  94. ret.put("msg", "修改成功!");
  95. return ret;
  96. }
  97. /**
  98. * 分页查询客户信息
  99. * @param name
  100. * @param page
  101. * @return
  102. */
  103. @RequestMapping(value="/list",method=RequestMethod.POST)
  104. @ResponseBody
  105. public Map<String,Object> list(
  106. @RequestParam(name="name",defaultValue="") String name,
  107. @RequestParam(name="realName",defaultValue="") String realName,
  108. @RequestParam(name="idCard",defaultValue="") String idCard,
  109. @RequestParam(name="mobile",defaultValue="") String mobile,
  110. @RequestParam(name="status",required=false) Integer status,
  111. Page page
  112. ){
  113. Map<String,Object> ret = new HashMap<String, Object>();
  114. Map<String,Object> queryMap = new HashMap<String, Object>();
  115. queryMap.put("name", name);
  116. queryMap.put("status", status);
  117. queryMap.put("realName", realName);
  118. queryMap.put("idCard", idCard);
  119. queryMap.put("mobile", mobile);
  120. queryMap.put("offset", page.getOffset());
  121. queryMap.put("pageSize", page.getRows());
  122. ret.put("rows", accountService.findList(queryMap));
  123. ret.put("total", accountService.getTotal(queryMap));
  124. return ret;
  125. }
  126. /**
  127. * 客户信息删除操作
  128. * @param id
  129. * @return
  130. */
  131. @RequestMapping(value="/delete",method=RequestMethod.POST)
  132. @ResponseBody
  133. public Map<String, String> delete(Long id){
  134. Map<String, String> ret = new HashMap<String, String>();
  135. if(id == null){
  136. ret.put("type", "error");
  137. ret.put("msg", "请选择要删除的信息!");
  138. return ret;
  139. }
  140. try {
  141. if(accountService.delete(id) <= 0){
  142. ret.put("type", "error");
  143. ret.put("msg", "删除失败,请联系管理员!");
  144. return ret;
  145. }
  146. } catch (Exception e) {
  147. // TODO: handle exception
  148. ret.put("type", "error");
  149. ret.put("msg", "该客户下存在订单信息,请先删除该客户下的所有订单信息!");
  150. return ret;
  151. }
  152. ret.put("type", "success");
  153. ret.put("msg", "删除成功!");
  154. return ret;
  155. }
  156. /**
  157. * 判断用户名是否存在
  158. * @param name
  159. * @param id
  160. * @return
  161. */
  162. private boolean isExist(String name,Long id){
  163. Account findByName = accountService.findByName(name);
  164. if(findByName == null)return false;
  165. if(findByName.getId().longValue() == id.longValue())return false;
  166. return true;
  167. }
  168. }

角色role控制器:

  1. /**
  2. * 角色role控制器
  3. * @author yy
  4. *
  5. */
  6. @RequestMapping("/admin/role")
  7. @Controller
  8. public class RoleController {
  9. @Autowired
  10. private RoleService roleService;
  11. @Autowired
  12. private AuthorityService authorityService;
  13. @Autowired
  14. private MenuService menuService;
  15. /**
  16. * 角色列表页面
  17. * @param model
  18. * @return
  19. */
  20. @RequestMapping(value="/list",method=RequestMethod.GET)
  21. public ModelAndView list(ModelAndView model){
  22. model.setViewName("/role/list");
  23. return model;
  24. }
  25. /**
  26. * 获取角色列表
  27. * @param page
  28. * @param name
  29. * @return
  30. */
  31. @RequestMapping(value="/list",method=RequestMethod.POST)
  32. @ResponseBody
  33. public Map<String, Object> getList(Page page,
  34. @RequestParam(name="name",required=false,defaultValue="") String name
  35. ){
  36. Map<String, Object> ret = new HashMap<String, Object>();
  37. Map<String, Object> queryMap = new HashMap<String, Object>();
  38. queryMap.put("name", name);
  39. queryMap.put("offset", page.getOffset());
  40. queryMap.put("pageSize", page.getRows());
  41. ret.put("rows", roleService.findList(queryMap));
  42. ret.put("total", roleService.getTotal(queryMap));
  43. return ret;
  44. }
  45. /**
  46. * 角色添加
  47. * @param role
  48. * @return
  49. */
  50. @RequestMapping(value="/add",method=RequestMethod.POST)
  51. @ResponseBody
  52. public Map<String, String> add(Role role){
  53. Map<String, String> ret = new HashMap<String, String>();
  54. if(role == null){
  55. ret.put("type", "error");
  56. ret.put("msg", "请填写正确的角色信息!");
  57. return ret;
  58. }
  59. if(StringUtils.isEmpty(role.getName())){
  60. ret.put("type", "error");
  61. ret.put("msg", "请填写角色名称!");
  62. return ret;
  63. }
  64. if(roleService.add(role) <= 0){
  65. ret.put("type", "error");
  66. ret.put("msg", "角色添加失败,请联系管理员!");
  67. return ret;
  68. }
  69. ret.put("type", "success");
  70. ret.put("msg", "角色添加成功!");
  71. return ret;
  72. }
  73. /**
  74. * 角色修改
  75. * @param role
  76. * @return
  77. */
  78. @RequestMapping(value="/edit",method=RequestMethod.POST)
  79. @ResponseBody
  80. public Map<String, String> edit(Role role){
  81. Map<String, String> ret = new HashMap<String, String>();
  82. if(role == null){
  83. ret.put("type", "error");
  84. ret.put("msg", "请填写正确的角色信息!");
  85. return ret;
  86. }
  87. if(StringUtils.isEmpty(role.getName())){
  88. ret.put("type", "error");
  89. ret.put("msg", "请填写角色名称!");
  90. return ret;
  91. }
  92. if(roleService.edit(role) <= 0){
  93. ret.put("type", "error");
  94. ret.put("msg", "角色修改失败,请联系管理员!");
  95. return ret;
  96. }
  97. ret.put("type", "success");
  98. ret.put("msg", "角色修改成功!");
  99. return ret;
  100. }
  101. /**
  102. * 删除角色信息
  103. * @param id
  104. * @return
  105. */
  106. @RequestMapping(value="/delete",method=RequestMethod.POST)
  107. @ResponseBody
  108. public Map<String, String> delete(Long id){
  109. Map<String, String> ret = new HashMap<String, String>();
  110. if(id == null){
  111. ret.put("type", "error");
  112. ret.put("msg", "请选择要删除的角色!");
  113. return ret;
  114. }
  115. try {
  116. if(roleService.delete(id) <= 0){
  117. ret.put("type", "error");
  118. ret.put("msg", "删除失败,请联系管理员!");
  119. return ret;
  120. }
  121. } catch (Exception e) {
  122. // TODO: handle exception
  123. ret.put("type", "error");
  124. ret.put("msg", "该角色下存在权限或者用户信息,不能删除!");
  125. return ret;
  126. }
  127. ret.put("type", "success");
  128. ret.put("msg", "角色删除成功!");
  129. return ret;
  130. }
  131. /**
  132. * 获取所有的菜单信息
  133. * @return
  134. */
  135. @RequestMapping(value="/get_all_menu",method=RequestMethod.POST)
  136. @ResponseBody
  137. public List<Menu> getAllMenu(){
  138. Map<String, Object> queryMap = new HashMap<String, Object>();
  139. queryMap.put("offset", 0);
  140. queryMap.put("pageSize", 99999);
  141. return menuService.findList(queryMap);
  142. }
  143. /**
  144. * 添加权限
  145. * @param ids
  146. * @return
  147. */
  148. @RequestMapping(value="/add_authority",method=RequestMethod.POST)
  149. @ResponseBody
  150. public Map<String, String> addAuthority(
  151. @RequestParam(name="ids",required=true) String ids,
  152. @RequestParam(name="roleId",required=true) Long roleId
  153. ){
  154. Map<String,String> ret = new HashMap<String, String>();
  155. if(StringUtils.isEmpty(ids)){
  156. ret.put("type", "error");
  157. ret.put("msg", "请选择相应的权限!");
  158. return ret;
  159. }
  160. if(roleId == null){
  161. ret.put("type", "error");
  162. ret.put("msg", "请选择相应的角色!");
  163. return ret;
  164. }
  165. if(ids.contains(",")){
  166. ids = ids.substring(0,ids.length()-1);
  167. }
  168. String[] idArr = ids.split(",");
  169. if(idArr.length > 0){
  170. authorityService.deleteByRoleId(roleId);
  171. }
  172. for(String id:idArr){
  173. Authority authority = new Authority();
  174. authority.setMenuId(Long.valueOf(id));
  175. authority.setRoleId(roleId);
  176. authorityService.add(authority);
  177. }
  178. ret.put("type", "success");
  179. ret.put("msg", "权限编辑成功!");
  180. return ret;
  181. }
  182. /**
  183. * 获取某个角色的所有权限
  184. * @param roleId
  185. * @return
  186. */
  187. @RequestMapping(value="/get_role_authority",method=RequestMethod.POST)
  188. @ResponseBody
  189. public List<Authority> getRoleAuthority(
  190. @RequestParam(name="roleId",required=true) Long roleId
  191. ){
  192. return authorityService.findListByRoleId(roleId);
  193. }
  194. }

前台首页控制器:

  1. /**
  2. * 前台首页控制器
  3. * @author yy
  4. *
  5. */
  6. @RequestMapping("/home")
  7. @Controller
  8. public class HomeController {
  9. @Autowired
  10. private RoomTypeService roomTypeService;
  11. @Autowired
  12. private AccountService accountService;
  13. /**
  14. * 前台首页
  15. * @param model
  16. * @param name
  17. * @return
  18. */
  19. @RequestMapping(value="/index",method=RequestMethod.GET)
  20. public ModelAndView list(ModelAndView model,
  21. @RequestParam(name="name",defaultValue="") String name
  22. ){
  23. Map<String,Object> queryMap = new HashMap<String, Object>();
  24. queryMap.put("name", name);
  25. queryMap.put("offset", 0);
  26. queryMap.put("pageSize", 999);
  27. model.addObject("roomTypeList", roomTypeService.findList(queryMap));
  28. model.setViewName("home/index/index");
  29. model.addObject("kw", name);
  30. return model;
  31. }
  32. /**
  33. * 登录页面
  34. * @param model
  35. * @return
  36. */
  37. @RequestMapping(value="/login",method=RequestMethod.GET)
  38. public ModelAndView login(ModelAndView model
  39. ){
  40. model.setViewName("home/index/login");
  41. return model;
  42. }
  43. /**
  44. * 注册页面
  45. * @param model
  46. * @return
  47. */
  48. @RequestMapping(value="/reg",method=RequestMethod.GET)
  49. public ModelAndView reg(ModelAndView model
  50. ){
  51. model.setViewName("home/index/reg");
  52. return model;
  53. }
  54. /**
  55. * 登录信息提交
  56. * @param account
  57. * @return
  58. */
  59. @RequestMapping(value="/login",method=RequestMethod.POST)
  60. @ResponseBody
  61. public Map<String,String> loginAct(Account account,String vcode,HttpServletRequest request){
  62. Map<String,String> retMap = new HashMap<String, String>();
  63. if(account == null){
  64. retMap.put("type", "error");
  65. retMap.put("msg", "请填写正确的用户信息!");
  66. return retMap;
  67. }
  68. if(StringUtils.isEmpty(account.getName())){
  69. retMap.put("type", "error");
  70. retMap.put("msg", "用户名不能为空!");
  71. return retMap;
  72. }
  73. if(StringUtils.isEmpty(account.getPassword())){
  74. retMap.put("type", "error");
  75. retMap.put("msg", "密码不能为空!");
  76. return retMap;
  77. }
  78. if(StringUtils.isEmpty(vcode)){
  79. retMap.put("type", "error");
  80. retMap.put("msg", "验证码不能为空!");
  81. return retMap;
  82. }
  83. Object attribute = request.getSession().getAttribute("accountLoginCpacha");
  84. if(attribute == null){
  85. retMap.put("type", "error");
  86. retMap.put("msg", "验证码过期,请刷新!");
  87. return retMap;
  88. }
  89. if(!vcode.equalsIgnoreCase(attribute.toString())){
  90. retMap.put("type", "error");
  91. retMap.put("msg", "验证码错误!");
  92. return retMap;
  93. }
  94. Account findByName = accountService.findByName(account.getName());
  95. if(findByName == null){
  96. retMap.put("type", "error");
  97. retMap.put("msg", "用户名不存在!");
  98. return retMap;
  99. }
  100. if(!account.getPassword().equals(findByName.getPassword())){
  101. retMap.put("type", "error");
  102. retMap.put("msg", "密码错误!");
  103. return retMap;
  104. }
  105. if(findByName.getStatus() == -1){
  106. retMap.put("type", "error");
  107. retMap.put("msg", "该用户已被禁用,请联系管理员!");
  108. return retMap;
  109. }
  110. request.getSession().setAttribute("account", findByName);
  111. request.getSession().setAttribute("accountLoginCpacha", null);
  112. retMap.put("type", "success");
  113. retMap.put("msg", "登录成功!");
  114. return retMap;
  115. }
  116. /**
  117. * 注册信息提交
  118. * @param account
  119. * @return
  120. */
  121. @RequestMapping(value="/reg",method=RequestMethod.POST)
  122. @ResponseBody
  123. public Map<String,String> regAct(Account account){
  124. Map<String,String> retMap = new HashMap<String, String>();
  125. if(account == null){
  126. retMap.put("type", "error");
  127. retMap.put("msg", "请填写正确的用户信息!");
  128. return retMap;
  129. }
  130. if(StringUtils.isEmpty(account.getName())){
  131. retMap.put("type", "error");
  132. retMap.put("msg", "用户名不能为空!");
  133. return retMap;
  134. }
  135. if(StringUtils.isEmpty(account.getPassword())){
  136. retMap.put("type", "error");
  137. retMap.put("msg", "密码不能为空!");
  138. return retMap;
  139. }
  140. if(StringUtils.isEmpty(account.getMobile())){
  141. retMap.put("type", "error");
  142. retMap.put("msg", "手机号不能为空!");
  143. return retMap;
  144. }
  145. if(isExist(account.getName())){
  146. retMap.put("type", "error");
  147. retMap.put("msg", "该用户名已经存在!");
  148. return retMap;
  149. }
  150. if(accountService.add(account) <= 0){
  151. retMap.put("type", "error");
  152. retMap.put("msg", "注册失败,请联系管理员!");
  153. return retMap;
  154. }
  155. retMap.put("type", "success");
  156. retMap.put("msg", "注册成功!");
  157. return retMap;
  158. }
  159. /**
  160. * 退出登录
  161. * @param request
  162. * @return
  163. */
  164. @RequestMapping(value="/logout",method=RequestMethod.GET)
  165. public String logout(HttpServletRequest request){
  166. request.getSession().setAttribute("account", null);
  167. return "redirect:login";
  168. }
  169. private boolean isExist(String name){
  170. Account account = accountService.findByName(name);
  171. if(account == null)return false;
  172. return true;
  173. }
  174. }

前台用户控制器:

  1. /**
  2. * 前台用户控制器
  3. * @author yy
  4. *
  5. */
  6. @RequestMapping("/home/account")
  7. @Controller
  8. public class HomeAccountController {
  9. @Autowired
  10. private RoomTypeService roomTypeService;
  11. @Autowired
  12. private AccountService accountService;
  13. @Autowired
  14. private BookOrderService bookOrderService;
  15. /**
  16. * 前台用户中心首页
  17. * @param model
  18. * @param name
  19. * @return
  20. */
  21. @RequestMapping(value="/index",method=RequestMethod.GET)
  22. public ModelAndView list(ModelAndView model,HttpServletRequest request
  23. ){
  24. Account account = (Account)request.getSession().getAttribute("account");
  25. Map<String,Object> queryMap = new HashMap<String, Object>();
  26. queryMap.put("accountId", account.getId());
  27. queryMap.put("offset", 0);
  28. queryMap.put("pageSize", 999);
  29. model.addObject("bookOrderList", bookOrderService.findList(queryMap));
  30. model.addObject("roomTypeList", roomTypeService.findAll());
  31. model.setViewName("home/account/index");
  32. return model;
  33. }
  34. /**
  35. * 预定房间页面
  36. * @param model
  37. * @return
  38. */
  39. @RequestMapping(value="/book_order",method=RequestMethod.GET)
  40. public ModelAndView bookOrder(ModelAndView model,Long roomTypeId
  41. ){
  42. model.addObject("roomType", roomTypeService.find(roomTypeId));
  43. model.setViewName("home/account/book_order");
  44. return model;
  45. }
  46. /**
  47. * 预定信息提交
  48. * @param account
  49. * @return
  50. */
  51. @RequestMapping(value="/book_order",method=RequestMethod.POST)
  52. @ResponseBody
  53. public Map<String,String> bookOrderAct(BookOrder bookOrder,HttpServletRequest request){
  54. Map<String, String> ret = new HashMap<String, String>();
  55. if(bookOrder == null){
  56. ret.put("type", "error");
  57. ret.put("msg", "请填写正确的预定订单信息!");
  58. return ret;
  59. }
  60. Account account = (Account)request.getSession().getAttribute("account");
  61. if(account == null){
  62. ret.put("type", "error");
  63. ret.put("msg", "客户不能为空!");
  64. return ret;
  65. }
  66. bookOrder.setAccountId(account.getId());
  67. if(bookOrder.getRoomTypeId() == null){
  68. ret.put("type", "error");
  69. ret.put("msg", "房型不能为空!");
  70. return ret;
  71. }
  72. if(StringUtils.isEmpty(bookOrder.getName())){
  73. ret.put("type", "error");
  74. ret.put("msg", "预定订单联系人名称不能为空!");
  75. return ret;
  76. }
  77. if(StringUtils.isEmpty(bookOrder.getMobile())){
  78. ret.put("type", "error");
  79. ret.put("msg", "预定订单联系人手机号不能为空!");
  80. return ret;
  81. }
  82. if(StringUtils.isEmpty(bookOrder.getIdCard())){
  83. ret.put("type", "error");
  84. ret.put("msg", "联系人身份证号不能为空!");
  85. return ret;
  86. }
  87. if(StringUtils.isEmpty(bookOrder.getArriveDate())){
  88. ret.put("type", "error");
  89. ret.put("msg", "到达时间不能为空!");
  90. return ret;
  91. }
  92. if(StringUtils.isEmpty(bookOrder.getLeaveDate())){
  93. ret.put("type", "error");
  94. ret.put("msg", "离店时间不能为空!");
  95. return ret;
  96. }
  97. bookOrder.setCreateTime(new Date());
  98. bookOrder.setStatus(0);
  99. if(bookOrderService.add(bookOrder) <= 0){
  100. ret.put("type", "error");
  101. ret.put("msg", "添加失败,请联系管理员!");
  102. return ret;
  103. }
  104. RoomType roomType = roomTypeService.find(bookOrder.getRoomTypeId());
  105. //预定成功后去修改该房型的预定数
  106. if(roomType != null){
  107. roomType.setBookNum(roomType.getBookNum() + 1);
  108. roomType.setAvilableNum(roomType.getAvilableNum() - 1);
  109. roomTypeService.updateNum(roomType);
  110. //如果可用的房间数为0,则设置该房型状态已满
  111. if(roomType.getAvilableNum() == 0){
  112. roomType.setStatus(0);
  113. roomTypeService.edit(roomType);
  114. }
  115. }
  116. ret.put("type", "success");
  117. ret.put("msg", "预定成功!");
  118. return ret;
  119. }
  120. /**
  121. * 修改个人信息提交
  122. * @param account
  123. * @return
  124. */
  125. @RequestMapping(value="/update_info",method=RequestMethod.POST)
  126. @ResponseBody
  127. public Map<String,String> updateInfoAct(Account account,HttpServletRequest request){
  128. Map<String,String> retMap = new HashMap<String, String>();
  129. if(account == null){
  130. retMap.put("type", "error");
  131. retMap.put("msg", "请填写正确的用户信息!");
  132. return retMap;
  133. }
  134. if(StringUtils.isEmpty(account.getName())){
  135. retMap.put("type", "error");
  136. retMap.put("msg", "用户名不能为空!");
  137. return retMap;
  138. }
  139. Account loginedAccount = (Account)request.getSession().getAttribute("account");
  140. if(isExist(account.getName(),loginedAccount.getId())){
  141. retMap.put("type", "error");
  142. retMap.put("msg", "该用户名已经存在!");
  143. return retMap;
  144. }
  145. loginedAccount.setAddress(account.getAddress());
  146. loginedAccount.setIdCard(account.getIdCard());
  147. loginedAccount.setMobile(account.getMobile());
  148. loginedAccount.setName(account.getName());
  149. loginedAccount.setRealName(account.getRealName());
  150. if(accountService.edit(loginedAccount) <= 0){
  151. retMap.put("type", "error");
  152. retMap.put("msg", "修改失败,请联系管理员!");
  153. return retMap;
  154. }
  155. request.getSession().setAttribute("account", loginedAccount);
  156. retMap.put("type", "success");
  157. retMap.put("msg", "修改成功!");
  158. return retMap;
  159. }
  160. /**
  161. * 修改密码提交
  162. * @param account
  163. * @return
  164. */
  165. @RequestMapping(value="/update_pwd",method=RequestMethod.POST)
  166. @ResponseBody
  167. public Map<String,String> updatePwdAct(String oldPassword,String newPassword,HttpServletRequest request){
  168. Map<String,String> retMap = new HashMap<String, String>();
  169. if(StringUtils.isEmpty(oldPassword)){
  170. retMap.put("type", "error");
  171. retMap.put("msg", "请填写原来的密码!");
  172. return retMap;
  173. }
  174. if(StringUtils.isEmpty(newPassword)){
  175. retMap.put("type", "error");
  176. retMap.put("msg", "请填写新密码!");
  177. return retMap;
  178. }
  179. Account loginedAccount = (Account)request.getSession().getAttribute("account");
  180. if(!oldPassword.equals(loginedAccount.getPassword())){
  181. retMap.put("type", "error");
  182. retMap.put("msg", "原密码错误!");
  183. return retMap;
  184. }
  185. loginedAccount.setPassword(newPassword);
  186. if(accountService.edit(loginedAccount) <= 0){
  187. retMap.put("type", "error");
  188. retMap.put("msg", "修改失败,请联系管理员!");
  189. return retMap;
  190. }
  191. retMap.put("type", "success");
  192. retMap.put("msg", "修改密码成功!");
  193. return retMap;
  194. }
  195. /**
  196. * 判断用户是否存在
  197. * @param name
  198. * @param id
  199. * @return
  200. */
  201. private boolean isExist(String name,Long id){
  202. Account account = accountService.findByName(name);
  203. if(account == null)return false;
  204. if(account != null && account.getId().longValue() == id)return false;
  205. return true;
  206. }
  207. }

源码获取:博客首页 "资源" 里下载!

标签: mysql java ssm

本文转载自: https://blog.csdn.net/yuyecsdn/article/details/124047258
版权归原作者 pastclouds 所有, 如有侵权,请联系我们删除。

“Java项目:YY酒店管理系统(java+JSP+Easyui+Echars+ssm+mysql)”的评论:

还没有评论