该系统分为前台和后台,前台可以自主注册,后台管理员角色,除基础脚手架外,实现的功能有:
后台管理员功能有:
商品分类管理、商品管理、套餐管理、新闻分类管理、新闻管理、常见问题、关于我们、团队管理、订单查看和前台用户查看等功能。
前台用户功能有:注册登录、查看商品、购物车、支付订单、评价、照片库、新闻列表、个人中心、购买套餐等功能。
运行环境:windows/linux均可、jdk1.8、mysql5.7、maven3.5\maven3.6、idea/eclip均可。
系统控制器代码:
/*** 系统控制器* @author admin**/@requestmapping("/system")@controllerpublic class systemcontroller {@autowiredprivate operaterlogrvice operaterlogrvice;@autowiredprivate urrvice urrvice;@autowiredprivate datababakrvice datababakrvice;@autowiredprivate staffrvice staffrvice;@autowiredprivate orderauthrvice orderauthrvice;private logger log = loggerfactory.getlogger(systemcontroller.class);/*** 登录页面* @param model* @return*/@requestmapping(value="/login",method=requestmethod.get)public string login(model model){model.addattribute("logintypes", logintype.values());return "admin/system/login";}/*** 用户登录提交表单处理方法* @param request* @param cpacha* @return*/@requestmapping(value="/login",method=requestmethod.post)@responbodypublic result<boolean> login(httprvletrequest request,string urname,string password,string cpacha,integer type){if(stringutils.impty(urname)){return result.error(codemsg.admin_urname_empty);}if(stringutils.impty(password)){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);}if(type == logintype.administrator.getcode()){//表示验证码正确,开始查询数据库,检验密码是否正确ur findbyurname = urrvice.findbyurname(urname);//判断是否为空if(findbyurname == null){return result.error(codemsg.admin_urname_no_exist);}//表示用户存在,进一步对比密码是否正确if(!findbyurname.getpassword().equals(password)){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);request.getssion().tattribute("logintype",type);//销毁ssion中的验证码request.getssion().tattribute("admin_login", null);//将登陆记录写入日志库operaterlogrvice.add("用户【"+urname+"】于【" + stringutil.getformatterdate(new date(), "yyyy-mm-dd hh:mm:ss") + "】登录系统!");log.info("用户成功登录,ur = " + findbyurname);}el{staff byjobnumber = staffrvice.findbynameandisstatus(urname);//判断是否为空if(byjobnumber == null){return result.error(codemsg.admin_urname_no_exist);}//表示用户存在,进一步对比密码是否正确if(!byjobnumber.getpasswo兵马俑在哪里rd().equals(password)){return result.error(codemsg.admin_password_error);}//检查用户所属角色状态是否可用if(byjobnumber.getrole() == null || byjobnumber.getrole().getstatus() == role.admin_role_status_unable){return result.error(codemsg.admin_ur_role_unable);}//检查用户所属角色的权限是否存在if(byjobnumber.getrole().getauthorities() == null || byjobnumber.getrole().getauthorities().size() == 0){return result.error(codemsg.admin_ur_role_authorites_empty);}//检查一切符合,可以登录,将用户信息存放至ssionrequest.getssion().tattribute(ssionconstant.ssion_staff_login_key, byjobnumber);request.getssion().tattribute("logintype",type);//销毁ssion中的验证码request.getssion().tattribute("admin_login", null);//将登陆记录写入日志库operaterlogrvice.add("用户【"+urname+"】于【" + stringutil.getformatterdate(new date(), "yyyy-mm-dd hh:mm:ss") + "】登录系统!");log.info("员工成功登录,ur = " + byjobnumber);}return result.success(true);}/*** 登录成功后的系统主页* @param model* @return*/@requestmapping(value="/index")public string index(model model){model.addattribute("operatorlogs", operaterlogrvice.findlastestlog(10));model.addattribute("urtotal", urrvice.total());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(){integer logintype = (integer) ssionutil.get("logintype");if(logintype == logintype.administrator.getcode()){ur loginedur = ssionutil.getloginedur();if(loginedur != null){ssionutil.t(ssionconstant.ssion_ur_login_key, null);}}el if(logintype == logintype.staff.getcode()){staff loginedstaff = ssionutil.getloginedstaff();if(loginedstaff != null){ssionutil.t(ssionconstant.ssion_staff_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.temail(ur.getemail());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){integer logintype = (integer) ssionutil.get("logintype");if(logintype == logintype.administrator.getcode()){ur loginedur = ssionutil.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);}if(newpwd.length()<4 || newpwd.length()>32){return result.error(codemsg.admin_ur_pwd_length_error);}loginedur.tpassword(newpwd);//保存数据库urrvice.save(loginedur);//更新ssionssionutil.t(ssionconstant.ssion_ur_login_key, loginedur);}el{staff loginedstaff = ssionutil.getloginedstaff();staff staff = staffrvice.find(loginedstaff.getid());if(!staff.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);}staff.tpassword(newpwd);codemsg codemsg = validateentityutil.validate(staff);if (codemsg.getcode() != codemsg.success.getcode()){return result.error(codemsg);}loginedstaff.tpassword(newpwd);//保存数据库staffrvice.save(loginedstaff);//更新ssionssionutil.t(ssionconstant.ssion_staff_login_key, loginedstaff);}return result.success(true);}/*** 日志管理列表* @param model* @param operaterlog* @param pagebean* @return*/@requestmapping(value="/operator_log_list")public string operatorloglist(mo你说你会哭不是因为在乎del 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);}}
用户控制:
/*** 用户控制*/@controller("ur")@requestmapping("/ur")public class urcontroller {private final logger logger = loggerfactory.getlogger(urcontroller.class);private final resultmap resultmap;@autowiredprivate urrvice urrvice;@autowiredprivate urrolervice urrolervice;@autowiredpublic urcontroller(resultmap resultmap) {this.resultmap = resultmap;}/*** 返回有权限信息*/@requestmapping(value = "/getmessage", method = requestmethod.get)public resultmap getmessage() {return resultmap.success().message("您拥有用户权限,可以获得该接口的信息!");}/*** 修改用户信息页面ur/uredit.html*/@requestmapping(value = "/editurpage")public string editurpage(long urid, model model) {model.addattribute("manageur", urid);if (null != urid) {ur ur = urrvice.lectbyprimarykey(urid);model.addattribute("manageur", ur);}return "ur/uredit";}/*** 更新数据库*/@responbody@requestmapping("/updateur")public string updateur(ur ur) {return urrvice.updateur(ur);}}
健康评估控制层:
/*** 健康评估*/@controller("healthcontroller")@requestmappi长春科技学院学费ng("/health")public class healthcontroller {@autowiredprivate diagnosisrvice diagnosisrvice;@autowiredprivate appointmentrvice appointmentrvice;@autowiredprivate petrvice petrvice;@autowiredprivate petdailyrvice petdailyrvice;@autowiredprivate urrvice urrvice;@autowiredprivate standardrvice standardrvice;/*** 分析页面*/@requestmapping("/asss")public string applylistdoctor(model model) {subject subject = curityutils.getsubject();ur ur = (ur) subject.getprincipal();pet pet = new pet();pet.turid(ur.getid());pet.tpage(1);pet.tlimit(100);mmgridpagevobean<pet> vobean = (mmgridpagevobean<pet>) petrvice.getallbylimit(pet);list<pet> rows = vobean.getrows();// 获取到该用户下所有的宠物model.addattribute("pets", rows);list<long> applycount = new arraylist<>();list<string> dscount = new arraylist<>();list<string> tscount = new arraylist<>();list<string> wscount = new arraylist<>();list<string> hscount = new arraylist<>();list<string> ascount = new arraylist<>();list<double> pt = new arraylist<>();list<double> pw = new arraylist<>();list<double> ph = new arraylist<>();list<double> pa = new arraylist<>();list<double> mt = new arraylist<>();list<double> mw = new arraylist<>();list<double> mh = new arraylist<>();list<double> ma = new arraylist<>();for(pet p: rows){// 获取预约次数appointment appointment = new appointment();appointment.tpetid(p.getid());appointment.tpage(1);appointment.tlimit(1000);mmgridpagevobean<appointment> as = (mmgridpagevobean<appointment>) appointmentrvice.getallbylimit(appointment);applycount.add(as==null? 0l : as.gettotal());// 获取就诊记录diagnosis diagnosis = new diagnosis();diagnosis.tpetid(p.getid());diagnosis.tpage(1);diagnosis.tlimit(10);mmgridpagevobean<diagnosis> ds = (mmgridpagevobean<diagnosis>) diagnosisrvice.getallbylimit(diagnosis);list<diagnosis> dsrows = ds.getrows();int diagnosisstatus = 0;for (diagnosis d: dsrows){diagnosisstatus += d.getstatus();}int sw = diagnosisstatus / dsrows.size();switch (sw){ca 1:dscount.add(p.getname() + " 宠物健康,请继续保持");break;ca 2:dscount.add(p.getname() + " 宠物异常请及时就诊!");break;ca 3:dscount.add(p.getname() + " 宠物病情比较严重,请及时就医!");break;ca 4:dscount.add(p.getname() + " 很抱歉宠物已无法治疗!");break;default:dscount.add(p.getname() + " 宠物基本健康,请继续保持");break;}// 获取宠物日志petdaily petdaily = new petdaily();petdaily.tpetid(p.getid());petdaily.tpage(1);petdaily.tlimit(10);mmgridpagevobean<petdaily> ps = (mmgridpagevobean<petdaily>) petdailyrvice.getallbylimit(petdaily);list<petdaily> psrows = ps.getrows();double t = 0;double w = 0;double h = 0;double a = 0;for (petdaily petdaily1 : psrows){t+=petdaily1.gettemperature();w+=petdaily1.getweight();h+=petdaily1.getheight();a+=petdaily1.杭州西湖十景getappetite();}t = t/psrows.size();w = w/psrows.size();h = h/psrows.size();a = a/psrows.size();pt.add(t);pw.add(w);ph.add(h);pa.add(a);// 获取标准standard standard = new standard();// 对应宠物类型standard.ttype(p.gettype());// 健康标准standard.tstatus(1);int petage = myutils.get2dateday(myutils.getdate2string(p.getbirthday(), "yyyy-mm-dd"), myutils.getdate2string(new date(), "yyyy-mm-dd"));petage = (petage<0? -petage : petage)/365;// 年龄standard.tagemax(petage);standard.tpage(1);standard.tlimit(100);mmgridpagevobean<standard> ss = (mmgridpagevobean<standard>) standardrvi毕业祝福语ce.getallbylimit(standard);list<standard> ssrows = ss.getrows();double tsmin = 0;double tsmax = 0;double wsmin = 0;double wsmax = 0;double hsmin = 0;double hsmax = 0;double asmin = 0;double asmax = 0;for (standard s : ssrows){tsmin+=s.gettempmin();tsmax+=s.gettempmax();wsmin+=s.getweightmin();wsmax+=s.getweightmax();hsmin+=s.getheightmin();hsmax+=s.getheightmax();asmin+=s.getappetitemin();asmax+=s.getappetitemax();}tsmin = tsmin / ssrows.size();tsmax = tsmax / ssrows.size();wsmin = wsmin / ssrows.size();wsmax = wsmax / ssrows.size();hsmin = hsmin / ssrows.size();hsmax = hsmax / ssrows.size();asmin = asmin / ssrows.size();asmax = asmax / ssrows.size();mt.add(tsmax);mw.add(wsmax);mh.add(hsmax);ma.add(asmax);if (t>=tsmin && t<=tsmax){tscount.add(" 体温正常");}el if (t<tsmin){tscount.add( " 体温偏低");}el if (t>tsmax){tscount.add( " 体温偏高");}if (w>=wsmin && w<=wsmax){wscount.add( " 体重正常");}el if (w<wsmin){wscount.add(" 体重偏低");}el if (w>wsmax){wscount.add(" 体重偏高");}if (h>=hsmin && h<=hsmax){hscount.add(" 身高正常");}el if (h<hsmin){hscount.add( " 身高偏低");}el if (h>hsmax){hscount.add(" 身高偏高");}if (a>=asmin && a<=asmax){ascount.add( " 饭量正常");}el if (a<asmin){ascount.add(" 饭量偏低");}el if (a>asmax){ascount.add(" 饭量偏高");}}model.addattribute("pets", rows);model.addattribute("tscount", tscount);model.addattribute("wscount", wscount);model.addattribute("hscount", hscount);model.addattribute("ascount", ascount);model.addattribute("dscount", dscount);system.out.println(pt);model.addattribute("pt", pt);model.addattribute("ph", ph);model.addattribute("pw", pw);model.addattribute("pa", pa);model.addattribute("mt", mt);model.addattribute("mh", mh);model.addattribute("mw", mw);model.addattribute("ma", ma);return "tj/asss";}/*** 普通用户预约统计*/@requestmapping("/tjapply")public string tjapply(model model) {subject subject = curityutils.getsubject();ur ur = (ur) subject.getprincipal();appointment appointment = new appointment();appointment.turid(ur.getid());appointment.tpage(1);appointment.tlimit(99999);mmgridpagevobean<appointment> vobean = (mmgridpagevobean<appointment>) appointmentrvice.getallbylimit(appointment);list<appointment> rows = vobean.getrows();integer a1 = 0;integer a2 = 0;integer a3 = 0;integer a4 = 0;for (appointment a: rows){switch (a.getstatus()){ca 1: a1++;break;ca 2: a2++;break;ca 3: a3++;break;ca 4: a4++;break;}}model.addattribute("a1", a1);model.addattribute("a2", a2);model.addattribute("a3", a3);model.addattribute("a4", a4);return "tj/tjapply";}/*** 医生预约统计*/@requestmapping("/tjapplydoctor")public string tjapplydoctor(model model) {appointment appointment = new appointment();appointment.tpage(1);appointment.tlimit(99999);mmgridpagevobean<appointment> vobean = (mmgridpagevobean<appointment>) appointmentrvice.getallbylimit(appointment);list<appointment> rows = vobean.getrows();integer a1 = 0;integer a2 = 0;integer a3 = 0;integer a4 = 0;for (appointment a: rows){switch (a.getstatus()){ca 1: a1++;break;ca 2: a2++;break;ca 3: a3++;break;ca 4: a4++;break;}}model.addattribute("a1", a1);model.addattribute("a2", a2);model.addattribute("a3", a3);model.addattribute("a4", a4);return "tj/tjapplydoctor";}/*** 普通用户宠物日志统计*/@requestmapping("/tjdaily")public string tjdaily(model model) {subject subject = curityutils.getsubject();ur ur = (ur) subject.getprincipal();pet pet = new pet();pet.turid(ur.getid());pet.tpage(1);pet.tlimit(99999);mmgridpagevobean<pet> vobean = (mmgridpagevobean<pet>) petrvice.getallbylimit(pet);list<pet> rows = vobean.getrows();model.addattribute("pets", rows);if (rows.size()>0){pet = rows.get(0);petdaily daily = new petdaily();daily.tpetid(pet.getid());daily.tpage(1);daily.tlimit(99999);mmgridpagevobean<petdaily> ppp = (mmgridpagevobean<petdaily>) petdailyrvice.getallbylimit(daily);list<petdaily> list = ppp.getrows();for (petdaily p : list){p.tdatetime(myutils.getdate2string(p.getcreatetime(), "yyyy-mm-dd"));}model.addattribute("dailys", list);}return "tj/tjdaily";}/*** 医生宠物日志统计*/@requestmapping("/tjdailydoctor")public string tjdailydoctor(model model) {pet pet = new pet();pet.tpage(1);pet.tlimit(99999);mmgridpagevobean<pet> vobean = (mmgridpagevobean<pet>) petrvice.getallbylimit(pet);list<pet> rows = vobean.getrows();model.addattribute("pets", rows);if (rows.size()>0){pet = rows.get(0);petdaily daily = new petdaily();daily.tpetid(pet.getid());daily.tpage(1);daily.tlimit(99999);mmgridpagevobean<petdaily> ppp = (mmgridpagevobean<petdaily>) petdailyrvice.getallbylimit(daily);list<petdaily> list = ppp.getrows();for (petdaily p : list){p.tdatetime(myutils.getdate2string(p.getcreatetime(), "yyyy-mm-dd"));}model.addattribute("dailys", list);}return "tj/tjdailydoctor";}/*** 普通用户查询条件数据返回宠物日志*/@requestmapping("/tjdailydata")@responbodypublic object tjdailydata(long id){petdaily daily = new petdaily();daily.tpetid(id);daily.tpage(1);daily.tlimit(99999);mmgridpagevobean<petdaily> ppp = (mmgridpagevobean<petdaily>) petdailyrvice.getallbylimit(daily);list<petdaily> list = ppp.getrows();for (petdaily p : list){p.tdatetime(myutils.getdate2string(p.getcreatetime(), "yyyy-mm-dd"));}return list;}/*** 医生查询条件数据返回宠物日志*/@requestmapping("/tjdailydatadoctor")@responbodypublic object tjdailydatadoctor(long id){petdaily daily = new petdaily();daily.tpetid(id);daily.tpage(1);daily.tlimit(99999);mmgridpagevobean<petdaily> ppp = (mmgridpagevobean<petdaily>) petdailyrvice.getallbylimit(daily);list<petdaily> list = ppp.getrows();for (petdaily p : list){p.tdatetime(myutils.getdate2string(p.getcreatetime(), "yyyy-mm-dd"));}return list;}/*** 用户查看医生空闲时间*/@requestmapping(value = "/freetime")public string freetime(model model) {list<ur> doctors = urrvice.listdoctor();model.addattribute("doctors", doctors);long docid = doctors.get(0).getid();model.addattribute("docname", doctors.get(0).getname());string nowdateymd = myutils.getnowdateymd();list<map<string, object>> map = appointmentrvice.getfreetimebyid(docid, nowdateymd+myutils.start_hour);list<string> time = new arraylist<>();list<long> value = new arraylist<>();for (map<string, object> m : map){string df = (string) m.get("df");time.add(df);long v = (long) m.get("c");if (v == null) {value.add(0l);}el {value.add(v);}}model.addattribute("time", time);model.addattribute("value", value);return "tj/freetime";}@requestmapping(value = "/getfreetime")@responbodypublic object getfreetime(long id, string date) {ur doctors = urrvice.lectbyprimarykey(id);map<string, object> result = new hashmap<>();result.put("n", doctors.getname());list<map<string, object>> map = appointmentrvice.getfreetimebyid(id, date+myutils.start_hour);list<string> time = new arraylist<>();list<long> value = new arraylist<>();for (map<string, object> m : map){string df = (string) m.get("df");time.add(df+"点");long v = (long) m.get("c");if (v == null) {value.add(0l);}el {value.add(v);}}result.put("t", time);result.put("v", value);return result;}}
到此这篇关于java实战宠物店在线交易平台的实现流程的文章就介绍到这了,更多相关java 宠物在线交易内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!
本文发布于:2023-04-04 09:37:47,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/65cb9727f14ab1ee17fac0697cc49ed0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Java实战宠物店在线交易平台的实现流程.doc
本文 PDF 下载地址:Java实战宠物店在线交易平台的实现流程.pdf
留言与评论(共有 0 条评论) |