当前位置:   article > 正文

协同过滤算法|电影推荐系统|基于用户偏好的电影推荐系统设计与开发_基于协同过滤算法的电影推荐系统

基于协同过滤算法的电影推荐系统

作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、Python项目、前端项目、人工智能与大数据、毕业设计、简历模板、学习资料、面试题库、技术互助

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-PT-106

一,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

开发技术:SSM框架+JSP+协同过滤算法+地图定位系统等

二,项目简介

信息技术的应用虽然说带来了很多的便宜,但同时也带了信息和数据的大爆炸。在信息匮乏的时代,人们期望获得更多的信息和数据,以便了解这个世界,但是真正到了数据大爆炸的时代,人们又往往无所适从,不知道怎么才能过滤掉那些对自己无用的数据,获得有效的信息。本次课题所研究的就是基于用户偏好来实抽电影推荐系统,其主要是根据用户在平台上的操作行为记录,来根据设定的相关规则判断用户的喜好,根据协同过滤算法来给用户进行相应的数据推荐。同时在用户无操作数据记录时,也就是常用的数据静默时,也根据相应的规则给用户推荐一些电影数据,以期为用户找到一些对自己有用的数据。

本系统主要基于Java开发技术平台来实现系统的开发,使用了SSM框架来完成电影推荐系统的后台服务接口开发和业务逻辑处理,使用JSP页面完成数据的展示,利用AJAX和JQUERY来实现人机交互的异步数据请求。具体的数据推荐主要使用协同过滤算法的数据模型进行数据推荐。系统整体功能完整,界面美观大方,人机交互效果好。

根据市场调研和用户走访,并进行整理分析,得知本次设计实现的电影推荐系统用户一共有二类,一是前端用户,一类是管理员用户。这二类用户的角色和操作功能权限各不不同,下面通过用例图的方式来进行展示。

前端用户的用例图如下图1所示。

图1 前端用户用例图

前端用户用例描述:前端用户注册登陆后,主要可以实现在线浏览新闻信息、分类浏览电影信息、电影影评信息、用户发布的电影攻略信息,查看推荐的电影信息,在线进行反馈留言,预定电影票等,同时在个人中心处可以发布电影攻略,查看个人的收藏信息、预定信息等。

管理员用户的操作用例图如下图2所示:

图2 管理员用户用例图

管理员用户用例图描述:管理员登陆电影推荐系统,主要的职责是对平台的基础信息进行管理,包含前端注册的用户信息管理、轮播图管理、资讯管理、电影管理、类型管理、电影说评管理、投诉管理、预定订单管理、攻略管理等。

在对整个电影推荐系统做了充分的需求分析和架构设计之后,最终确定了本次开发设计的电影推荐系统要实现的功能目标,下面分别展示一下电影推荐系统的前端用户功能架构和后台管理的功能架构图。前端用户的功能具体展示如下图3所示。

 图3  前端用户功能结构图

前端用户的功能模块介绍:

   (1)注册登录功能模块设计

 前端用户进行相关操作时需要进行注册线上会员,填写个人账户信息和个人信息后注册成功后即可登陆。

   (2)个人信息管理功能模块设计

用户登录系统后,可以进入系统管理来修改密码,输入旧密码、新密码并确认密码,保证新密码和确认密码一致的情况下则修改成功,如果不一致则就修改失败。

   (3)信息浏览功能模块

前端用户可以在电影平台上浏览电影信息、相关电影说评信息、电影攻略信息、行业资讯信息等,可以查看具体各类信息的详情,并可以在线评论,对于喜欢的电影或电影说评,可以进行收藏。

   (4)在线预定功能模块

前端用户登陆后,进入电影介绍的详情页面,可以点击预定按钮,在线预定电影,并可以在个人中心中管理自己预定的电影,待后台管理员审核通过后即算预定成功。

   (5)电影攻略模块

用户可以在线进行发贴,书写自己所观看的电影的感受,或某个电影的攻略信息,并可以在线管理自己的贴子。

   (6)个性化推荐模块

电影管理平台系统,会根据用户的浏览记录,进行相关的计算,采用协同过滤算法来给不同的用户进行相应的信息推荐,目前的数据模型主要是依据用户浏览的电影特点,匹配相关性的电影信息,在首页推荐模块进行推荐展示。

   (7)全文检索模块

    在电影管理平台系统中,前端用户可以根据相关的关键词来进行搜索,会全文匹配电影信息,电影说评信息等,根据标题说明来进行模糊匹配,将查找到的信息展现出来。

   (8)投诉建议

除了提供用户的在线评论和收藏等互动功能外,还提供了投诉建议模块,以便用户及时反馈相关的意见,由后台管理员进行处理。

后端用户的功能模块介绍:

   (1)个人信息管理:管理员登陆后台可以对个人的信息进行相应的管理操作。

   (2)用户管理:管理员可以对前端注册的用户信息进行相应的管理操作。

   (3)轮播图管理:对前端首页的轮播图信息进行相应的管理操作,可根据需求进行轮播图的更换等。

   (4)行业资讯管理:主要管理和发布电影行业的相关动态新闻信息。

   (5)电影管理:主要管理发布的电影信息,详细的介绍电影的价格,特点等,并在后台指定电影所放映的影院地图定位坐标,这使得前端用户可以直接通过百度地图定位电影院所在位置。

   (6)电影说评管理:主要管理电影附近的相关电影说评信息,完成电影说评信息的增删改查操作。

   (7)订单管理:主要管理前端用户的下单信息,前端会员预定电影后,需要管理员在后台进行审核,生效后方可使用。

   (8)攻略管理:主要管理前端电影会员用户发布和电影攻略信息。

   (9)投诉建议:对前端用户发布的投诉建议信息进行相关的管理操作。

三,系统展示

3.1前台功能模块的展示

3.1.1 注册登陆

电影推荐系统为前端用户提供了注册和登陆的基本功能,这也是为了确保用户进行在线预定等的数据安全和数据的对应,用户登陆的基本流程如下图3.1所示。

 

图3.1 登陆流程图

用户登陆的操作界面如下图5.2所示:

 

图3.2 用户登陆

登陆的前提是要有注册的账户信息,用户注册的基本流程如下图3.3所示:

 

图3.3 前端用户注册流程图

 电影推荐系统的前端用户注册的界面如下图3.4所示:

 

图3.4 前端用户注册界面

3.1.2 电影分类浏览

用户登陆系统后可以在线查看发布的电影信息,平台提供了按电影名称进行全局搜索的操作,同时可以根据电影类型分类查询,具体展示如下图35所示。

图3.5 电影分类浏览

   用户点击感兴趣的电影后会进入电影的详情界面,在电影的详情里可以查看这部电影相关具体的信息(导演、编剧、主演、简介等),还可以进行在线预定、收藏、评论留言等互动操作,具体如下图3.6所示。

 图3.6 电影详情浏览

3.1.3 电影推荐

 用户登陆系统后,系统可以根据用户的一些操作行为数据记录并基于系统所用的协同过滤算法功能来为用户推荐相关的电影信息并直接在系统的首页进行展示,具体展示如图3.7所示。

 

