首页 > 作文

Java毕业设计实战之生活旅行分享平台的实现

更新时间:2023-04-04 21:58:57 阅读: 评论:0

一、项目运行

环境配置:

jdk1.8 + tomcat8.5 + mysql + eclispe(intellij idea,eclispe,myeclispe,sts都支持)

项目技术:

springboot+ springmvc + jpa+ jsp + html+ javascript + jquery + ajax + maven等等

评论业务控制器:

/** * 评论控制器 * @author yy * */@restcontroller@requestmapping("/comment")public class commentcontroller {   @resource  private commentrvice commentrvice;   @resource  private articlervice articlervice;   @resource  private replyrvice replyrvice;   /**   * 分页查询评论   * @param comment   * @param page   * @param pagesize   * @return   */  @requestmapping("/list")  public map<string, object> commentlist(comment comment, @r无垠造句equestparam(value = "page", required = fal) integer page,                                         @requestparam(value = "pagesize", required = fal) integer pagesize) {    list<comment> commentlist = commentrvice.list(comment, null, null, page - 1, pagesize, null);    long total = commentrvice.getcount(comment, null, null, null);    int totalpage = (int) (total % pagesize == 0 ? total / pagesize : total / pagesize + 1);    map<string, object> resultmap = new hashmap<string, object>();    resultmap.put("totalpage", totalpage);    resultmap.put("data", commentlist);    return resultmap;  }   /**   * 分页查询评论   * @param page   * @param pagesize   * @return   */  @requestmapping("/massagelist")  public map<string, object> massagelist(@requestparam(value = "page", required = fal) integer page,                                         @requestparam(value = "pagesize", required = fal) integer pagesize) {    list<comment> commentlist = commentrvice.massagelist(page - 1, pagesize);    long total = commentrvice.getcount2();    int totalpage = (int) (total % pagesize == 0 ? total / pagesize : total / pagesize + 1);    map<string, object> resultmap = new hashmap<string, object>();    resultmap.put("totalpage", totalpage);    resultmap.put("data", commentlist);    return resultmap;  }   /**   * 添加评论   * @title: add   * @param comment  评论实体   * @return  参数说明   * @return map<string,object>    返回类型   * @throws   */  @requestmapping("/add")  public map<string, object> add(comment comment, httpssion ssion) {    ur currentur = (ur) ssion.getattribute("ur");    map<string, object> resultmap = new hashmap<string, object>();    comment.tcommentdate(new date());    comment.tur(currentur);    commentrvice.add(comment);    if (comment.getarticle() != null) {      articlervice.increacomment(comment.getarticle().getarticleid());    }    resultmap.put("comment", comment);    resultmap.put("success", true);    return resultmap;  } }

回复业务控制器:

/** * 回复控制器 * @author yy * */@restcontroller@requestmapping("/reply")public class replycontroller {   @resource  private replyrvice replyrvice;   /**   * 获取回复   * @param reply   * @return   */  @requestmapping("/list")  public map<string, object> replylist(reply reply) {    list<reply> replylist = replyrvice.list(reply);    map<string, object> resultmap = new hashmap<string, object>();    resultmap.put("data", replylist);    return resultmap;  }   /**   * 添加回复   * @param reply   * @return   */  @requestmapping("/add")  public map<string, object> add(reply reply, httpssion ssion) {    ur currentur = (ur) ssion.getattribute("ur");    map<string, object> resultmap = new hashmap<string, object>();    reply.treplydate(new date());    reply.tus淘宝网上购物er(currentur);    replyrvice.add(reply);    resultmap.put("reply", reply);    resultmap.put("success", true);    return resultmap;  } }

管理员业务控制器:

