系统分普通用户、企业、超级管理员等角色,除基础脚手架外,实现的功能有:
超级管理员:系统管理、用户管理、企业用户管理、普通用户管理、货物类型管理、车辆管理、公告管理、使用帮助等。
普通用户:注册登录、个人信息管理(个人资料、密码修改、充值、订单管理等)、货物浏览、公告查看、下单等。
企业用户:注册登录、修改密码、充值、订单管理、货物管理、车辆管理、安排车辆等。
运行环境:windows/linux均可、jdk1.8、mysql5.7、redis3.0、idea/eclip均可。
特色功能:系统支持支付宝沙箱支付。
后台角色管理控制器:
/** * 后台角色管理控制器 * */@requestmapping("/admin/role")@controllerpublic class rolecontroller { private logger log = loggerfactory.getlogger(rolecontroller.class);@autowiredprivate menurvice menurvice;@autowiredprivate operaterlogrvice operaterlogrvice;@autowiredprivate rolervice rolervice;/** * 分页搜索角色列表 * @param model * @param role * @param pagebean * @return */@requestmapping(value="/list")public string list(model model,role role,pagebean<role> pagebean){model.addattribute("title", "角色列表");model.addattribute("name", role.getname());model.addattribute("pagebean", rolervice.findbyname(role, pagebean));return "admin/role/list";}/** * 角色添加页面 * @param model * @return */@requestmapping(value="/add",method=requestmethod.get)public string add(model model){list<menu> findall = menurvice.findall();model.addattribute("roletypes", urroletypeenum.values());model.addattribute("topmenus",menuutil.gettopmenus(findall));model.addattribute("condmenus",menuutil.getcondmenus(findall));model.addattribute("thirdmenus",menuutil.getthirdmenus(findall));return "admin/role/add";}/** * 角色添加表单提交处理 * @param role * @return */@requestmapping(value="/add",method=requestmethod.post)@responbodypublic result<boolean> add(role role){role top1byroletype = rolervice.findtop1byroletypeandroletypenot(role.getroletype());if (top1byroletype != null){return result.error(codemsg.admin_role_exist);}//用统一验证实体方法验证是否合法codemsg validate = validateentityutil.validate(role);if(validate.getcode() != codemsg.success.getcode()){return result.error(validate);}if(rolervice.save(role) == null){return result.error(codemsg.admin_role_add_error);}log.info("添加角色【"+role+"】");operaterlogrvice.add("添加角色【"+role.getname()+"】");return result.success(true);}/** * 角色编辑页面 * @param id * @param model * @return */@requestmapping(value="/edit",method=requestmethod.get)public string edit(@requestparam(name="id",required=true)long id,model model){list<menu> findall = menurvice.findall();model.addattribute("topmenus",menuutil.gettopmenus(findall));model.addattribute("condmenus",menuutil.getcondmenus(findall));model.addattribute("thirdmenus",menuutil.getthirdmenus(findall));role role = rolervice.find(id);model.addattribute("role", role);model.addattribute("authorities",jsonarray.tojson(role.getauthorities()).tostring());model.addattribute("roletypes", urroletypeenum.values());return "admin/role/edit";}/** * 角色修改表单提交处理 * @param request * @param role * @return */@requestmapping(value="/edit",method=requestmethod.post)@responbodypublic result<boolean> edit(role role){//用统一验证实体方法验证是否合法codemsg validate = validateentityutil.validate(role);if(validate.getcode() != codemsg.success.getcode()){return result.error(validate);}role existrole = rolervice.find(role.getid());if(existrole == null){return result.error(codemsg.admin_role_no_exist);}existrole.tname(role.getname());existrole.tremark(role.getremark());existrole.tstatus(role.getstatus());existrole.tauthorities(role.getauthorities());if(rolervice.save(existrole) == null){return result.error(codemsg.admin_role_edit_error);}log.info("编辑角色【"+role+"】");operaterlogrvice.add("编辑角色【"+role.getname()+"】");return result.success(true);}/** * 删除角色 * @param request * @param id * @return */@requestmapping(value="delete",method=requestmethod.post)@responbodypublic result<boolean> delete(@requestparam(name="id",required=true)long id){try {rolervice.delete(id);} catch (exception e) {// todo: handle exceptionreturn result.error(codemsg.admin_role_delete_error);}log.info("编辑角色id【"+id+"】");operaterlogrvice.add("删除角色id【"+id+"】");return result.success(true);}}
系统控制器:
/** * 系统控制器 * */@requestmapping("/system")@controllerpublic class systemcontroller { @autowiredprivate operaterlogrvice operaterlogrvice;@autowiredprivate urrvice urrvice;@autowiredprivate datababakrvice datababakrvice;@autowiredprivate orderauthrvice orderauthrvice; @autowiredprivate homeurrvice homeurrvice; @autowired private expressmailorderrvice expressmailorderrvice; private logger log = loggerfactory.getlogger(systemcontroller.class);/** * 登录页面 * @param model * @return */@requestmapping(value="/login",method=requestmethod.get)public string login(model model){return "admin/system/login";}/** * 用户登录提交表单处理方法 * @param request * @param ur * @param cpacha * @return */@requestmapping(value="/login",method=requestmethod.post)@responbodypublic result<boolean> login(httprvletrequest request,ur ur,string cpacha){if(ur == null){return result.error(codemsg.data_error);}if (ur.geturname() == null || "".equals(ur.geturname())){return result.error(codemsg.admin_urname_empty);}if (ur.getpassword() == null || "".equals(ur.getpassword())){return result.error(codemsg.admin_password_empty);}//表示实体信息合法,开始验证验证码是否为空if(stringutils.impty(cpacha)){return result.error(codemsg.cpacha_empty);}//说明验证码不为空,从ssion里获取验证码object attribute = request.getssion().getattribute("admin_login");if(attribute == null){return result.error(codemsg.ssion_expired);}//表示ssion未失效,进一步判断用户填写的验证码是否正确if(!cpacha.equalsignoreca(attribute.tostring())){return result.error(codemsg.cpacha_error);}//表示验证码正确,开始查询数据库,检验密码是否正确ur findby木炭在氧气中燃烧的现象urname = urrvice.findbyurname(ur.geturname());//判断是否为空if(findbyurname == null){return result.error(codemsg.admin_urname_no_exist);}//表示用户存在,进一步对比密码是否正确if(!findbyurname.getpassword().equals(ur.getpassword())){return result.error(codemsg.admin_password_error);}//表示密码正确,接下来判断用户状态是否可用if(findbyurname.getstatus() == ur.admin_ur_status_unable){return result.error(codemsg.admin_ur_unable);}//检查用户所属角色状态是否可用if(findbyurname.getrole() == null || findbyurname.getrole().getstatus() == role.admin_role_status_unable){return result.error(codemsg.admin_ur_role_unable);}//检查用户所属角色的权限是否存在if(findbyurname.getrole().getauthorities() == null || findbyurname.getrole().getauthorities().size() == 0){return result.error(codemsg.admin_ur_role_authorites_empty);}//检查一切符合,可以登录,将用户信息存放至ssionrequest.getssion().tattribute(ssionconstant.ssion_ur_login_key, findbyurname);//销毁ssion中的验证码request.getssion().tattribute("admin_login", null);//将登陆记录写入日志库operaterlogrvice.add("用户【"+ur.geturname()+"】于【" + stringutil.getformatterdate(new date(), "yyyy-mm-dd hh:mm:ss") + "】登录系统!");log.info("用户成功登录,ur = " + findbyurname);return result.success(true);}/** * 登录成功后的系统主页 * @param model * @return */@requestmapping(value="/index")public string index(model model){model.addattribute("operatorlogs", operaterlogrvice.findlastestlog(10));bigdecimal homeurcount = new bigdecimal(homeurrvice.total());bigdecimal urcount = new bigdecimal(urrvice.total());bigdecimal homeurcountaddurcount = homeurcount.add(urcount);model.addattribute("branchesus班超素有大志ers",urrvice.inquiryou孔雀用英语怎么说tletsunderthecourier());model.addattribute("ordercountandmonthbynowyearlist",expressmailorderrvice.ordercountandmonthbynowyear());model.addattribute("urtotal",homeurcountaddurcount);model.addattribute("operatorlogtotal", operaterlogrvice.total());model.addattribute("datababackuptotal", datababakrvice.total());model.addattribute("onlineurtotal", ssionlistener.onlineurcount);return "admin/system/index";}/** * 注销登录 * @return */@requestmapping(value="/logout")public string logout(){ur loginedur = ssionutil.getloginedur();if(loginedur != null){ssionutil.t(ssionconstant.ssion_ur_login_key, null);}return "redirect:login";}/** * 无权限提示页面 * @return */@requestmapping(value="/no_right")public string noright(){return "admin/system/no_right";}/** * 修改用户个人信息 * @return */@requestmapping(value="/update_urinfo",method=requestmethod.get)public string updateurinfo(){return "admin/system/update_urinfo";}/** * 修改个人信息保存 * @param ur * @return */@requestmapping(value="/update_urinfo",method=requestmethod.post)public string updateurinfo(ur ur){ur loginedur = ssionutil.getloginedur();loginedur.tmobile(ur.getmobile());loginedur.theadpic(ur.getheadpic());//首先保存到数据库urrvice.save(loginedur);//更新ssion里的值ssionutil.t(ssionconstant.ssion_ur_login_key, loginedur);return "redirect:update_urinfo";}/** * 修改密码页面 * @return */@requestmapping(value="/update_pwd",method=requestmethod.get)public string updatepwd(){return "admin/system/update_pwd";}/** * 修改密码表单提交 * @param oldpwd * @param newpwd * @return */@requestmapping(value="/update_pwd",method=requestmethod.post)@responbodypublic result<boolean> updatepwd(@requestparam(name="oldpwd",required=true)string oldpwd,@requestparam(name="newpwd",required=true)string newpwd){ur loginedur = ssionut个人兴趣爱好il.getloginedur();if(!loginedur.getpassword().equals(oldpwd)){return result.error(codemsg.admin_南部山区ur_update_pwd_error);}if(stringutils.impty(newpwd)){return result.error(codemsg.admin_ur_update_pwd_empty);}loginedur.tpassword(newpwd);//保存数据库ur save = urrvice.save(loginedur);//更新ssionssionutil.t(ssionconstant.ssion_ur_login_key, save);return result.success(true);}/** * 日志管理列表 * @param model * @param operaterlog * @param pagebean * @return */@requestmapping(value="/operator_log_list")public string operatorloglist(model model,operaterlog operaterlog,pagebean<operaterlog> pagebean){model.addattribute("pagebean", operaterlogrvice.findlist(operaterlog, pagebean));model.addattribute("operator", operaterlog.getoperator());model.addattribute("title", "日志列表");return "admin/system/operator_log_list";}/** * 删除操作日志,可删除多个 * @param ids * @return */@requestmapping(value="/delete_operator_log",method=requestmethod.post)@responbodypublic result<boolean> delete(string ids){if(!stringutils.impty(ids)){string[] splitids = ids.split(",");for(string id : splitids){operaterlogrvice.delete(long.valueof(id));}}return result.success(true);}/** * 清空整个日志 * @return */@requestmapping(value="/delete_all_operator_log",method=requestmethod.post)@responbodypublic result<boolean> deleteall(){operaterlogrvice.deleteall();return result.success(true);}}
后台管理员管理控制器:
/** * 后台管理员管理控制器 * */@requestmapping("/admin/ur")@controllerpublic class urcontroller { @autowiredprivate urrvice urrvice;@autowiredprivate rolervice rolervice;@autowiredprivate operaterlogrvice operaterlogrvice;/** * 管理员列表页面 * @param model * @param ur * @param pagebean * @return */@requestmapping(value="/list")public string list(model model,ur ur,pagebean<ur> pagebean){model.addattribute("title", "管理员列表");model.addattribute("urname", ur.geturname());model.addattribute("pagebean", urrvice.findlist(pagebean,ur.geturname(), urroletypeenum.admin));return "admin/ur/list";}/** * 新增管理员页面 * @param model * @return */@requestmapping(value="/add",method=requestmethod.get)public string add(model model){model.addattribute("roles", rolervice.findallbyroletype(urroletypeenum.admin));return "admin/ur/add";}/** * 管理员添加表单提交处理 * @param ur * @return */@requestmapping(value="/add",method=requestmethod.post)@responbodypublic result<boolean> add(ur ur){//用统一验证实体方法验证是否合法codemsg validate = validateentityutil.validate(ur);if(validate.getcode() != codemsg.success.getcode()){return result.error(validate);}if(ur.getrole() == null || ur.getrole().getid() == null){return result.error(codemsg.admin_ur_role_empty);}//判断管理员名是否存在if(urrvice.ixisturname(ur.geturname(), 0l)){return result.error(codemsg.admin_urname_exist);}ur.turtype(urroletypeenum.admin);//到这说明一切符合条件,进行数据库新增if(urrvice.save(ur) == null){return result.error(codemsg.admin_u_add_error);}operaterlogrvice.add("添加管理员,管理员名:" + ur.geturname());return result.success(true);}/** * 管理员编辑页面 * @param model * @return */@requestmapping(value="/edit",method=requestmethod.get)public string edit(model model,@requestparam(name="id",required=true)long id){model.addattribute("roles", rolervice.findallbyroletype(urroletypeenum.admin));model.addattribute("ur", urrvice.find(id));return "admin/ur/edit";}/** * 编辑管理员信息表单提交处理 * @param ur * @return */@requestmapping(value="/edit",method=requestmethod.post)@responbodypublic result<boolean> edit(ur ur){//用统一验证实体方法验证是否合法codemsg validate = validateentityutil.validate(ur);if(validate.getcode() != codemsg.success.getcode()){return result.error(validate);}if(ur.getrole() == null || ur.getrole().getid() == null){return result.error(codemsg.admin_ur_role_empty);}if(ur.getid() == null || ur.getid().longvalue() <= 0){return result.error(codemsg.admin_u_no_exist);}if(urrvice.ixisturname(ur.geturname(), ur.getid())){return result.error(codemsg.admin_urname_exist);}//到这说明一切符合条件,进行数据库保存ur findbyid = urrvice.find(ur.getid());//讲提交的管理员信息指定字段复制到已存在的ur对象中,该方法会覆盖新字段内容beanutils.copyproperties(ur, findbyid, "id","createtime","updatetime","urtype");if(urrvice.save(findbyid) == null){return result.error(codemsg.admin_u_edit_error);}operaterlogrvice.add("编辑管理员,管理员名:" + ur.geturname());return result.success(true);}/** * 删除管理员 * @param id * @return */@requestmapping(value="/delete",method=requestmethod.post)@responbodypublic result<boolean> delete(@requestparam(name="id",required=true)long id){try {urrvice.delete(id);} catch (exception e) {return result.error(codemsg.admin_u_delete_error);}operaterlogrvice.add("删除管理员,管理员id:" + id);return result.success(true);}}
以上就是java实战之实现物流配送系统示例详解的详细内容,更多关于java 物流配送系统的资料请关注www.887551.com其它相关文章!
本文发布于:2023-04-04 03:16:19,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/8f8dbcac614e1c3b05491e7e5abd07bd.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Java实战之实现物流配送系统示例详解.doc
本文 PDF 下载地址:Java实战之实现物流配送系统示例详解.pdf
留言与评论(共有 0 条评论) |