图3.7 电影推荐

3.1.4 行业新闻浏览

用户登陆系统后可以点击博客文章进入博客模块,用户可以在线查看用户发布的博客信息,具体展示如下图4.8所示。

 

图3.8 电影新闻浏览

3.1.5 观影攻略

用户登陆系统后可以点击电影攻略,查看每个用户分享的电影攻略信息,用户可以自己在平台发布每个电影观看的攻略详情,具体展示如下图3.9所示。

 

图3.9 电影攻略

 3.1.6 电影说评

电影说评主要展示一些名人大伽对于电影的一些评析信息,用户在些模块可以进行查看,电影说评具体实现具体如下图3.10所示。

 

图3.10 个人信息管理

四,核心代码展示

  1. package com.sys.controller.admin;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import java.util.TreeSet;
  6. import javax.servlet.http.HttpServletRequest;
  7. import org.springframework.http.ResponseEntity;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.ui.Model;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import com.sys.controller.MyController;
  12. import com.sys.controller.suanfa.Aprioti;
  13. import com.sys.controller.suanfa.Itemset;
  14. import com.sys.controller.xietong.XietongUtil;
  15. import com.sxl.util.RandomValidateCode;
  16. import com.sxl.util.StringHelper;
  17. @Controller("frontController")
  18. @RequestMapping(value = "/front")
  19. public class FrontController extends MyController {
  20. /**
  21. * 使用协同过滤算法进行相关推荐
  22. * @param model
  23. * @param request
  24. * @return
  25. * @throws Exception
  26. */
  27. @RequestMapping(value = "/index")
  28. public String frame(Model model, HttpServletRequest request)
  29. throws Exception {
  30. String sql = "";
  31. sql = "select * from t_lbt";
  32. List list3 = db.queryForList(sql);
  33. request.setAttribute("list3", list3);
  34. sql = "select a.* from t_product a where typesId=1 order by id desc limit 3";
  35. List listb = db.queryForList(sql);
  36. request.setAttribute("listb", listb);
  37. //查询电影类型
  38. sql = "select * from t_types";
  39. model.addAttribute("typesList", db.queryForList(sql));
  40. //协同过滤推荐算法
  41. if(getCustomer(request)!=null){
  42. //如果该用户登录了,身份确定了, 则可以用协同过滤推荐
  43. List<Map> customerList = db.queryForList("select * from t_customer");
  44. List<Map> dataList = db.queryForList("select distinct productId, customerId from t_productclick where productId is not null and customerId is not null ");
  45. int usersize = customerList.size();
  46. String customerId = getCustomer(request).get("id").toString();
  47. /**
  48. * 输入用户-->物品条目 一个用户对应多个物品
  49. * 用户ID 物品ID集合
  50. * A a b d
  51. * B a c
  52. * C b e
  53. * D c d e
  54. */
  55. String[] userdata = new String[customerList.size()];
  56. for (int i = 0; i < customerList.size(); i++) {
  57. String customerid = customerList.get(i).get("id").toString();
  58. String aa="A"+customerid+"";
  59. for (int j = 0; j < dataList.size(); j++) {
  60. if(customerid.equals(dataList.get(j).get("customerId").toString())){
  61. aa+="@"+dataList.get(j).get("productId").toString();
  62. }
  63. }
  64. userdata[i]= aa+="@0";
  65. System.out.println("******"+aa);
  66. }
  67. String out = XietongUtil.xietongjob(usersize, userdata, "A"+customerId);
  68. String sqlall="select a.* from t_product a where typesId=1 ";
  69. sql=sqlall;
  70. if(out!=null&&!"".equals(out)){
  71. sql+=" and id in ("+out.substring(1,out.length())+")";
  72. }
  73. sql+=" order by rand() limit 8 ";
  74. //以上推荐算法最总结果在根据随机安排推荐
  75. //注!为了应对一开始人员访问数据量不够推荐算法使用的情况,就进行了数据补足,这个业务逻辑就非常完美了。
  76. List tuijianList = db.queryForList(sql);
  77. int a = 8;
  78. int b = 0;
  79. if(tuijianList==null||tuijianList.size()<8){
  80. if(tuijianList!=null){
  81. b = 8-tuijianList.size();
  82. }
  83. List list2 = db.queryForList(sqlall+" order by rand() limit "+b);
  84. tuijianList.addAll(list2);
  85. }else{
  86. }
  87. request.setAttribute("tuijianList", tuijianList);
  88. }else{
  89. //也就是说,如果网站用户未登录,则不能身份确认,所以用aprio算法
  90. //aprio推荐算法
  91. tuijiansuanfa(request);
  92. }
  93. return "/front/index";
  94. }
  95. /**
  96. * 专门有个算法包
  97. * 然后算法的逻辑也在这里,
  98. * 而且把算法之外额逻辑也加了
  99. * 注!为了应对一开始人员访问数据量不够推荐算法使用的情况,就进行了数据补足,这个业务逻辑就非常完美了。
  100. *
  101. * java推荐算法
  102. * @param request
  103. */
  104. public void tuijiansuanfa(HttpServletRequest request){
  105. Itemset originalItem = new Itemset();
  106. List<Map> lista = db.queryForList("select * from t_customer");
  107. for (int i = 0; i < lista.size(); i++) {
  108. TreeSet<String> itemset = new TreeSet<String>();
  109. List<Map> listb = db.queryForList("select * from t_productclick where customerId=?",new Object[]{lista.get(i).get("id")});
  110. for (int j = 0; j < listb.size(); j++) {
  111. itemset.add(listb.get(j).get("productId")+"");
  112. }
  113. originalItem.itemset.add(itemset);
  114. }
  115. Aprioti.originalItem=originalItem;
  116. List<Long> outList = Aprioti.aprioriProcess();
  117. String in ="";
  118. if(outList!=null&&outList.size()>0){
  119. for (int i = 0; i < outList.size(); i++) {
  120. in+=","+outList.get(i);
  121. }
  122. }
  123. String sqlall="select a.* from t_product a where 1=1 ";
  124. String sql=sqlall;
  125. if(in!=null&&!"".equals(in)){
  126. sql+=" and id in ("+in.substring(1,in.length())+")";
  127. }
  128. sql+=" order by rand() limit 8 ";
  129. //以上推荐算法最总结果在根据随机安排推荐
  130. //注!为了应对一开始人员访问数据量不够推荐算法使用的情况,就进行了数据补足,这个业务逻辑就非常完美了。
  131. List tuijianList = db.queryForList(sql);
  132. int a = 8;
  133. int b = 0;
  134. if(tuijianList==null||tuijianList.size()<8){
  135. if(tuijianList!=null){
  136. b = 8-tuijianList.size();
  137. }
  138. List list2 = db.queryForList(sqlall+" order by rand() limit "+b);
  139. tuijianList.addAll(list2);
  140. }else{
  141. }
  142. request.setAttribute("tuijianList", tuijianList);
  143. }
  144. @RequestMapping(value = "/baidu1")
  145. public String baidu1(Model model, HttpServletRequest request)
  146. throws Exception {
  147. return "/front/baidu1";
  148. }
  149. @RequestMapping(value = "/baidu2")
  150. public String baidu2(Model model, HttpServletRequest request)
  151. throws Exception {
  152. return "/front/baidu2";
  153. }
  154. @RequestMapping(value = "/daohang1")
  155. public String daohang1(Model model, HttpServletRequest request,String id)
  156. throws Exception {
  157. Map map = db.queryForMap("select * from t_product where id="+id);
  158. model.addAttribute("map", map);
  159. return "/front/daohang1";
  160. }
  161. public String getjwd(HttpServletRequest request){
  162. Object jwdd= request.getSession().getAttribute("yhjwd");
  163. if(jwdd!=null){
  164. return jwdd.toString();
  165. }else{
  166. return "116.438189,39.9125";
  167. }
  168. }
  169. @RequestMapping(value = "/daohang2")
  170. public String daohang2(Model model, HttpServletRequest request,String id)
  171. throws Exception {
  172. Map map = db.queryForMap("select *from t_zx where id="+id);
  173. map = new HashMap();
  174. map.put("jwd", "116.661256,39.975119");
  175. model.addAttribute("map", map);
  176. String jwd = getjwd(request);
  177. System.out.println(jwd);
  178. System.out.println(map.get("jwd"));
  179. model.addAttribute("jwd", jwd);
  180. return "/front/daohang2";
  181. }
  182. @RequestMapping(value = "/login")
  183. public String login(Model model, HttpServletRequest request)
  184. throws Exception {
  185. return "/front/login";
  186. }
  187. public void saveClick(HttpServletRequest request,Long id){
  188. String sql="insert into t_productclick(productId,customerId,insertDate) values(?,?,now())";
  189. Map customer = getCustomer(request);
  190. if(customer!=null&&customer.size()>0){
  191. db.update(sql, new Object[]{id,getCustomer(request).get("id")});
  192. }
  193. }
  194. /**
  195. * 查询信息
  196. * @param model
  197. * @param request
  198. * @param typesId
  199. * @param productName
  200. * @param px
  201. * @return
  202. * @throws Exception
  203. */
  204. @RequestMapping(value = "/all")
  205. public String all(Model model, HttpServletRequest request,Long typesId,String productName,String px,Integer bqid)
  206. throws Exception {
  207. String sql="select a.* from t_types a where 1=1";
  208. sql+=" order by id desc";
  209. List typesList = db.queryForList(sql);
  210. request.setAttribute("typesList", typesList);
  211. sql="select a.*,(select typesName from t_types b where a.typesId=b.id) typesName from t_product a where 1=1";
  212. if(typesId!=null&&!"".equals(typesId)){
  213. sql+=" and a.typesId="+typesId;
  214. }
  215. if(productName!=null&&!"".equals(productName)){
  216. sql+=" and a.productName like '%"+productName+"%' ";
  217. }
  218. if(bqid!=null){
  219. sql+=" and bqid="+bqid;
  220. }
  221. if("1".equals(px)){
  222. sql+=" order by id desc";
  223. }else if("2".equals(px)){
  224. sql+=" order by price asc";
  225. }else if("3".equals(px)){
  226. sql+=" order by price desc";
  227. }else if("4".equals(px)){
  228. sql+=" order by djl desc";
  229. }
  230. List list = db.queryForList(sql);
  231. request.setAttribute("list", list);
  232. return "/front/all";
  233. }
  234. @RequestMapping(value = "/jfdh")
  235. public String jfdh(Model model, HttpServletRequest request)
  236. throws Exception {
  237. String sql="select a.* from t_jfdh a where 1=1";
  238. sql+=" order by id desc";
  239. List list = db.queryForList(sql);
  240. request.setAttribute("list", list);
  241. return "/front/jfdh";
  242. }
  243. @RequestMapping(value = "/dhjfSave")
  244. public ResponseEntity<String> dhjfSave(Model model,
  245. HttpServletRequest request,Long id) throws Exception {
  246. Map map = db.queryForMap("select * from t_jfdh where id="+id);
  247. String jf = map.get("jfCost").toString();
  248. String jfName = map.get("jfName").toString();
  249. //订单
  250. String sql = "insert into t_order(orderNum,customerId,productDetail,allPrice,status,insertDate) values(?,?,?,?,?,now())";
  251. int result = db.update(sql, new Object[] { System.currentTimeMillis()+"",
  252. getCustomer(request).get("id").toString(), jfName+"积分兑换["+jf+"]", 0+"", "兑换完成" });
  253. sql="update t_customer set jf = jf-"+jf+" where id="+getCustomer(request).get("id");
  254. db.update(sql);
  255. //积分减少
  256. return renderData(true, "操作成功", null);
  257. }
  258. @RequestMapping(value = "/register")
  259. public String register(Model model, HttpServletRequest request)
  260. throws Exception {
  261. System.out.println("112312312");
  262. return "/front/register";
  263. }
  264. @RequestMapping(value = "/detail")
  265. public String detail(Model model, HttpServletRequest request, Long id)
  266. throws Exception {
  267. //保存点击
  268. saveClick(request, id);
  269. String sql = "select a.*,(select typesName from t_types b where a.typesId=b.id) typesName " +
  270. " from t_product a where id=" + id;
  271. Map map = db.queryForMap(sql);
  272. request.setAttribute("map", map);
  273. String sql2="select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName from t_pinglun_product a where productId=? order by id desc";
  274. List<Map> list = db.queryForList(sql2,new Object[]{id});
  275. model.addAttribute("list", list);
  276. db.update("update t_product set djl=djl+1 where id="+id);
  277. int scNum = db.queryForInt("select count(1) from t_sc where productId="+id);
  278. model.addAttribute("scNum", scNum);
  279. return "/front/detail";
  280. }
  281. @RequestMapping(value = "/myOrder")
  282. public String myOrder(Model model, HttpServletRequest request)
  283. throws Exception {
  284. String sql = "select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName from t_order a where 1=1 ";
  285. if (1 == 1) {
  286. sql += "and customerId=" + getCustomer(request).get("id") + " ";
  287. }
  288. sql += " order by id desc";
  289. List list = db.queryForList(sql);
  290. request.setAttribute("orderList", list);
  291. return "/front/myOrder";
  292. }
  293. @RequestMapping(value = "/deleteOneOrder")
  294. public ResponseEntity<String> deleteOneOrder(Model model,
  295. HttpServletRequest request,Long id) throws Exception {
  296. String sql="delete from t_order where id="+id;
  297. db.update(sql);
  298. return renderData(true, "操作成功", null);
  299. }
  300. @RequestMapping(value = "/pjSave")
  301. public ResponseEntity<String> pjSave(Model model,
  302. HttpServletRequest request,Long id,String pj) throws Exception {
  303. String sql="update t_order set pj='"+pj+"' where id="+id;
  304. db.update(sql);
  305. return renderData(true, "操作成功", null);
  306. }
  307. @RequestMapping(value = "/deletesc")
  308. public ResponseEntity<String> deletesc(Model model,
  309. HttpServletRequest request,Long id) throws Exception {
  310. String sql="delete from t_sc where id="+id;
  311. db.update(sql);
  312. return renderData(true, "操作成功", null);
  313. }
  314. @RequestMapping(value = "/deletexiaoxi")
  315. public ResponseEntity<String> deletexiaoxi(Model model,
  316. HttpServletRequest request,Long id) throws Exception {
  317. String sql="delete from t_xiaoxi where id="+id;
  318. db.update(sql);
  319. return renderData(true, "操作成功", null);
  320. }
  321. @RequestMapping(value = "/addShopcar")
  322. public ResponseEntity<String> addShopcar(Model model,
  323. HttpServletRequest request, Long id, Integer num) throws Exception {
  324. int result = 0;
  325. db.update("delete from t_shopcar where customerId="+getCustomer(request).get("id"));
  326. String sql = "insert into t_shopcar(productId,num,customerId) values(?,?,?)";
  327. result = db.update(sql, new Object[] { id, 1,
  328. getCustomer(request).get("id").toString() });
  329. return renderData(true, "操作成功", null);
  330. }
  331. @RequestMapping(value = "/pay3")
  332. public ResponseEntity<String> pay3(Model model, HttpServletRequest request,Long address)
  333. throws Exception {
  334. String sql = "select a.*,(select productName from t_product b where a.productId=b.id) productName,"
  335. + "(select price from t_product b where a.productId=b.id) price,(select jf from t_product b where a.productId=b.id) jf from t_shopcar a where customerId="
  336. + getCustomer(request).get("id");
  337. sql += " order by id desc";
  338. List<Map> list = db.queryForList(sql);
  339. int total = 0;
  340. int jf = 0;
  341. String productDetail = "";
  342. String productId="";
  343. for (int i = 0; i < list.size(); i++) {
  344. productId = list.get(i).get("productId").toString();
  345. productDetail += "," + list.get(i).get("productName") + "["
  346. + list.get(i).get("num") + "]";
  347. total += Integer.parseInt(list.get(i).get("price").toString())
  348. * Integer.parseInt(list.get(i).get("num").toString());
  349. // jf+=Integer.parseInt(list.get(i).get("jf").toString())
  350. // * Integer.parseInt(list.get(i).get("num").toString());
  351. String sql2="update t_product set nums=nums-"+list.get(i).get("num").toString()+" where id="+list.get(i).get("productId").toString();
  352. db.update(sql2);
  353. }
  354. Map addressMap = db.queryForMap("select * from t_address where id=?",new Object[]{address});
  355. sql = "insert into t_order(orderNum,customerId,productDetail,allPrice,status,insertDate,lxr,lxfs,address,productId) values(?,?,?,?,?,now(),?,?,?,?)";
  356. int result = db.update(sql, new Object[] { System.currentTimeMillis()+"",
  357. getCustomer(request).get("id").toString(), productDetail.subSequence(1, productDetail.length()), total+"", "等待处理",addressMap.get("lxr"),addressMap.get("phone"),addressMap.get("xxdz"),productId });
  358. sql = "delete from t_shopcar where customerId="
  359. + getCustomer(request).get("id");
  360. db.update(sql);
  361. if (result == 1) {
  362. return renderData(true, "操作成功", null);
  363. } else {
  364. return renderData(false, "操作失败", null);
  365. }
  366. }
  367. // @RequestMapping(value = "/addShopcar")
  368. // public ResponseEntity<String> addShopcar(Model model,
  369. // HttpServletRequest request, Long id, Integer num) throws Exception {
  370. // int result = 0;
  371. // // 判断该用户是否
  372. // String sql = "select * from t_shopcar where productId=? and customerId=?";
  373. // Map map = db.queryForMap(sql, new Object[] { id.toString(),
  374. // getCustomer(request).get("id").toString() });
  375. // if (map != null && map.size() > 0) {
  376. // sql = "update t_shopcar set productId=?,num=num+" + num
  377. // + " where id=?";
  378. // result = db.update(sql, new Object[] { id, map.get("id") });
  379. // } else {
  380. // sql = "insert into t_shopcar(productId,num,customerId) values(?,?,?)";
  381. // result = db.update(sql, new Object[] { id, num,
  382. // getCustomer(request).get("id").toString() });
  383. // }
  384. // if (result == 1) {
  385. // return renderData(true, "操作成功", null);
  386. // } else {
  387. // return renderData(false, "操作失败", null);
  388. // }
  389. // }
  390. @RequestMapping(value = "/checkIsLogin")
  391. public ResponseEntity<String> checkIsLogin(Model model,
  392. HttpServletRequest request) throws Exception {
  393. Map customer = getCustomer(request);
  394. if (customer != null && customer.size() > 0) {
  395. return renderData(true, "操作成功", null);
  396. } else {
  397. return renderData(false, "操作失败", null);
  398. }
  399. }
  400. @RequestMapping(value = "/pay")
  401. public ResponseEntity<String> pay(Model model, HttpServletRequest request,Long address)
  402. throws Exception {
  403. String orderDate = request.getParameter("orderDate");
  404. String zffs = request.getParameter("zffs");
  405. String sql = "select a.*,(select productName from t_product b where a.productId=b.id) productName,"
  406. + "(select price from t_product b where a.productId=b.id) price,(select jf from t_product b where a.productId=b.id) jf from t_shopcar a where customerId="
  407. + getCustomer(request).get("id");
  408. sql += " order by id desc";
  409. List<Map> list = db.queryForList(sql);
  410. int total = 0;
  411. int jf = 0;
  412. String productDetail = "";
  413. String productId="";
  414. for (int i = 0; i < list.size(); i++) {
  415. productId = list.get(i).get("productId").toString();
  416. productDetail = list.get(i).get("productName").toString() ;
  417. sql = "insert into t_order(orderNum,customerId,productDetail,allPrice,status,insertDate,lxr,lxfs,address,productId,orderDate,zffs) values(?,?,?,?,?,now(),?,?,?,?,?,?)";
  418. db.update(sql, new Object[] { System.currentTimeMillis()+"",
  419. getCustomer(request).get("id").toString(), productDetail, list.get(i).get("price").toString()+"", "等待处理",null,null,null,productId ,orderDate,zffs});
  420. }
  421. sql = "delete from t_shopcar where customerId="
  422. + getCustomer(request).get("id");
  423. db.update(sql);
  424. return renderData(true, "操作成功", null);
  425. }
  426. @RequestMapping(value = "/shopcar")
  427. public String shopcar(Model model, HttpServletRequest request)
  428. throws Exception {
  429. Map customer = getCustomer(request);
  430. if (customer != null && customer.size() > 0) {
  431. } else {
  432. return "redirect:/front/register.html";
  433. }
  434. String sql="select a.* from t_address a where 1=1";
  435. if(1==1){sql+=" and customerId="+getCustomer(request).get("id") +" ";}
  436. sql+=" order by id desc";
  437. List addressList = db.queryForList(sql);
  438. request.setAttribute("addressList", addressList);
  439. sql = "select b.*,a.id ids,a.num num from t_shopcar a left join t_product b on a.productId=b.id where 1=1 and customerId="
  440. + getCustomer(request).get("id");
  441. sql += " order by id desc";
  442. System.out.println(sql);
  443. List<Map> list = db.queryForList(sql);
  444. request.setAttribute("list", list);
  445. System.out.println(list);
  446. int total = 0;
  447. if(list!=null&&list.size()>0){
  448. for (int i = 0; i < list.size(); i++) {
  449. total += Integer.parseInt(list.get(i).get("price").toString())
  450. * Integer.parseInt(list.get(i).get("num").toString());
  451. }
  452. }
  453. request.setAttribute("total", total);
  454. return "/front/shopcar";
  455. }
  456. @RequestMapping(value = "/save")
  457. public ResponseEntity<String> loginSave(Model model,
  458. HttpServletRequest request, String username, String password)
  459. throws Exception {
  460. String sql = "select * from t_customer where username=?";
  461. List<Map> list = db.queryForList(sql, new Object[] { username });
  462. String result = "1";
  463. if (list != null && list.size() > 0) {
  464. Map map = list.get(0);
  465. if (StringHelper.get(map, "password").equals(password)) {
  466. request.getSession().setMaxInactiveInterval(60 * 60 * 24);
  467. request.getSession().setAttribute("customerBean", map);
  468. result = "1";
  469. } else {
  470. result = "0";
  471. }
  472. } else {
  473. result = "0";
  474. }
  475. return renderData(true, result, null);
  476. }
  477. @RequestMapping(value = "/deleteOneShopCar")
  478. public ResponseEntity<String> deleteOneShopCar(Model model,
  479. HttpServletRequest request,Long id)
  480. throws Exception {
  481. String sql="delete from t_shopcar where id="+id;
  482. db.update(sql);
  483. return renderData(true, "", null);
  484. }
  485. @RequestMapping(value = "/updateShopCar")
  486. public ResponseEntity<String> updateShopCar(Model model,
  487. HttpServletRequest request,Long id,Integer num)
  488. throws Exception {
  489. String sql="update t_shopcar set num="+num+" where id="+id;
  490. System.out.println(sql);
  491. db.update(sql);
  492. return renderData(true, "", null);
  493. }
  494. @RequestMapping(value = "/registerSave")
  495. public ResponseEntity<String> registerSave(Model model,
  496. HttpServletRequest request, Long id, String username,
  497. String password, String customerName, String sex, String address,String headPic,
  498. String phone) throws Exception {
  499. String yzm = request.getParameter("yzm");
  500. String yzmnow = request.getSession().getAttribute(RandomValidateCode.RANDOMCODEKEY).toString().toUpperCase();
  501. if(!yzmnow.equals(yzm.toUpperCase())){
  502. return renderData(false, "5", null);
  503. }
  504. int a = db.queryForInt("select count(1) from t_customer where username=?",new Object[]{username});
  505. if(a>0){
  506. return renderData(false, "1", null);
  507. }
  508. int result = 0;
  509. if(headPic==null||"".equals(headPic)){
  510. headPic ="resource/front4/123.jpg";
  511. }
  512. String sql = "insert into t_customer(username,password,customerName,sex,address,phone,headPic) values(?,?,?,?,?,?,?)";
  513. result = db.update(sql, new Object[] { username, password, customerName, sex,
  514. address, phone,headPic });
  515. sql = "select * from t_customer order by id desc limit 1";
  516. List<Map> list = db.queryForList(sql);
  517. request.getSession().setMaxInactiveInterval(60 * 60 * 24);
  518. request.getSession().setAttribute("customerBean", list.get(0));
  519. return renderData(true, "操作成功", null);
  520. }
  521. @RequestMapping(value = "/out")
  522. public String out(Model model, HttpServletRequest request) throws Exception {
  523. request.getSession().removeAttribute("customerBean");
  524. return "redirect:/front/login.html";
  525. }
  526. @RequestMapping(value = "/mine")
  527. public String mine(Model model, HttpServletRequest request)
  528. throws Exception {
  529. Map customer = getCustomer(request);
  530. Map map = db.queryForMap("select * from t_customer where id=?",
  531. new Object[] { customer.get("id") });
  532. model.addAttribute("customer", map);
  533. return "/front/mine";
  534. }
  535. @RequestMapping(value = "/mineSave")
  536. public ResponseEntity<String> mineSave(Model model,
  537. HttpServletRequest request, Long id, String username,
  538. String password, String customerName, String sex, String address,String headPic,
  539. String phone) throws Exception {
  540. int result = 0;
  541. String sql = "update t_customer set customerName=?,sex=?,address=?,phone=?,headPic=? where id=?";
  542. result = db.update(sql, new Object[] { customerName, sex, address, phone,headPic, id });
  543. sql = "select * from t_customer where id="+id;
  544. List<Map> list = db.queryForList(sql);
  545. request.getSession().setMaxInactiveInterval(60 * 60 * 24);
  546. request.getSession().setAttribute("customerBean", list.get(0));
  547. return renderData(true, "操作成功", null);
  548. }
  549. @RequestMapping(value = "/password")
  550. public String password(Model model, HttpServletRequest request)
  551. throws Exception {
  552. return "/front/password";
  553. }
  554. @RequestMapping(value = "/changePassword")
  555. public ResponseEntity<String> changePassword(Model model,
  556. HttpServletRequest request, String oldPassword, String newPassword)
  557. throws Exception {
  558. Map customer = getCustomer(request);
  559. if (oldPassword.equals(customer.get("password").toString())) {
  560. String sql = "update t_customer set password=? where id=?";
  561. db.update(sql, new Object[] { newPassword, customer.get("id") });
  562. return renderData(true, "1", null);
  563. } else {
  564. return renderData(false, "1", null);
  565. }
  566. }
  567. @RequestMapping(value = "/scSave")
  568. public ResponseEntity<String> scSave(Model model,
  569. HttpServletRequest request, Long id, String pl) throws Exception {
  570. int result = 0;
  571. String customerId = getCustomer(request).get("id").toString();
  572. db.update("delete from t_sc where productId=? and customerId=? ", new Object[] {id,customerId });
  573. String sql = "insert into t_sc(productId,customerId,insertDate) values(?,?,now())";
  574. result = db.update(sql, new Object[] {id,customerId });
  575. return renderData(true, "操作成功", null);
  576. }
  577. @RequestMapping(value = "/plSave")
  578. public ResponseEntity<String> plSave(Model model,
  579. HttpServletRequest request, Long id, String pl) throws Exception {
  580. int result = 0;
  581. String sql = "update t_order set pl=? where id=?";
  582. result = db.update(sql, new Object[] { pl, id });
  583. if (result == 1) {
  584. return renderData(true, "操作成功", null);
  585. } else {
  586. return renderData(false, "操作失败", null);
  587. }
  588. }
  589. @RequestMapping(value = "/contact")
  590. public String fk(Model model, HttpServletRequest request) throws Exception {
  591. return "/front/contact";
  592. }
  593. @RequestMapping(value = "/contactSave")
  594. public ResponseEntity<String> contactSave(Model model,
  595. HttpServletRequest request, String content, String phone)
  596. throws Exception {
  597. int result = 0;
  598. String sql = "insert into t_contact(customerId,phone,content,insertDate) values(?,?,?,now())";
  599. result = db.update(sql, new Object[] { getCustomer(request).get("id"),
  600. phone, content });
  601. if (result == 1) {
  602. return renderData(true, "操作成功", null);
  603. } else {
  604. return renderData(false, "操作失败", null);
  605. }
  606. }
  607. @RequestMapping(value = "/message")
  608. public String message(Model model, HttpServletRequest request)
  609. throws Exception {
  610. String sql = "select a.*,(select max(name) from t_customer b where a.customerId=b.id) customerName from t_message a where 1=1 ";
  611. sql += " and customerId=" + getCustomer(request).get("id") + " ";
  612. sql += " order by id desc";
  613. List list = db.queryForList(sql);
  614. request.setAttribute("list", list);
  615. System.out.println(list);
  616. return "/front/message";
  617. }
  618. @RequestMapping(value = "/saveMessageContent")
  619. public ResponseEntity<String> saveMessageContent(Model model,
  620. HttpServletRequest request, String messageContent) throws Exception {
  621. Map customer = getCustomer(request);
  622. String sql = "insert into t_message(customerId,messageContent,insertDate,types) values(?,?,now(),1)";//1代表我
  623. int result = db
  624. .update(sql, new Object[] { getCustomer(request).get("id"),
  625. messageContent });
  626. return renderData(true, "1", null);
  627. }
  628. ///前端增删改查例子开始//
  629. @RequestMapping(value = "/test")
  630. public String test(Model model, HttpServletRequest request,String flag,String testName)throws Exception {
  631. String sql="select a.*,(select max(name) from t_customer b where a.customerId=b.id) customerName from t_test a where 1=1";
  632. if(testName!=null&&!"".equals(testName)){
  633. sql+=" and testName like '%"+testName+"%' ";
  634. }
  635. sql+=" and customerId="+getCustomer(request).get("id");
  636. sql+=" order by id desc";
  637. List list = db.queryForList(sql);
  638. request.setAttribute("list", list);
  639. return "/front/test";
  640. }
  641. @RequestMapping(value = "/testaddSave")
  642. public ResponseEntity<String> testaddSave(Model model,HttpServletRequest request,Long id,String flag
  643. ,Integer customerId,String testName,String testContent,String testSex,String testDay,String testPic,String insertDate) throws Exception{
  644. int result = 0;
  645. if(id!=null){
  646. String sql="update t_test set testName=?,testContent=?,testSex=?,testDay=?,testPic=? where id=?";
  647. result = db.update(sql, new Object[]{testName,testContent,testSex,testDay,testPic,id});
  648. }else{
  649. String sql="insert into t_test(customerId,testName,testContent,testSex,testDay,testPic,insertDate) values(?,?,?,?,?,?,now())";
  650. result = db.update(sql, new Object[]{getCustomer(request).get("id"),testName,testContent,testSex,testDay,testPic});
  651. }
  652. if(result==1){
  653. return renderData(true,"操作成功",null);
  654. }else{
  655. return renderData(false,"操作失败",null);
  656. }
  657. }
  658. @RequestMapping(value = "/testDelete")
  659. public ResponseEntity<String> testDelete(Model model,HttpServletRequest request,Long id,String flag) throws Exception {
  660. String sql="delete from t_test where id=?";
  661. int result = db.update(sql, new Object[]{id});
  662. if(result==1){
  663. return renderData(true,"操作成功",null);
  664. }else{
  665. return renderData(false,"操作失败",null);
  666. }
  667. }
  668. @RequestMapping(value = "/testadd")
  669. public String testadd(Model model, HttpServletRequest request,Long id,String flag)throws Exception {
  670. if(id!=null){
  671. //修改
  672. String sql="select * from t_test where id=?";
  673. Map map = db.queryForMap(sql,new Object[]{id});
  674. model.addAttribute("map", map);
  675. }String sql="";
  676. return "/front/testadd";
  677. }
  678. ///前端增删改查例子结束/
  679. @RequestMapping(value = "/find")
  680. public String find(Model model, HttpServletRequest request)
  681. throws Exception {
  682. return "/front/find";
  683. }
  684. @RequestMapping(value = "/findSave")
  685. public ResponseEntity<String> findSave(Model model,
  686. HttpServletRequest request, String username, String phone)
  687. throws Exception {
  688. String sql = "select * from t_customer where username=? and phone=?";
  689. List<Map> list = db.queryForList(sql, new Object[] { username,phone });
  690. System.out.println(list);
  691. String result = "1";
  692. if (list != null && list.size() > 0) {
  693. Map map = list.get(0);
  694. return renderData(true, result, null);
  695. } else {
  696. return renderData(false, result, null);
  697. }
  698. }
  699. @RequestMapping(value = "/findSaveConfirm")
  700. public ResponseEntity<String> findSaveConfirm(Model model,
  701. HttpServletRequest request, String username, String phone,String password)
  702. throws Exception {
  703. String sql = "update t_customer set password=? where username=? and phone=?";
  704. db.update(sql, new Object[] {password, username,phone });
  705. return renderData(true, "", null);
  706. }
  707. @RequestMapping(value = "/lt")
  708. public String lt(Model model, HttpServletRequest request,String searchName,Long oneClassifyId)
  709. throws Exception {
  710. Map customer = getCustomer(request);
  711. String sql="select a.*,(select max(customerName) from t_customer b where b.id=a.customerId) customerName," +
  712. "(select count(1) from t_pinglun b where b.wdxxId=a.id) nums from t_wdxx a where 1=1 ";
  713. if(searchName !=null&&!"".equals(searchName)){
  714. sql+=" and a.title like '%"+searchName+"%'";
  715. }
  716. if(customer==null||customer.size()==0){
  717. sql+=" and a.nologin='是' ";
  718. }
  719. sql+=" order by id desc";
  720. List<Map> list = db.queryForList(sql);
  721. model.addAttribute("list", list);
  722. return "/front/lt";
  723. }
  724. @RequestMapping(value = "/wdxxList")
  725. public String wdxxList(Model model, HttpServletRequest request,String flag,String title)throws Exception {
  726. String sql="select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName from t_wdxx a where 1=1";
  727. if(1==1){sql+=" and customerId="+getCustomer(request).get("id") +" ";}
  728. if(title!=null&&!"".equals(title)){
  729. sql+=" and title like '%"+title+"%'";
  730. }
  731. sql+=" order by id desc";
  732. List list = db.queryForList(sql);
  733. request.setAttribute("list", list);
  734. return "/front/wdxxList";
  735. }
  736. @RequestMapping(value = "/mineaddress")
  737. public String mineaddress(Model model, HttpServletRequest request,String flag,String title)throws Exception {
  738. String sql="select a.* from t_address a where 1=1";
  739. if(1==1){sql+=" and customerId="+getCustomer(request).get("id") +" ";}
  740. sql+=" order by id desc";
  741. List list = db.queryForList(sql);
  742. request.setAttribute("list", list);
  743. return "/front/mineaddress";
  744. }
  745. @RequestMapping(value = "/minesc")
  746. public String minesc(Model model, HttpServletRequest request,String flag,String title)throws Exception {
  747. String sql="select (select max(productName) from t_product b where b.id=a.productId) productName,(select max(productPic1) from t_product b where b.id=a.productId) productPic1,id,productId from t_sc a where 1=1";
  748. if(1==1){sql+=" and customerId="+getCustomer(request).get("id") +" ";}
  749. sql+=" order by id desc";
  750. List list = db.queryForList(sql);
  751. System.out.println(sql);
  752. request.setAttribute("list", list);
  753. return "/front/minesc";
  754. }
  755. @RequestMapping(value = "/minexiaoxi")
  756. public String minexiaoxi(Model model, HttpServletRequest request,String flag,String title)throws Exception {
  757. String sql=" select * from t_xiaoxi a where 1=1";
  758. if(1==1){sql+=" and customerId="+getCustomer(request).get("id") +" ";}
  759. sql+=" order by id desc";
  760. List list = db.queryForList(sql);
  761. request.setAttribute("list", list);
  762. return "/front/minexiaoxi";
  763. }
  764. @RequestMapping(value = "/hywdxxList")
  765. public String hywdxxList(Model model, HttpServletRequest request,String flag,String title)throws Exception {
  766. Map customer = getCustomer(request);
  767. String sql="select a.*,(select max(name) from t_customer b where a.customerId=b.id) customerName from t_wdxx a where 1=1";
  768. sql+=" and exists(select 1 from t_wdhy b where a.customerId=b.hhId and b.customerId="+customer.get("id")+") ";
  769. if(title!=null&&!"".equals(title)){
  770. sql+=" and title like '%"+title+"%'";
  771. }
  772. sql+=" order by id desc";
  773. List list = db.queryForList(sql);
  774. request.setAttribute("list", list);
  775. return "/front/wdxxList";
  776. }
  777. @RequestMapping(value = "/wdxxEditSave")
  778. public ResponseEntity<String> editSave(Model model,HttpServletRequest request,Long id,String flag
  779. ,Integer customerId,String title,String pic,String content,Integer zan,String insertDate,String nologin,Long bkId) throws Exception{
  780. int result = 0;
  781. if(id!=null){
  782. String sql="update t_wdxx set title=?,pic=?,content=?,nologin=?,bkId=? where id=?";
  783. result = db.update(sql, new Object[]{title,pic,content,nologin,bkId,id});
  784. }else{
  785. String sql="insert into t_wdxx(customerId,title,pic,content,zan,insertDate,nologin,bkId) values(?,?,?,?,?,now(),?,?)";
  786. result = db.update(sql, new Object[]{getCustomer(request).get("id"),title,pic,content,0,nologin,bkId});
  787. }
  788. if(result==1){
  789. return renderData(true,"操作成功",null);
  790. }else{
  791. return renderData(false,"操作失败",null);
  792. }
  793. }
  794. @RequestMapping(value = "/mineaddressEditSave")
  795. public ResponseEntity<String> mineaddressEditSave(Model model,HttpServletRequest request,Long id,String province,String city,String area,String phone,String lxr,String xxdz) throws Exception{
  796. int result = 0;
  797. if(id!=null){
  798. String sql="update t_address set province=?,city=?,area=?,phone=?,lxr=?,xxdz=? where id=?";
  799. result = db.update(sql, new Object[]{province,city,area,phone,lxr,xxdz,id});
  800. }else{
  801. String sql="insert into t_address(customerId,province,city,area,phone,lxr,xxdz) values(?,?,?,?,?,?,?)";
  802. result = db.update(sql, new Object[]{getCustomer(request).get("id"),province,city,area,phone,lxr,xxdz});
  803. }
  804. if(result==1){
  805. return renderData(true,"操作成功",null);
  806. }else{
  807. return renderData(false,"操作失败",null);
  808. }
  809. }
  810. @RequestMapping(value = "/wdxxEditDelete")
  811. public ResponseEntity<String> editDelete(Model model,HttpServletRequest request,Long id,String flag) throws Exception {
  812. String sql="delete from t_wdxx where id=?";
  813. int result = db.update(sql, new Object[]{id});
  814. if(result==1){
  815. return renderData(true,"操作成功",null);
  816. }else{
  817. return renderData(false,"操作失败",null);
  818. }
  819. }
  820. @RequestMapping(value = "/wdxxEdit")
  821. public String wdxxEdit(Model model, HttpServletRequest request,Long id,String flag)throws Exception {
  822. if(id!=null){
  823. //修改
  824. String sql="select * from t_wdxx where id=?";
  825. Map map = db.queryForMap(sql,new Object[]{id});
  826. model.addAttribute("map", map);
  827. }String sql="";
  828. return "/front/wdxxEdit";
  829. }
  830. @RequestMapping(value = "/mineaddressEdit")
  831. public String mineaddressEdit(Model model, HttpServletRequest request,Long id,String flag)throws Exception {
  832. if(id!=null){
  833. //修改
  834. String sql="select * from t_address where id=?";
  835. Map map = db.queryForMap(sql,new Object[]{id});
  836. model.addAttribute("map", map);
  837. }String sql="";
  838. return "/front/mineaddressEdit";
  839. }
  840. @RequestMapping(value = "/wdxxShow")
  841. public String wdxxShow(Model model, HttpServletRequest request,Long id,String flag)throws Exception {
  842. if(id!=null){
  843. //修改
  844. String sql="select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName,(select count(1) from t_pinglun b where b.wdxxId=a.id) nums from t_wdxx a where id=?";
  845. Map map = db.queryForMap(sql,new Object[]{id});
  846. model.addAttribute("map", map);
  847. }
  848. String sql="select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName,(select max(headPic) from t_customer b where a.customerId=b.id) headPic from t_pinglun a where wdxxId=? order by id desc";
  849. List<Map> list = db.queryForList(sql,new Object[]{id});
  850. model.addAttribute("list", list);
  851. sql="select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName from t_wdxx a where 1=1 order by zan desc limit 4";
  852. List list3 = db.queryForList(sql);
  853. request.setAttribute("list3", list3);
  854. sql="select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName from t_wdxx a where 1=1 order by id desc limit 4";
  855. List list4 = db.queryForList(sql);
  856. request.setAttribute("list4", list4);
  857. return "/front/wdxxShow";
  858. }
  859. @RequestMapping(value = "/wdxxDelete")
  860. public ResponseEntity<String> wdxxDelete(Model model,
  861. HttpServletRequest request, Long id) throws Exception {
  862. Map customer = getCustomer(request);
  863. String sql="delete from t_wdxx where id=?";
  864. db.update(sql, new Object[]{id});
  865. return renderData(true, "操作成功", null);
  866. }
  867. @RequestMapping(value = "/addressDelete")
  868. public ResponseEntity<String> addressDelete(Model model,
  869. HttpServletRequest request, Long id) throws Exception {
  870. Map customer = getCustomer(request);
  871. String sql="delete from t_address where id=?";
  872. db.update(sql, new Object[]{id});
  873. return renderData(true, "操作成功", null);
  874. }
  875. @RequestMapping(value = "/pinglunSave")
  876. public ResponseEntity<String> pinglunSave(Model model,HttpServletRequest request,Long id,String flag
  877. ,String wdxxId,Integer customerId,String content,String insertDate) throws Exception{
  878. int result = 0;
  879. String sql="insert into t_pinglun(wdxxId,customerId,content,insertDate) values(?,?,?,now())";
  880. result = db.update(sql, new Object[]{wdxxId,getCustomer(request).get("id"),content});
  881. if(result==1){
  882. return renderData(true,"操作成功",null);
  883. }else{
  884. return renderData(false,"操作失败",null);
  885. }
  886. }
  887. @RequestMapping(value = "/productPinglunSave")
  888. public ResponseEntity<String> productPinglunSave(Model model,HttpServletRequest request,Long id,String flag
  889. ,String productId,Integer customerId,String content,String insertDate) throws Exception{
  890. int result = 0;
  891. String sql="insert into t_pinglun_product(productId,customerId,content,insertDate) values(?,?,?,now())";
  892. result = db.update(sql, new Object[]{productId,getCustomer(request).get("id"),content});
  893. if(result==1){
  894. return renderData(true,"操作成功",null);
  895. }else{
  896. return renderData(false,"操作失败",null);
  897. }
  898. }
  899. @RequestMapping(value = "/zanSave")
  900. public ResponseEntity<String> zanSave(Model model,HttpServletRequest request,Long id) throws Exception{
  901. int result = 0;
  902. String sql="update t_wdxx set zan=zan+1 where id=?";
  903. result = db.update(sql, new Object[]{id});
  904. if(result==1){
  905. return renderData(true,"操作成功",null);
  906. }else{
  907. return renderData(false,"操作失败",null);
  908. }
  909. }
  910. @RequestMapping(value = "/zxList")
  911. public String zxList(Model model, HttpServletRequest request,String flag,String title)throws Exception {
  912. String sql="select a.* from t_zx a where 1=1 ";
  913. if(title!=null&&!"".equals(title)){
  914. sql+=" and title like '%"+title+"%'";
  915. }
  916. sql+=" order by id desc";
  917. List list = db.queryForList(sql);
  918. request.setAttribute("list", list);
  919. return "/front/zxList";
  920. }
  921. @RequestMapping(value = "/zxShow")
  922. public String zxShow(Model model, HttpServletRequest request,Long id,String flag)throws Exception {
  923. String sql="select * from t_zx where id=?";
  924. Map map = db.queryForMap(sql,new Object[]{id});
  925. model.addAttribute("map", map);
  926. sql="select a.* from t_zx a where 1=1 ";
  927. sql+=" order by id desc limit 3";
  928. List list = db.queryForList(sql);
  929. request.setAttribute("list", list);
  930. return "/front/zxShow";
  931. }
  932. @RequestMapping(value = "/ltjlDelete")
  933. public ResponseEntity<String> ltjlDelete(Model model,HttpServletRequest request,Long id,String pl,String flag) throws Exception {
  934. System.out.println("getCustomer(request).get()==================="+getCustomer(request).get("id"));
  935. db.update("delete from t_liaotian where customerId=? or toId=?", new Object[]{getCustomer(request).get("id"),getCustomer(request).get("id")});
  936. return renderData(true,"操作成功",null);
  937. }
  938. @RequestMapping(value = "/liaotian")
  939. public String liaotian(Model model, HttpServletRequest request,Long id,String flag,Long toId)throws Exception {
  940. Map customer = getCustomer(request);
  941. if (customer != null && customer.size() > 0) {
  942. } else {
  943. return "redirect:/front/register.html";
  944. }
  945. String customerId = getCustomer(request).get("id").toString();
  946. String batchNum1 = customerId+"&&"+toId;
  947. String batchNum2 = toId+"&&"+customerId;
  948. List list = db.queryForList("select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName1," +
  949. "(select max(name) from t_user c where a.toId=c.id) customerName2 from t_liaotian a where batchNum in ('"+batchNum1+"','"+batchNum2+"') order by id asc");
  950. System.out.println("select a.*,(select max(customerName) from t_customer b where a.customerId=b.id) customerName1," +
  951. "(select max(name) from t_user c where a.toId=c.id) customerName2 from t_liaotian a where batchNum in ('"+batchNum1+"','"+batchNum2+"') order by id asc");
  952. model.addAttribute("list", list);
  953. System.out.println(list);
  954. return "/front/liaotian";
  955. }
  956. @RequestMapping(value = "/woxiaoxi")
  957. public String woxiaoxi(Model model, HttpServletRequest request,Long id,String flag,Long toId)throws Exception {
  958. String customerId = getCustomer(request).get("id").toString();
  959. String sql="select customerId,(select max(customerName) from t_customer b where b.id=a.customerId) customerName from t_liaotian a where toId="+customerId+" group by customerId ";
  960. System.out.println(db.queryForList(sql));
  961. model.addAttribute("list", db.queryForList(sql));
  962. return "/front/woxiaoxi";
  963. }
  964. @RequestMapping(value = "/liaotianSave")
  965. public ResponseEntity<String> liaotianSave(Model model,HttpServletRequest request,Long toId,String content) throws Exception {
  966. String customerId = getCustomer(request).get("id").toString();
  967. String batchNum = customerId+"&&"+toId;
  968. db.update("insert into t_liaotian(customerId,toId,content,insertDate,batchNum,fq) values(?,?,?,now(),?,1)", new Object[]{customerId,toId,content,batchNum});
  969. return renderData(true,"操作成功",null);
  970. }
  971. }