/** * 管理员控制器 * @author yy * */@restcontroller@requestmapping("/admin")public class admincontroller {   @value("${md5salt}")  private string salt; // md5加密盐   @resource  private adminrvice adminrvice;  @resource  private urrvice urrvice;  @resource  private articlervice articlervice;  @resource  private classifyrvice classifyrvice;   /**   * 后台管理员登录验证   * @param admin   * @param request   * @return   */  @requestmapping("/login")  public modelandview login(admin admin, httprvletrequest request) {    modelandview mav = new modelandview();    httpssion ssion = request.getssion();    try {      admin resultur = adminrvice.findbyurnameandpassword(admin.geturname(), admin.getpassword());      if (resultur == null) {        mav.addobject("errorinfo", "用户名或者密码错误!");        mav.tviewname("/login");      } el {        ssion.tattribute("adminur", resultur);        // 统计用户总数        long urcount = urrvice.getcount();        // 统计今天注册        long urregcount = urrvice.gettodayregistcount(new ur(), "1", "1");        // 统计今日登录        long urlogcount = urrvice.getcount(new ur(), "1", "1");        // 统计笔记总数        long artcount = articlervice.getcount();        // 统计笔记分类        long classcount = classifyrvice.getcount();         ssion.tattribute("urcount", urcount);        ssion.tattribute("urregcount", urregcount);        ssion.tattribute("urlogcount", urlogcount);        ssion.tattribute("artcount", artcount);        ssion.tattribute("classcount", classcount);         mav.addobject("success", true);        mav.tviewname("/admin/index");      }    } catch (exception e) { // 用户名密码错误      e.printstacktrace();      mav.addobject("admin", admin);      mav.addobject("errorinfo", "用户名或者密码错误!");      mav.tviewname("/login");    }    ret2013 考研urn mav;  }   /**   * 查看个人信息   *    * @return   */  @requestmapping("viewperson")  public modelandview viewperson(httprvletrequest request) {    admin admin = (admin) request.getssion().getattribute("adminur");    modelandview mav = new modelandview();    admin u = adminrvice.findbyid(admin.getadminid());    mav.addobject("ur", u);    mav.tviewname("/admin/adminviewperson");    return mav;  }   /**   * 保存用户信息   *    * @param ur   * @return   */  @requestmapping("/save")  public modelandview save(admin ur) {    modelandview mav = new modelandview();    adminrvice.save(ur);    mav.tviewname("/admin/index");    return mav;  }}

用户业务控制器:

/** * 用户控制器 * */@restcontroller@requestmapping("/admin/ur")public class uradmincontroller {   @resource  private urrvice urrvice;   @value("${md5salt}")  private string salt; // md5加密盐   /**   * 根据id查找用户   * @param urid   * @return   */  @requestmapping("/findbyid")  public map<string, object> findbyid(integer urid) {    map<string, object> resultmap = new hashmap<string, object>();    ur ur = urrvice.findbyid(urid);    resultmap.put("errorno", 0);    resultmap.put("data", ur);    return resultmap;  }   /**   * 分页查询用户   * @param ur   * @param registrationdates   * @param page   * @param limit   * @return   */  @requestmapping("/list")  public map<string, object> list(ur ur,      @requestparam(value = "latelylogintimes", required = fal) string latelylogintimes,      @requestparam(value = "page", required = fal) integer page,      @requestparam(value = "pagesize", required = fal) integer pagesize) {    string中国十大禁书 s_bregistrationdate = null; // 开始时间    string s_eregistrationdate = null; // 结束时间    if (stringutil.isnotempty(latelylogintimes)) {      string[] strs = latelylogintimes.split(" - "); // 拆分时间段      s_bregistrationdate = strs[0];      s_eregistrationdate = strs[1];    }    list<ur> urlist = urrvice.list(ur, s_bregistrationdate, s_eregistrationdate, page - 1,动车司机 pagesize);    long total = urrvice.getcount(ur, s_bregistrationdate, s_eregistrationdate);    map<string, object> resultmap = new hashmap<string, object>();    resultmap.put("errorno", 0);    resultmap.put("data", urlist);    resultmap.put("total", total);    return resultmap;  }   @requestmapping("/delete")  public map<string, object> delete(integer urid) {    map<string, object> resultmap = new hashmap<string, object>();    urrvice.delete(urid);    resultmap.put("errorno", 0);    return resultmap;  }   /**   * 取消关注   * @param request   * @param urid   * @return   */  @requestmapping("/removefocusur")  public modelandview removefocusur(httprvletrequest request, string urid) {    modelandview mav = new modelandview();    ur ur = (ur) request.getssion().getattribute("ur");// 当前登录用户     string urids = ur.geturids();    list<string> templist = arrays.aslist(urids.split(","));    list<string> lineidlist = new arraylist<>(templist);    lineidlist.remove(urid);    string ret = stringutils.join(lineidlist, ",");     ur.turids(ret);     urrvice.save(ur);    mav.tviewname("redirect:/viewfocusur");    return mav;  }   /**   * 关注用户   * @param request   * @param urid   * @return   */  @requestmapping("/addfocusur")  public modelandview addfocusur(httprvletrequest request, string urid) {    modelandview mav = new modelandview();    ur ur = (ur) request.getssion().getattribute("ur");// 当前登录用户     string urids = ur.geturids();    list<string> templist = arrays.aslist(urids.split(","));    list<string> lineidlist = new arraylist<>(templist);    lineidlist.add(urid);    string ret = stringutils.join(lineidlist, ",");     ur.turids(ret);     urrvice.save(ur);    mav.tviewname("redirect:/viewfocusur");    return mav;  }   @requestmapping("/addfocusur/{urid}")  public modelandview addfocusur(@pathvariable(value = "urid", required = fal) integer urid,      httpssion ssion) {    modelandview mav = new modelandview();    ur ur = (ur) ssion.getattribute("ur");// 当前登录用户     string urids = ur.geturids();    list<string> templist = new arraylist<>();    if (urids != null) {      templist = arrays.aslist(urids.split(","));    }    list<string> lineidlist = new arraylist<>(templist);    lineidlist.add(urid.tostring());    string ret = stringutils.join(lineidlist, ",");     ur.turids(ret);     urrvice.save(ur);    mav.tviewname("redirect:/viewfocusur");    return mav;  }   /**   * 取消收藏   * @param request   * @param urid   * @return   */  @requestmapping("/removecollection")  public modelandview removecollection(httprvletrequest request, string artid) {    modelandview mav = new modelandview();    ur ur = (ur) request.getssion().getattribute("ur");// 当前登录用户     string artids = ur.getarticleids();    list<string> templist = arrays.aslist(artids.split(","));    list<string> lineidlist = new arraylist<>(templist);    lineidlist.remove(artid);    string ret = stringutils.join(lineidlist, ",");     ur.tarticleids(ret);     urrvice.save(ur);    mav.tviewname("redirect:/viewcollection");    return mav;  }   /**   * 收藏   * @param request   * @param urid   * @return   */  @requestmapping("/addcollection")  public modelandview addcollection(httprvletrequest request, string artid) {    modelandview mav = new modelandview();    ur ur = (ur) request.getssion().getattribute("ur");// 当前登录用户     string artids = ur.getarticleids();    list<string> templist = arrays.aslist(artids.split(","));    list<string> lineidlist = new arraylist<>(templist);    lineidlist.add(artid);    string ret = stringutils.join(lineidlist, ",");     ur.tarticleids(ret);     urrvice.save(ur);    mav.tviewname("redirect:/viewcollection");    return mav;  }}

到此这篇关于java毕业设计实战之生活旅行分享平台的实现的文章就介绍到这了,更多相关java 生活旅行分享平台内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!

本文发布于:2023-04-04 21:58:55,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/a8249598390187d16adaaba54ecac62d.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:Java毕业设计实战之生活旅行分享平台的实现.doc

本文 PDF 下载地址:Java毕业设计实战之生活旅行分享平台的实现.pdf

标签:用户   控制器   分页   业务
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图