五,项目总结

本课题主要实现基于用户偏好实现的电影信息推荐系统,根据相关分析,本系统主要实现前端用户和后台管理用户两类角色的相关操作功能,具体实现了电影信息的在线浏览、收藏、评论和预定功能,同时根据用户的操作记录,完成电影信息的数据推荐功能。主要有以下几个章节组成。

第一部分主要是通过绪论来阐述开发这个推荐系统的基本背景及其意义,之后描述了推荐系统在国内外不同的研究情况和协同过滤算法应用的相关介绍以及其现状。

第二部分详细介绍了本系统使用的SSM框架,以及系统的整体架构模型和所使用的数据库类型。

第三部分主要通过多方位全面的对系统进行了需求分析,论证了系统技术和操作的可行性以及系统所需要的功能点和非功能性需求。

第四部分主要基于系统的需求来设计系统的整体架构和功能架构以及业务逻辑,细化到了每个小模块的设计,同时也说明了系统的数据库设计与实现。

第五部分主要根据上一部分的系统设计,实现了系统的各个功能模块并进行了前端页面的演示。

第六部分测试主要通过明确测试的目的与方法来搭建测试环境以及测试用例的编写完成对系统的功能性测试。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/449639
推荐阅读
相关标签
  

闽ICP备14008679号