├── README.md ├── pom.xml ├── src └── main │ ├── java │ └── com │ │ └── shopping │ │ ├── bean │ │ ├── Access.java │ │ ├── Admin.java │ │ ├── AdminContent.java │ │ ├── Goods.java │ │ ├── Image.java │ │ ├── Order.java │ │ ├── Post.java │ │ ├── PostStatus.java │ │ ├── Shop.java │ │ └── User.java │ │ ├── controller │ │ ├── AdministratorController.java │ │ ├── CardController.java │ │ ├── EvaluationController.java │ │ ├── ProductController.java │ │ ├── ProductTypeController.java │ │ ├── ShopController.java │ │ ├── ShoppingCarController.java │ │ ├── ShoppingRecordController.java │ │ └── UserController.java │ │ ├── dao │ │ ├── AccessDAO.java │ │ ├── AdminContentDAO.java │ │ ├── CardDao.java │ │ ├── CardDaoImplement.java │ │ ├── EvaluationDao.java │ │ ├── EvaluationDaoImplement.java │ │ ├── GoodsDAO.java │ │ ├── ImageDAO.java │ │ ├── OrderDAO.java │ │ ├── PageDao.java │ │ ├── PageDaoImplement.java │ │ ├── PostDAO.java │ │ ├── PostStatusDAO.java │ │ ├── ProductDao.java │ │ ├── ProductDaoImplement.java │ │ ├── ProductTypeDao.java │ │ ├── ProductTypeDaoImplement.java │ │ ├── ShopDAO.java │ │ ├── ShoppingCarDao.java │ │ ├── ShoppingCarDaoImplement.java │ │ ├── ShoppingRecordDao.java │ │ ├── ShoppingRecordDaoImplement.java │ │ ├── UserDAO.java │ │ ├── UserDaoImplement.java │ │ ├── UserDetailDao.java │ │ └── UserDetailDaoImplement.java │ │ ├── entity │ │ ├── Card.java │ │ ├── Evaluation.java │ │ ├── Page.java │ │ ├── Product.java │ │ ├── ProductType.java │ │ ├── ShoppingCar.java │ │ ├── ShoppingCarPriKey.java │ │ ├── ShoppingRecord.java │ │ ├── ShoppingRecordPriKey.java │ │ ├── User.java │ │ └── UserDetail.java │ │ ├── filter │ │ ├── EncodingFilter.java │ │ └── LoginFilter.java │ │ ├── service │ │ ├── CardService.java │ │ ├── CardServiceImplement.java │ │ ├── EvaluationService.java │ │ ├── EvaluationServiceImplement.java │ │ ├── ProductService.java │ │ ├── ProductServiceImplement.java │ │ ├── ProductTypeService.java │ │ ├── ProductTypeServiceImplement.java │ │ ├── ShoppingCarService.java │ │ ├── ShoppingCarServiceImplement.java │ │ ├── ShoppingRecordService.java │ │ ├── ShoppingRecordServiceImplement.java │ │ ├── UserDetailService.java │ │ ├── UserDetailServiceImplement.java │ │ ├── UserService.java │ │ └── UserServiceImplement.java │ │ └── utils │ │ └── Response.java │ ├── resources │ ├── 05.jpg │ ├── properties │ │ ├── Shopping SQL语句.txt │ │ └── database.properties │ └── spring │ │ ├── applicationContext.xml │ │ └── spring-mvc.xml │ └── webapp │ ├── WEB-INF │ ├── views │ │ ├── all_cards.jsp │ │ ├── amend_info.jsp │ │ ├── bossControl.jsp │ │ ├── bossLogin.jsp │ │ ├── control.jsp │ │ ├── include │ │ │ ├── bossHead.jsp │ │ │ ├── foot.jsp │ │ │ └── header.jsp │ │ ├── login.jsp │ │ ├── main.jsp │ │ ├── manager.jsp │ │ ├── managerControl.jsp │ │ ├── managerLogin.jsp │ │ ├── page_cards.jsp │ │ ├── product_detail.jsp │ │ ├── register.jsp │ │ ├── search.jsp │ │ ├── send_card.jsp │ │ ├── shop.jsp │ │ ├── shopping_car.jsp │ │ ├── shopping_handle.jsp │ │ ├── shopping_record.jsp │ │ ├── vip.jsp │ │ └── vipLogin.jsp │ └── web.xml │ └── static │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ └── style.css │ ├── img │ ├── 0045e07dd23e1845063c823cb7cfaeee.jpg │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 46f46cfac8b8a702f970353f7fec5618.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 662072618.jpg │ ├── B1.jpg │ └── key-lime.jpg │ └── js │ ├── ajaxfileupload.js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── html5shiv.min.js │ ├── jquery.min.js │ ├── layer.js │ ├── mobile │ ├── layer.js │ └── need │ │ └── layer.css │ ├── npm.js │ ├── respond.min.js │ └── skin │ ├── default │ ├── icon-ext.png │ ├── icon.png │ ├── layer.css │ ├── loading-0.gif │ ├── loading-1.gif │ └── loading-2.gif │ ├── family │ └── style.css │ └── lists │ └── style.css ├── views(优化用户界面).zip └── 于12.25优化用户界面 /README.md: -------------------------------------------------------------------------------- 1 | # Shopping 2 | 网上商城——WEB程序设计课程期末大作业项目 3 | ## 说明 4 | git clone 项目url, 使用IDEA导入项目->maven导入->pom.xml->import changes->OK! 5 | ## 更新日志: 6 | master 7 | 12.26做完了PPT 8 | 12.26优化了登录界面 9 | ======= 10 | 12.26 完成了PPT初稿\ 11 | 12.26 限制了用户注册时昵称的长度\ 12 | 12.26 解决了数据库之前的级联问题\ 13 | 12.26 bugs fixed\ 14 | 12.26 bugs fixed\ 15 | 12.25 解决了发帖功能中存在的一些bugs 16 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.shopping 5 | shopping 6 | war 7 | 1.0-SNAPSHOT 8 | Shopping 9 | http://maven.apache.org 10 | 11 | 12 | 13 | junit 14 | junit 15 | 3.8.1 16 | test 17 | 18 | 19 | 20 | 21 | javax 22 | javaee-api 23 | 7.0 24 | provided 25 | 26 | 27 | 28 | 29 | org.glassfish.web 30 | javax.servlet.jsp.jstl 31 | 1.2.2 32 | 33 | 34 | 35 | 36 | mysql 37 | mysql-connector-java 38 | 8.0.13 39 | 40 | 41 | 42 | 44 | 45 | org.springframework 46 | spring-webmvc 47 | 4.3.5.RELEASE 48 | 49 | 50 | 51 | 52 | org.springframework 53 | spring-orm 54 | 4.3.5.RELEASE 55 | 56 | 57 | 58 | 59 | org.springframework 60 | spring-aspects 61 | 4.3.5.RELEASE 62 | 63 | 64 | 65 | 66 | org.apache.commons 67 | commons-dbcp2 68 | 2.1.1 69 | 70 | 71 | 72 | 73 | commons-fileupload 74 | commons-fileupload 75 | 1.3.2 76 | 77 | 78 | 79 | 80 | 81 | org.hibernate 82 | hibernate-core 83 | 4.3.8.Final 84 | 85 | 86 | 87 | 88 | com.alibaba 89 | fastjson 90 | 1.2.24 91 | 92 | 93 | 94 | 95 | com.fasterxml.jackson.core 96 | jackson-core 97 | 2.9.7 98 | 99 | 100 | 101 | com.fasterxml.jackson.core 102 | jackson-databind 103 | 2.9.6 104 | 105 | 106 | 107 | 108 | Shopping 109 | 110 | 111 | 112 | org.apache.maven.plugins 113 | maven-compiler-plugin 114 | 2.3.2 115 | 116 | 1.8 117 | 1.8 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Access.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Access { 4 | private String user_account; 5 | private String goods_name; 6 | private String content; 7 | 8 | public String getUser_account() { 9 | return user_account; 10 | } 11 | 12 | public void setUser_account(String user_account) { 13 | this.user_account = user_account; 14 | } 15 | 16 | public String getGoods_name() { 17 | return goods_name; 18 | } 19 | 20 | public void setGoods_name(String goods_name) { 21 | this.goods_name = goods_name; 22 | } 23 | 24 | public String getContent() { 25 | return content; 26 | } 27 | 28 | public void setContent(String content) { 29 | this.content = content; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Admin.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Admin { 4 | private String account; 5 | private String password; 6 | 7 | public String getAccount() { 8 | return account; 9 | } 10 | 11 | public void setAccount(String account) { 12 | this.account = account; 13 | } 14 | 15 | public String getPassword() { 16 | return password; 17 | } 18 | 19 | public void setPassword(String password) { 20 | this.password = password; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/AdminContent.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class AdminContent { 4 | private String content; 5 | 6 | public String getContent() { 7 | return content; 8 | } 9 | 10 | public void setContent(String content) { 11 | this.content = content; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Goods.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Goods { 4 | private String name; 5 | private String photo; 6 | private double price; 7 | private String owner; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getPhoto() { 18 | return photo; 19 | } 20 | 21 | public void setPhoto(String photo) { 22 | this.photo = photo; 23 | } 24 | 25 | public double getPrice() { 26 | return price; 27 | } 28 | 29 | public void setPrice(double price) { 30 | this.price = price; 31 | } 32 | 33 | public String getOwner() { 34 | return owner; 35 | } 36 | 37 | public void setOwner(String owner) { 38 | this.owner = owner; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Image.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Image { 4 | public String getGood_name() { 5 | return good_name; 6 | } 7 | 8 | public void setGood_name(String good_name) { 9 | this.good_name = good_name; 10 | } 11 | 12 | public byte[] getPhoto() { 13 | return photo; 14 | } 15 | 16 | public void setPhoto(byte[] photo) { 17 | this.photo = photo; 18 | } 19 | 20 | public String getDescription() { 21 | return description; 22 | } 23 | 24 | public void setDescription(String description) { 25 | this.description = description; 26 | } 27 | 28 | String good_name;//商品名 29 | byte[] photo;//图片路径 30 | String description;//图片描述 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Order.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Order { 4 | private String user_account; 5 | private String shop_account; 6 | private String goods_name; 7 | private int goods_num; 8 | private double sum; 9 | private int status; 10 | private double goods_price; 11 | 12 | 13 | public double getGoods_price() { 14 | return goods_price; 15 | } 16 | public void setGoods_price(double goods_price) { 17 | this.goods_price = goods_price; 18 | } 19 | public String getUser_account() { 20 | return user_account; 21 | } 22 | 23 | public void setUser_account(String user_account) { 24 | this.user_account = user_account; 25 | } 26 | 27 | public String getShop_account() { 28 | return shop_account; 29 | } 30 | 31 | public void setShop_account(String shop_account) { 32 | this.shop_account = shop_account; 33 | } 34 | 35 | public String getGoods_name() { 36 | return goods_name; 37 | } 38 | 39 | public void setGoods_name(String goods_name) { 40 | this.goods_name = goods_name; 41 | } 42 | 43 | public int getGoods_num() { 44 | return goods_num; 45 | } 46 | 47 | public void setGoods_num(int goods_num) { 48 | this.goods_num = goods_num; 49 | } 50 | 51 | public double getSum() { 52 | return sum; 53 | } 54 | 55 | public void setSum(double sum) { 56 | this.sum = sum; 57 | } 58 | 59 | public int getStatus() { 60 | return status; 61 | } 62 | 63 | public void setStatus(int status) { 64 | this.status = status; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Post.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Post { 4 | private String user_account; 5 | private String content; 6 | 7 | public String getUser_account() { 8 | return user_account; 9 | } 10 | 11 | public void setUser_account(String user_account) { 12 | this.user_account = user_account; 13 | } 14 | 15 | public String getContent() { 16 | return content; 17 | } 18 | 19 | public void setContent(String content) { 20 | this.content = content; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class PostStatus { 4 | private int id; 5 | private int status; 6 | 7 | public int getId() { 8 | return id; 9 | } 10 | 11 | public void setId(int id) { 12 | this.id = id; 13 | } 14 | 15 | public int getStatus() { 16 | return status; 17 | } 18 | 19 | public void setStatus(int status) { 20 | this.status = status; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/Shop.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | public class Shop { 4 | private String account; 5 | private String password; 6 | 7 | public String getAccount() { 8 | return account; 9 | } 10 | 11 | public void setAccount(String account) { 12 | this.account = account; 13 | } 14 | 15 | public String getPassword() { 16 | return password; 17 | } 18 | 19 | public void setPassword(String password) { 20 | this.password = password; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.shopping.bean; 2 | 3 | import javax.persistence.Entity; 4 | 5 | @Entity 6 | public class User { 7 | private String account; 8 | private String password; 9 | private int member; 10 | 11 | public String getAccount() { 12 | return account; 13 | } 14 | 15 | public void setAccount(String account) { 16 | this.account = account; 17 | } 18 | 19 | public String getPassword() { 20 | return password; 21 | } 22 | 23 | public void setPassword(String password) { 24 | this.password = password; 25 | } 26 | 27 | public int getMember() { 28 | return member; 29 | } 30 | 31 | public void setMember(int member) { 32 | this.member = member; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/controller/AdministratorController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.controller; 2 | 3 | import com.shopping.bean.AdminContent; 4 | import com.shopping.bean.Goods; 5 | import com.shopping.dao.AdminContentDAO; 6 | import com.shopping.dao.GoodsDAO; 7 | import com.shopping.dao.PostStatusDAO; 8 | import com.shopping.dao.ShopDAO; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.util.List; 15 | 16 | @Controller 17 | public class AdministratorController { 18 | /** 19 | * 列出所有商品 20 | * @param request 21 | * @param response 22 | * @throws Exception 23 | */ 24 | @RequestMapping(value = "/adminGoodsList",method = RequestMethod.POST) 25 | public void GoodsList(HttpServletRequest request, HttpServletResponse response) 26 | throws Exception{ 27 | List goodss=new GoodsDAO().seleteAll(); 28 | //System.out.println(goodss.toArray().toString()); 29 | request.setAttribute("goodss",goodss); 30 | request.getRequestDispatcher("adminGoodsList.jsp").forward(request, response); 31 | } 32 | /** 33 | * 删除商品 34 | * @param request 35 | * @param response 36 | * @throws Exception 37 | */ 38 | @RequestMapping(value = "/adminDeleteGoods",method = RequestMethod.POST) 39 | public void AdminDeleteGoods(HttpServletRequest request, HttpServletResponse response) 40 | throws Exception{ 41 | String name= request.getParameter("name"); 42 | new GoodsDAO().deleteGoods(name); 43 | response.getWriter().write("

删除商品完成返回管理员主界面

"); 44 | response.setHeader("refresh","3;/adminMain.jsp"); 45 | } 46 | 47 | /** 48 | * 删除店铺及其旗下商品 49 | * @param request 50 | * @param response 51 | * @throws Exception 52 | */ 53 | @RequestMapping(value = "/adminDeleteShop",method = RequestMethod.POST) 54 | public void AdminDeleteShop(HttpServletRequest request, HttpServletResponse response) 55 | throws Exception{ 56 | String owner=request.getParameter("owner"); 57 | new GoodsDAO().deleteOwnerGoods(owner); 58 | new ShopDAO().deleteShop(owner); 59 | response.getWriter().write("

删除商家完成返回管理员主界面

"); 60 | response.setHeader("refresh","3;/adminMain.jsp"); 61 | } 62 | 63 | /** 64 | * 管理员登录 65 | * @param request 66 | * @param response 67 | * @throws Exception 68 | */ 69 | @RequestMapping(value = "/adminLogin",method = RequestMethod.POST) 70 | public void AdminLogin(HttpServletRequest request, HttpServletResponse response) 71 | throws Exception{ 72 | String account=request.getParameter("account"); 73 | String password=request.getParameter("password"); 74 | if("root".equals(account)&&"admin".equals(password)){ 75 | request.getSession().setAttribute("admin","admin"); 76 | response.getWriter().write("

管理员登录成功!

"); 77 | response.setHeader("refresh","3;/adminMain.jsp"); 78 | } 79 | else{ 80 | response.getWriter().write("

管理员登录失败!

"); 81 | } 82 | } 83 | 84 | /** 85 | * 管理员 关闭帖子功能 86 | * @param request 87 | * @param response 88 | * @throws Exception 89 | */ 90 | @RequestMapping(value = "/adminPostClose",method = RequestMethod.POST) 91 | public void AdminPostClose(HttpServletRequest request, HttpServletResponse response) 92 | throws Exception{ 93 | new PostStatusDAO().updateStatus(0); 94 | response.getWriter().println("关闭帖子功能"); 95 | response.getWriter().write("

关闭帖子功能成功!

"); 96 | response.setHeader("refresh","3;/adminMain.jsp"); 97 | } 98 | 99 | /** 100 | * 管理员开启帖子功能 101 | * @param request 102 | * @param response 103 | * @throws Exception 104 | */ 105 | @RequestMapping(value = "/adminPostOpen",method = RequestMethod.POST) 106 | public void AdminPostOpen(HttpServletRequest request, HttpServletResponse response) 107 | throws Exception{ 108 | new PostStatusDAO().updateStatus(1); 109 | response.getWriter().write("

开启帖子功能成功!

"); 110 | response.setHeader("refresh","3;/adminMain.jsp"); 111 | } 112 | 113 | /** 114 | * 管理员发出通告 115 | * @param request 116 | * @param response 117 | * @throws Exception 118 | */ 119 | @RequestMapping(value = "/adminSayServlet",method = RequestMethod.POST) 120 | public void AdminSay(HttpServletRequest request, HttpServletResponse response) 121 | throws Exception{ 122 | String content=request.getParameter("content"); 123 | AdminContent adminContent=new AdminContent(); 124 | adminContent.setContent(content); 125 | new AdminContentDAO().addContent(adminContent); 126 | response.getWriter().write("

管理员发出通告成功!

"); 127 | response.setHeader("refresh","3;/adminMain.jsp"); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/controller/CardController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.controller; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.shopping.entity.Card; 6 | import com.shopping.service.CardService; 7 | import com.shopping.utils.Response; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import javax.annotation.Resource; 14 | import javax.servlet.http.HttpSession; 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | @Controller 21 | public class CardController { 22 | @Resource 23 | private CardService cardService; 24 | 25 | @RequestMapping(value = "/send_card") 26 | public String sendCard() { 27 | return "send_card"; 28 | } 29 | 30 | @RequestMapping(value = "/all_cards") 31 | public String allCards() { 32 | return "all_cards"; 33 | } 34 | 35 | @RequestMapping(value = "/getAllCards",method =RequestMethod.POST) 36 | @ResponseBody 37 | public Map getAllCards(){ 38 | List cardsList = new ArrayList<>(); 39 | cardsList = cardService.getAllCards(); 40 | for(int i=0;i resultMap = new HashMap(); 45 | resultMap.put("allCards",allCards); 46 | return resultMap; 47 | } 48 | @RequestMapping(value = "/Post", method = RequestMethod.POST) 49 | @ResponseBody 50 | public void Post( int isopen,HttpSession httpSession) { 51 | System.out.println(isopen); 52 | httpSession.setAttribute("isopen",isopen); 53 | } 54 | 55 | 56 | @RequestMapping(value = "/deleteCard",method = RequestMethod.POST) 57 | @ResponseBody 58 | public Response deleteCard(int id) { 59 | System.out.println("被删的id是:"+id); 60 | return cardService.deleteCard(id); 61 | } 62 | 63 | @RequestMapping(value = "/pageQuery",method =RequestMethod.POST) 64 | @ResponseBody 65 | public Map pageQuery(int star,int num){ 66 | List cardsList = new ArrayList<>(); 67 | cardsList = cardService.pageQuery(star,num); 68 | String threeCards = JSONArray.toJSONString(cardsList); 69 | Map resultMap = new HashMap(); 70 | resultMap.put("threeCards",threeCards); 71 | return resultMap; 72 | } 73 | 74 | @RequestMapping(value = "/getCardsByUser",method = RequestMethod.POST) 75 | @ResponseBody 76 | public Map getCardByUser(int userId) { 77 | List cardList = new ArrayList<>(); 78 | cardList = cardService.getCardsByUser(userId); 79 | String userCards = JSONArray.toJSONString(cardList); 80 | Map resultMap = new HashMap(); 81 | resultMap.put("userCards",userCards); 82 | return resultMap; 83 | } 84 | 85 | @RequestMapping(value = "/addCard", method = RequestMethod.POST) 86 | @ResponseBody 87 | public Map addCard(String content,int userId) { 88 | System.out.println(userId+"添加了:"+content); 89 | String result ="fail"; 90 | Card card=new Card(); 91 | card.setContent(content); 92 | card.setUserId(userId); 93 | System.out.println("发表的内容为"+card.getContent()); 94 | cardService.addCard(card); 95 | Map resultMap = new HashMap(); 96 | resultMap.put("result","success"); 97 | return resultMap; 98 | } 99 | /*public static void main(String[] args){ 100 | Card card=new Card(); 101 | card.setContent("hello"); 102 | card.setUserId(1); 103 | System.out.println(card.getContent()); 104 | cardService.addCard(card); 105 | }*/ 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/controller/EvaluationController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.controller; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.shopping.entity.Evaluation; 5 | import com.shopping.service.EvaluationService; 6 | import com.shopping.service.ShoppingRecordService; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | 12 | import javax.annotation.Resource; 13 | import java.text.SimpleDateFormat; 14 | import java.util.Date; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | /** 20 | * Created by 14437 on 2017/3/7. 21 | */ 22 | @Controller 23 | public class EvaluationController { 24 | @Resource 25 | private EvaluationService evaluationService; 26 | 27 | @Resource 28 | private ShoppingRecordService shoppingRecordService; 29 | 30 | @RequestMapping(value = "/addShoppingEvaluation",method = RequestMethod.POST) 31 | @ResponseBody 32 | public Map addShoppingEvaluation(int userId, int productId, String content){ 33 | System.out.println("我添加了"+userId+" "+productId); 34 | String result = null; 35 | if(shoppingRecordService.getUserProductRecord(userId,productId)){ 36 | Evaluation evaluation = new Evaluation(); 37 | evaluation.setUserId(userId); 38 | evaluation.setProductId(productId); 39 | Date date = new Date(); 40 | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); 41 | evaluation.setTime(sf.format(date)); 42 | evaluation.setContent(content); 43 | evaluationService.addEvaluation(evaluation); 44 | result = "success"; 45 | } 46 | else{ 47 | result="noneRecord"; 48 | } 49 | 50 | Map resultMap = new HashMap(); 51 | resultMap.put("result",result); 52 | return resultMap; 53 | } 54 | 55 | @RequestMapping(value = "/getShoppingEvaluations",method = RequestMethod.POST) 56 | @ResponseBody 57 | public Map getShoppingEvaluations(int productId){ 58 | List evaluationList = evaluationService.getProductEvaluation(productId); 59 | String evaluations = JSONArray.toJSONString(evaluationList); 60 | Map resultMap = new HashMap(); 61 | resultMap.put("result",evaluations); 62 | return resultMap; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/controller/ProductTypeController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.controller; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.shopping.entity.ProductType; 5 | import com.shopping.service.ProductTypeService; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | public class ProductTypeController { 17 | @Resource 18 | private ProductTypeService productTypeService; 19 | @RequestMapping(value = "/addType", method = RequestMethod.POST) 20 | @ResponseBody 21 | public Map addType(String type) { 22 | String result ="fail"; 23 | ProductType productType=new ProductType(); 24 | productType.setType(type); 25 | productTypeService.addProductTypes(productType); 26 | Map resultMap = new HashMap(); 27 | resultMap.put("result","success"); 28 | return resultMap; 29 | } 30 | 31 | @RequestMapping(value = "/getAllTypes",method = RequestMethod.POST) 32 | @ResponseBody 33 | public Map getAllTypes(){ 34 | List productTypeList = new ArrayList<>(); 35 | productTypeList = productTypeService.getAllProductTypes(); 36 | String allProductTypes = JSONArray.toJSONString(productTypeList); 37 | Map resultMap = new HashMap(); 38 | resultMap.put("allProductTypes",allProductTypes); 39 | return resultMap; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/controller/ShoppingCarController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.controller; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.shopping.entity.ShoppingCar; 5 | import com.shopping.service.ProductService; 6 | import com.shopping.service.ShoppingCarService; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | /** 18 | * Created by 14437 on 2017/3/3. 19 | */ 20 | @Controller 21 | public class ShoppingCarController { 22 | @Resource 23 | private ProductService productService; 24 | @Resource 25 | private ShoppingCarService shoppingCarService; 26 | 27 | @RequestMapping(value = "/shopping_car") 28 | public String shopping_car(){ 29 | return "shopping_car"; 30 | } 31 | 32 | @RequestMapping(value = "/addShoppingCar",method = RequestMethod.POST) 33 | @ResponseBody 34 | public Map addShoppingCar(int userId,int productId,int counts){ 35 | System.out.println("数量为"+counts); 36 | ShoppingCar shoppingCar = shoppingCarService.getShoppingCar(userId,productId); 37 | if(shoppingCar == null){ 38 | ShoppingCar shoppingCar1 = new ShoppingCar(); 39 | shoppingCar1.setUserId(userId); 40 | shoppingCar1.setProductId(productId); 41 | shoppingCar1.setCounts(counts); 42 | shoppingCar1.setProductPrice(productService.getProduct(productId).getPrice()*counts); 43 | shoppingCarService.addShoppingCar(shoppingCar1); 44 | } 45 | else{ 46 | shoppingCar.setCounts(shoppingCar.getCounts()+counts); 47 | shoppingCar.setProductPrice(productService.getProduct(productId).getPrice()*shoppingCar.getCounts()); 48 | shoppingCarService.updateShoppingCar(shoppingCar); 49 | } 50 | Map resultMap = new HashMap(); 51 | resultMap.put("result","success"); 52 | System.out.println("我返回了"); 53 | return resultMap; 54 | } 55 | @RequestMapping(value = "/updateShoppingCar",method = RequestMethod.POST) 56 | @ResponseBody 57 | public Map updateShoppingCar(int userId,int productId,int counts){ 58 | ShoppingCar shoppingCar=new ShoppingCar(); 59 | shoppingCar.setCounts(counts); 60 | shoppingCar.setProductId(productId); 61 | shoppingCar.setUserId(userId); 62 | shoppingCar.setProductPrice(productService.getProduct(productId).getPrice()*shoppingCar.getCounts()); 63 | shoppingCarService.updateShoppingCar(shoppingCar); 64 | Map resultMap = new HashMap(); 65 | resultMap.put("result","success"); 66 | System.out.println("我返回了"); 67 | return resultMap; 68 | } 69 | 70 | @RequestMapping(value = "/getShoppingCars",method = RequestMethod.POST) 71 | @ResponseBody 72 | public Map getShoppingCars(int userId){ 73 | List shoppingCarList = shoppingCarService.getShoppingCars(userId); 74 | String shoppingCars = JSONArray.toJSONString(shoppingCarList); 75 | Map resultMap = new HashMap(); 76 | resultMap.put("result",shoppingCars); 77 | return resultMap; 78 | } 79 | 80 | @RequestMapping(value = "/deleteShoppingCar",method = RequestMethod.POST) 81 | @ResponseBody 82 | public Map deleteShoppingCar(int userId,int productId){ 83 | shoppingCarService.deleteShoppingCar(userId,productId); 84 | Map resultMap = new HashMap(); 85 | resultMap.put("result","success"); 86 | System.out.println("我返回了"); 87 | return resultMap; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/controller/ShoppingRecordController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.controller; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.shopping.entity.Product; 5 | import com.shopping.entity.ShoppingRecord; 6 | import com.shopping.service.ProductService; 7 | import com.shopping.service.ShoppingRecordService; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import javax.annotation.Resource; 14 | import java.text.SimpleDateFormat; 15 | import java.util.Date; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | /** 21 | * Created by 14437 on 2017/3/3. 22 | */ 23 | @Controller 24 | public class ShoppingRecordController { 25 | @Resource 26 | private ProductService productService; 27 | @Resource 28 | private ShoppingRecordService shoppingRecordService; 29 | 30 | @RequestMapping(value = "/shopping_record") 31 | public String shopping_record(){ 32 | return "shopping_record"; 33 | } 34 | 35 | @RequestMapping(value = "/shopping_handle") 36 | public String shopping_handle(){ 37 | return "shopping_handle"; 38 | } 39 | 40 | @RequestMapping(value = "/addShoppingRecord",method = RequestMethod.POST) 41 | @ResponseBody 42 | public Map addShoppingRecord(int userId,int productId,int counts,int shopId){ 43 | System.out.println("我添加了"+userId+" "+productId+" "+shopId); 44 | String result = null; 45 | Product product = productService.getProduct(productId); 46 | 47 | if(counts<=product.getCounts()) { 48 | ShoppingRecord shoppingRecord = new ShoppingRecord(); 49 | shoppingRecord.setUserId(userId); 50 | shoppingRecord.setProductId(productId); 51 | shoppingRecord.setProductPrice(product.getPrice() * counts); 52 | shoppingRecord.setCounts(counts); 53 | shoppingRecord.setOrderStatus(0); 54 | System.out.println("在contreller 的 if中 传入之前的 shopId is "+shopId); 55 | shoppingRecord.setShopId(shopId); 56 | System.out.println("在contreller 的 if中 shopId is "+shoppingRecord.getShopId()); 57 | Date date = new Date(); 58 | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); 59 | shoppingRecord.setTime(sf.format(date)); 60 | product.setCounts(product.getCounts()-counts); 61 | productService.updateProduct(product); 62 | shoppingRecordService.addShoppingRecord(shoppingRecord); 63 | result = "success"; 64 | } 65 | else{ 66 | result = "unEnough"; 67 | } 68 | Map resultMap = new HashMap(); 69 | resultMap.put("result",result); 70 | return resultMap; 71 | } 72 | 73 | @RequestMapping(value = "/changeShoppingRecord",method = RequestMethod.POST) 74 | @ResponseBody 75 | public Map changeShoppingRecord(int userId,int productId,String time,int orderStatus){ 76 | System.out.println("我接收了"+userId+" "+productId+" "+time+" "+orderStatus); 77 | ShoppingRecord shoppingRecord = shoppingRecordService.getShoppingRecord(userId,productId,time); 78 | System.out.println("我获取到了了"+shoppingRecord.getTime()); 79 | shoppingRecord.setOrderStatus(orderStatus); 80 | shoppingRecordService.updateShoppingRecord(shoppingRecord); 81 | 82 | Map resultMap = new HashMap(); 83 | resultMap.put("result","success"); 84 | System.out.println("我成功fanhui了"); 85 | return resultMap; 86 | } 87 | 88 | @RequestMapping(value = "/getShoppingRecords",method = RequestMethod.POST) 89 | @ResponseBody 90 | public Map getShoppingRecords(int userId){ 91 | List shoppingRecordList = shoppingRecordService.getShoppingRecords(userId); 92 | shoppingRecordList.forEach(e->{ 93 | System.out.println("在Controller中的productId,userId(买家),shopId(卖家)是:"+e.getProductId()+" " 94 | +e.getUserId()+" "+e.getShopId()+" "+e.getTime()+" "+e.getProductPrice()+" "+e.getCounts()+e.getOrderStatus()); 95 | }); 96 | String shoppingRecords = JSONArray.toJSONString(shoppingRecordList); 97 | Map resultMap = new HashMap(); 98 | resultMap.put("result",shoppingRecords); 99 | return resultMap; 100 | } 101 | 102 | @RequestMapping(value = "/getShoppingRecordsByOrderStatus",method = RequestMethod.POST) 103 | @ResponseBody 104 | public Map getShoppingRecordsByOrderStatus(int orderStatus){ 105 | List shoppingRecordList = shoppingRecordService.getShoppingRecordsByOrderStatus(orderStatus); 106 | String shoppingRecords = JSONArray.toJSONString(shoppingRecordList); 107 | Map resultMap = new HashMap(); 108 | resultMap.put("result",shoppingRecords); 109 | return resultMap; 110 | } 111 | 112 | @RequestMapping(value = "/getAllShoppingRecords",method = RequestMethod.POST) 113 | @ResponseBody 114 | public Map getAllShoppingRecords(){ 115 | // System.out.println("wo在这里i"); 116 | List shoppingRecordList = shoppingRecordService.getAllShoppingRecords(); 117 | System.out.println("这是controller"); 118 | for(int i=0;i resultMap = new HashMap(); 123 | resultMap.put("result",shoppingRecords); 124 | // System.out.println("我反悔了"+shoppingRecords); 125 | return resultMap; 126 | } 127 | 128 | @RequestMapping(value = "/getUserProductRecord",method = RequestMethod.POST) 129 | @ResponseBody 130 | public Map getUserProductRecord(int userId,int productId){ 131 | String result = "false"; 132 | if(shoppingRecordService.getUserProductRecord(userId,productId)){ 133 | result = "true"; 134 | } 135 | Map resultMap = new HashMap(); 136 | resultMap.put("result",result); 137 | return resultMap; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/AccessDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.bean.Access; 4 | 5 | import java.sql.*; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class AccessDAO { 10 | public AccessDAO() { 11 | try { 12 | Class.forName("com.mysql.jdbc.Driver"); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | public Connection getConnection() throws SQLException { 18 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 19 | "root", 20 | "root"); 21 | } 22 | 23 | /** 24 | * 查询商品的所有评价 25 | * @param goods_name 26 | * @return 27 | */ 28 | public List seleteAccessByGoods(String goods_name) { 29 | List accesses = new ArrayList(); 30 | try (Connection c = getConnection(); 31 | PreparedStatement ps = c.prepareStatement("select * from access where goods_name=?");) { 32 | ps.setString(1,goods_name); 33 | ResultSet rs = ps.executeQuery(); 34 | while (rs.next()) { 35 | Access access=new Access(); 36 | String user_account=rs.getString(1); 37 | String temp_goods_name=rs.getString(2); 38 | String content=rs.getString(3); 39 | //double price=rs.getDouble(3); 40 | //String temp_owner=rs.getString(4); 41 | access.setContent(content); 42 | access.setUser_account(user_account); 43 | access.setGoods_name(temp_goods_name); 44 | accesses.add(access); 45 | } 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | return accesses; 50 | } 51 | 52 | /** 53 | * 增加商品评价 54 | * @param access 55 | */ 56 | public void addAccess(Access access) { 57 | String sql = "insert into access values(?,?,?)"; 58 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 59 | ps.setString(1,access.getUser_account()); 60 | ps.setString(2,access.getGoods_name()); 61 | ps.setString(3,access.getContent()); 62 | ps.execute(); 63 | } catch (Exception e) { 64 | e.printStackTrace(); 65 | } 66 | } 67 | 68 | /** 69 | * 删除商品评价 70 | * @param access 71 | */ 72 | public void deleteAccess(Access access) { 73 | String sql = "delete from access where user_account = ? and goods_name = ?"; 74 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 75 | ps.setString(1,access.getUser_account()); 76 | ps.setString(2,access.getGoods_name()); 77 | ps.execute(); 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/AdminContentDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | 4 | import com.shopping.bean.AdminContent; 5 | 6 | import java.sql.*; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class AdminContentDAO { 11 | public AdminContentDAO() { 12 | try { 13 | Class.forName("com.mysql.jdbc.Driver"); 14 | } catch (Exception e) { 15 | e.printStackTrace(); 16 | } 17 | } 18 | public Connection getConnection() throws SQLException { 19 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT", 20 | "root", 21 | "root"); 22 | } 23 | public void addContent(AdminContent adminContent) { 24 | String sql = "insert into admincontent values(?)"; 25 | try (Connection c = getConnection(); 26 | PreparedStatement ps = c.prepareStatement(sql);) { 27 | ps.setString(1, adminContent.getContent()); 28 | ps.execute(); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | public List seleteAll() { 34 | List contents = new ArrayList(); 35 | String sql = "select * from admincontent"; 36 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 37 | ResultSet rs = ps.executeQuery(); 38 | while (rs.next()) { 39 | AdminContent content=new AdminContent(); 40 | String tempContent=rs.getString(1); 41 | content.setContent(tempContent); 42 | contents.add(content); 43 | } 44 | } catch (Exception e) { 45 | e.printStackTrace(); 46 | } 47 | return contents; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/CardDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Card; 4 | 5 | import java.util.List; 6 | 7 | public interface CardDao { 8 | public List getAllCards(); 9 | public List getCardsByUser(int userId); 10 | public void addCard(Card card); 11 | public List pageQuery(int start,int num); 12 | public boolean deleteCard(int id); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/CardDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Card; 4 | import org.hibernate.Query; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.*; 10 | 11 | @Repository 12 | public class CardDaoImplement implements CardDao{ 13 | 14 | @Resource 15 | private SessionFactory sessionFactory; 16 | 17 | @Override 18 | public List getAllCards() { 19 | 20 | String hql = "from Card"; 21 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 22 | return query.list(); 23 | } 24 | 25 | @Override 26 | public List pageQuery(int start,int num) { 27 | String hql = "from Card"; 28 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 29 | query.setFirstResult(start); 30 | query.setMaxResults(num); 31 | return query.list(); 32 | } 33 | 34 | @Override 35 | public boolean deleteCard(int id) { 36 | System.out.println("要删除的帖子id是 "+id); 37 | String hql = "delete Card where id=?"; 38 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 39 | query.setParameter(0, id); 40 | return query.executeUpdate() > 0; 41 | } 42 | 43 | @Override 44 | public List getCardsByUser(int userId) { 45 | String hql = "from Card where userId=?"; 46 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 47 | query.setParameter(0,userId); 48 | return query.list(); 49 | } 50 | 51 | @Override 52 | public void addCard(Card card) { 53 | System.out.println("发表content is "+card.getContent()); 54 | System.out.println(card); 55 | sessionFactory.getCurrentSession().save(card); 56 | 57 | } 58 | 59 | 60 | public static void main(String[] args){ 61 | CardDaoImplement cardDaoImplement=new CardDaoImplement(); 62 | Card card=new Card(); 63 | card.setUserId(0); 64 | card.setContent("llll"); 65 | // CardDaoImplement cardDaoImplement=new CardDaoImplement(); 66 | cardDaoImplement.addCard(card); 67 | /* List cardArrayList=new ArrayList<>(); 68 | cardArrayList= cardDaoImplement.getAllCards(); 69 | cardArrayList.forEach(e->{ 70 | System.out.println(e.getContent()); 71 | });*/ 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/EvaluationDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Evaluation; 4 | import com.sun.org.apache.xml.internal.serialize.LineSeparator; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by 14437 on 2017/3/7. 10 | */ 11 | public interface EvaluationDao { 12 | public Evaluation getEvaluation(int userId,int productId,String time); 13 | 14 | public void addEvaluation(Evaluation evaluation); 15 | 16 | public boolean deleteEvaluation(int userId,int productId,String time); 17 | 18 | public boolean updateEvaluation(Evaluation evaluation); 19 | 20 | public List getProductEvaluation(int productId); 21 | 22 | boolean deleteEvaluationByUser(int userId); 23 | 24 | boolean deleteEvaluationByProduct(int productId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/EvaluationDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Evaluation; 4 | import org.hibernate.Query; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by 14437 on 2017/3/7. 13 | */ 14 | @Repository 15 | public class EvaluationDaoImplement implements EvaluationDao { 16 | 17 | @Resource 18 | private SessionFactory sessionFactory; 19 | 20 | @Override 21 | public Evaluation getEvaluation(int userId, int productId, String time) { 22 | String hql = "from Evaluation where userId=? and productId=? and time=?"; 23 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 24 | query.setParameter(0, userId); 25 | query.setParameter(1, productId); 26 | query.setParameter(2, time); 27 | return (Evaluation) query.uniqueResult(); 28 | } 29 | 30 | @Override 31 | public void addEvaluation(Evaluation evaluation) { 32 | sessionFactory.getCurrentSession().save(evaluation); 33 | } 34 | 35 | @Override 36 | public boolean deleteEvaluation(int userId, int productId, String time) { 37 | String hql = "delete Evaluation where userId=? and productId=? and time=?"; 38 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 39 | query.setParameter(0, userId); 40 | query.setParameter(1, productId); 41 | query.setParameter(2, time); 42 | return query.executeUpdate() > 0; 43 | } 44 | 45 | @Override 46 | public boolean updateEvaluation(Evaluation evaluation) { 47 | String hql = "update Evaluation set content=? where userId=? and productId=? and time=?"; 48 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 49 | query.setParameter(0, evaluation.getContent()); 50 | query.setParameter(1, evaluation.getUserId()); 51 | query.setParameter(2, evaluation.getProductId()); 52 | query.setParameter(3, evaluation.getTime()); 53 | return query.executeUpdate() > 0; 54 | } 55 | 56 | @Override 57 | public List getProductEvaluation(int productId) { 58 | String hql = "from Evaluation where productId=?"; 59 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 60 | query.setParameter(0, productId); 61 | return query.list(); 62 | } 63 | 64 | @Override 65 | public boolean deleteEvaluationByUser(int userId) { 66 | String hql = "delete Evaluation where userId=?"; 67 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 68 | query.setParameter(0, userId); 69 | return query.executeUpdate() > 0; 70 | } 71 | 72 | @Override 73 | public boolean deleteEvaluationByProduct(int productId) { 74 | System.out.println("deleteEvaluationByProduct productId "+productId); 75 | String hql = "delete Evaluation where productId=?"; 76 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 77 | query.setParameter(0, productId); 78 | return query.executeUpdate() > 0; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/GoodsDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.bean.Goods; 4 | 5 | import java.sql.*; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class GoodsDAO { 10 | public GoodsDAO() { 11 | try { 12 | Class.forName("com.mysql.jdbc.Driver"); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | public Connection getConnection() throws SQLException { 18 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 19 | "root", 20 | "root"); 21 | } 22 | public void addGoods(Goods goods) { 23 | 24 | String sql = "insert into goods values(?,?,?,?)"; 25 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 26 | ps.setString(1,goods.getName()); 27 | ps.setString(2,goods.getPhoto()); 28 | ps.setDouble(3,goods.getPrice()); 29 | ps.setString(4,goods.getOwner()); 30 | ps.execute(); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | 36 | /** 37 | * 获取所有商品 38 | * @return 39 | */ 40 | public List seleteAll() { 41 | List goodss = new ArrayList(); 42 | String sql = "select * from goods"; 43 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 44 | ResultSet rs = ps.executeQuery(); 45 | while (rs.next()) { 46 | Goods goods=new Goods(); 47 | /*String account=rs.getString(1); 48 | String password=rs.getString(2); 49 | shop.setPassword(password); 50 | shop.setAccount(account); 51 | shops.add(shop);*/ 52 | String name=rs.getString(1); 53 | String photo=rs.getString(2); 54 | double price=rs.getDouble(3); 55 | String owner=rs.getString(4); 56 | goods.setPrice(price); 57 | goods.setPhoto(photo); 58 | goods.setOwner(owner); 59 | goods.setName(name); 60 | goodss.add(goods); 61 | } 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | return goodss; 66 | } 67 | public List seleteShopGoods(String owner) { 68 | List goodss = new ArrayList(); 69 | //String sql = "select * from goods owner=?"; 70 | try (Connection c = getConnection(); 71 | PreparedStatement ps = c.prepareStatement("select * from goods where owner=?");) { 72 | ps.setString(1,owner); 73 | ResultSet rs = ps.executeQuery(); 74 | while (rs.next()) { 75 | Goods goods=new Goods(); 76 | String name=rs.getString(1); 77 | String photo=rs.getString(2); 78 | double price=rs.getDouble(3); 79 | //String temp_owner=rs.getString(4); 80 | goods.setPrice(price); 81 | goods.setPhoto(photo); 82 | goods.setOwner(owner); 83 | goods.setName(name); 84 | goodss.add(goods); 85 | } 86 | } catch (Exception e) { 87 | e.printStackTrace(); 88 | } 89 | return goodss; 90 | } 91 | 92 | /** 93 | * 删除商品 94 | * @param name 95 | */ 96 | public void deleteGoods(String name) { 97 | try (Connection c=getConnection(); 98 | PreparedStatement ps=c.prepareStatement("delete from goods where name=?");){ 99 | ps.setString(1,name); 100 | ps.execute(); 101 | } catch (Exception e) { 102 | e.printStackTrace(); 103 | } 104 | } 105 | 106 | /** 107 | * 删除商家的所有商品 108 | * @param owner 109 | */ 110 | public void deleteOwnerGoods(String owner) { 111 | try (Connection c=getConnection(); 112 | PreparedStatement ps=c.prepareStatement("delete from goods where owner=?");){ 113 | ps.setString(1,owner); 114 | ps.execute(); 115 | } catch (Exception e) { 116 | e.printStackTrace(); 117 | } 118 | } 119 | 120 | /** 121 | * 模糊查找商品 122 | * @param temp_name 123 | * @return 124 | */ 125 | public List seleteGoods(String temp_name) { 126 | List goodss = new ArrayList(); 127 | //String sql = "select * from goods owner=?"; 128 | try (Connection c = getConnection(); 129 | PreparedStatement ps = c.prepareStatement( 130 | "select * ,(length(name)-length(?)) as rn from goods where name like ? order by rn");) { 131 | ps.setString(1,temp_name); 132 | ps.setString(2,"%"+temp_name+"%"); 133 | ResultSet rs = ps.executeQuery(); 134 | while (rs.next()) { 135 | Goods goods=new Goods(); 136 | String name=rs.getString(1); 137 | String photo=rs.getString(2); 138 | double price=rs.getDouble(3); 139 | String owner=rs.getString(4); 140 | goods.setPrice(price); 141 | goods.setPhoto(photo); 142 | goods.setOwner(owner); 143 | goods.setName(name); 144 | goodss.add(goods); 145 | } 146 | } catch (Exception e) { 147 | e.printStackTrace(); 148 | } 149 | return goodss; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ImageDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.bean.Goods; 4 | import com.shopping.bean.Image; 5 | 6 | import java.io.*; 7 | import java.sql.*; 8 | 9 | public class ImageDAO { 10 | InputStream in; 11 | public ImageDAO() { 12 | try { 13 | Class.forName("com.mysql.jdbc.Driver"); 14 | } catch (Exception e) { 15 | e.printStackTrace(); 16 | } 17 | } 18 | public Connection getConnection() throws SQLException { 19 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 20 | "root", 21 | "root"); 22 | } 23 | 24 | /** 25 | * 向数据库中插入一张图片 26 | * @param image 图片名 27 | */ 28 | public void addImage(Image image) { 29 | String sql = "insert into image values(?,?,?)"; 30 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 31 | InputStream inputStream= new ByteArrayInputStream(image.getPhoto()); 32 | ps.setString(1,image.getGood_name()); 33 | ps.setBinaryStream(2,inputStream,inputStream.available()); 34 | ps.setString(3,image.getDescription()); 35 | ps.execute(); 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | /** 42 | * 从数据库读取商品图片 43 | * @param good_name 商品名称 44 | * @return 商品图片地址 45 | */ 46 | public InputStream getImage(String good_name){ 47 | String sql = "select * from image where good_name = ?"; 48 | Image image = null; 49 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 50 | ps.setString(1,good_name); 51 | ResultSet rs = ps.executeQuery(); 52 | 53 | while (rs.next()) 54 | in = rs.getBinaryStream("photo"); 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | return in; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/OrderDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | 4 | import com.shopping.bean.Order; 5 | 6 | import java.sql.*; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class OrderDAO { 11 | public OrderDAO() { 12 | try { 13 | Class.forName("com.mysql.jdbc.Driver"); 14 | } catch (Exception e) { 15 | e.printStackTrace(); 16 | } 17 | } 18 | public Connection getConnection() throws SQLException { 19 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 20 | "root", 21 | "root"); 22 | } 23 | public void addOrder(Order temp_order) { 24 | String sql = "insert into `order` values(?,?,?,?,?,?,?)"; 25 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 26 | ps.setString(1,temp_order.getUser_account()); 27 | ps.setString(2,temp_order.getShop_account()); 28 | ps.setString(3,temp_order.getGoods_name()); 29 | ps.setInt(4,temp_order.getGoods_num()); 30 | ps.setDouble(5,temp_order.getSum()); 31 | ps.setDouble(7,temp_order.getGoods_price()); 32 | ps.setInt(6,0); 33 | ps.execute(); 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | } 38 | public List seleteOrderByUser(String user_account) { 39 | List orders = new ArrayList(); 40 | String sql = "select * from `order` where user_account=?"; 41 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 42 | ps.setString(1,user_account); 43 | ResultSet rs = ps.executeQuery(); 44 | while (rs.next()) { 45 | Order order=new Order(); 46 | //String user_account=rs.getString(1); 47 | String temp_user_account=rs.getString(1); 48 | String shop_account=rs.getString(2); 49 | String goods_name=rs.getString(3); 50 | int goods_num=rs.getInt(4); 51 | double sum=rs.getDouble(5); 52 | int status=rs.getInt(6); 53 | double goods_price=rs.getDouble(7); 54 | //post.setUser_account(user_account); 55 | order.setUser_account(temp_user_account); 56 | order.setShop_account(shop_account); 57 | order.setGoods_name(goods_name); 58 | order.setGoods_num(goods_num); 59 | order.setSum(sum); 60 | order.setStatus(status); 61 | order.setGoods_price(goods_price); 62 | orders.add(order); 63 | } 64 | } catch (Exception e) { 65 | e.printStackTrace(); 66 | } 67 | return orders; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/PageDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Card; 4 | import com.shopping.entity.Page; 5 | 6 | import java.util.List; 7 | 8 | public interface PageDao { 9 | public void addPage(Page page); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/PageDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Card; 4 | import com.shopping.entity.Page; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | @Repository 12 | public class PageDaoImplement implements PageDao { 13 | @Resource 14 | private SessionFactory sessionFactory; 15 | 16 | @Override 17 | public void addPage(Page page) { 18 | sessionFactory.getCurrentSession().save(page); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/PostDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.bean.Post; 4 | 5 | import java.sql.*; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class PostDAO { 10 | public PostDAO() { 11 | try { 12 | Class.forName("com.mysql.jdbc.Driver"); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | public Connection getConnection() throws SQLException { 18 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 19 | "root", 20 | "root"); 21 | } 22 | public void addPost(Post post) { 23 | String sql = "insert into post values(?,?)"; 24 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 25 | ps.setString(1,post.getUser_account()); 26 | ps.setString(2,post.getContent()); 27 | ps.execute(); 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | public List seleteAll() { 33 | List posts = new ArrayList(); 34 | String sql = "select * from post"; 35 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 36 | ResultSet rs = ps.executeQuery(); 37 | while (rs.next()) { 38 | Post post=new Post(); 39 | String user_account=rs.getString(1); 40 | String content=rs.getString(2); 41 | post.setUser_account(user_account); 42 | post.setContent(content); 43 | posts.add(post); 44 | } 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | return posts; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/PostStatusDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import java.sql.*; 4 | 5 | public class PostStatusDAO { 6 | public PostStatusDAO() { 7 | try { 8 | Class.forName("com.mysql.jdbc.Driver"); 9 | } catch (Exception e) { 10 | e.printStackTrace(); 11 | } 12 | } 13 | public Connection getConnection() throws SQLException { 14 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 15 | "root", 16 | "root"); 17 | } 18 | public int selectStatus() { 19 | int status=0; 20 | String sql = "select status from poststatus limit 1"; 21 | try (Connection c = getConnection(); 22 | PreparedStatement ps = c.prepareStatement(sql);) { 23 | ResultSet rs=ps.executeQuery(); 24 | status=rs.getInt(1); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | return status; 29 | } 30 | public void updateStatus(int num) { 31 | String sql = "update poststatus set status= ? where id=1"; 32 | try (Connection c = getConnection(); 33 | PreparedStatement ps = c.prepareStatement(sql);) { 34 | ps.setInt(1,num); 35 | ps.execute(); 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ProductDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Product; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/1. 9 | */ 10 | public interface ProductDao { 11 | public Product getProduct(int id); 12 | 13 | public List getProductsByBoss(int bossId); 14 | 15 | public Product getProduct(String name); 16 | 17 | public void addProduct(Product product); 18 | 19 | public boolean deleteProduct(int id); 20 | 21 | public boolean updateProduct(Product product); 22 | 23 | public List getProductsByKeyWord(String searchKeyWord); 24 | 25 | public List getProductsByType(int type); 26 | 27 | public List getAllProduct(); 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ProductDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.Product; 4 | import org.hibernate.Query; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by 14437 on 2017/3/1. 13 | */ 14 | @Repository 15 | public class ProductDaoImplement implements ProductDao { 16 | @Resource 17 | private SessionFactory sessionFactory; 18 | 19 | @Override 20 | public Product getProduct(int id) { 21 | String hql = "from Product where id=?"; 22 | System.out.println("现在在ProductDao里面啊啊啊啊啊"); 23 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 24 | query.setParameter(0, id); 25 | Product product=(Product) query.uniqueResult(); 26 | System.out.println("在ProduDao里面 product Name is(也就是真正查询出来的东西) "+product.getName()); 27 | return (Product) query.uniqueResult(); 28 | } 29 | 30 | 31 | @Override 32 | public Product getProduct(String name) { 33 | String hql = "from Product where name=?"; 34 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 35 | query.setParameter(0,name); 36 | return (Product) query.uniqueResult(); 37 | } 38 | 39 | @Override 40 | public void addProduct(Product product) { 41 | sessionFactory.getCurrentSession().save(product); 42 | } 43 | 44 | @Override 45 | public boolean deleteProduct(int id) { 46 | System.out.println("要删除的商品id是 "+id); 47 | String hql = "delete Product where id=?"; 48 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 49 | query.setParameter(0, id); 50 | return query.executeUpdate() > 0; 51 | } 52 | 53 | 54 | 55 | @Override 56 | public boolean updateProduct(Product product) { 57 | String hql = "update Product set name=?,description=?,keyWord=?,price=?,counts=?,type=? where id=?"; 58 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 59 | query.setParameter(0,product.getName()); 60 | query.setParameter(1,product.getDescription()); 61 | query.setParameter(2,product.getKeyWord()); 62 | query.setParameter(3,product.getPrice()); 63 | query.setParameter(4,product.getCounts()); 64 | query.setParameter(5,product.getType()); 65 | query.setParameter(6,product.getId()); 66 | return query.executeUpdate() > 0; 67 | } 68 | 69 | @Override 70 | public List getProductsByKeyWord(String searchKeyWord) { 71 | String queryKeyWord = "%"; 72 | for(int i=0;i getProductsByType(int type) { 85 | String hql = "from Product where type=?"; 86 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 87 | query.setParameter(0,type); 88 | return query.list(); 89 | } 90 | 91 | @Override 92 | public List getProductsByBoss(int bossId) { 93 | String hql = "from Product where bossId=?"; 94 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 95 | query.setParameter(0,bossId); 96 | return query.list(); 97 | } 98 | 99 | 100 | @Override 101 | public List getAllProduct() { 102 | String hql = "from Product"; 103 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 104 | return query.list(); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ProductTypeDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.ProductType; 4 | 5 | import java.util.List; 6 | 7 | public interface ProductTypeDao { 8 | public List getAllProductTypes(); 9 | public void addProductTypes(ProductType productType); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ProductTypeDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.ProductType; 4 | import org.hibernate.Query; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | @Repository 11 | public class ProductTypeDaoImplement implements ProductTypeDao { 12 | 13 | @Resource 14 | private SessionFactory sessionFactory; 15 | 16 | 17 | @Override 18 | public List getAllProductTypes() { 19 | String hql = "from ProductType"; 20 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 21 | return query.list(); 22 | } 23 | 24 | @Override 25 | public void addProductTypes(ProductType productType) { 26 | sessionFactory.getCurrentSession().save(productType); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ShopDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | 4 | import com.shopping.bean.Shop; 5 | 6 | import java.sql.*; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class ShopDAO { 11 | public ShopDAO() { 12 | try { 13 | Class.forName("com.mysql.jdbc.Driver"); 14 | } catch (Exception e) { 15 | e.printStackTrace(); 16 | } 17 | } 18 | public Connection getConnection() throws SQLException { 19 | return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/finaltest?characterEncoding=UTF-8&serverTimezone=GMT", 20 | "root", 21 | "root"); 22 | } 23 | public void addShop(Shop shop) { 24 | String sql = "insert into shop values(?,?)"; 25 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 26 | ps.setString(1, shop.getAccount()); 27 | ps.setString(2, shop.getPassword()); 28 | ps.execute(); 29 | } catch (SQLException e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | 34 | /** 35 | * 查询商家是否存在 36 | * @return boolean 37 | */ 38 | public boolean shopExists(String account){ 39 | boolean hasShop=false; 40 | String sql = "select * from shop where account = ?"; 41 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 42 | ps.setString(1,account); 43 | ResultSet rs = ps.executeQuery(); 44 | rs.last(); 45 | if (rs.getRow()!=0)hasShop=true; 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | return hasShop; 50 | } 51 | 52 | public List seleteAll() { 53 | List shops = new ArrayList(); 54 | String sql = "select * from shop"; 55 | try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) { 56 | ResultSet rs = ps.executeQuery(); 57 | while (rs.next()) { 58 | Shop shop = new Shop(); 59 | String account=rs.getString(1); 60 | String password=rs.getString(2); 61 | shop.setPassword(password); 62 | shop.setAccount(account); 63 | shops.add(shop); 64 | } 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | } 68 | return shops; 69 | } 70 | public void deleteShop(String account) { 71 | try (Connection c=getConnection(); 72 | PreparedStatement ps=c.prepareStatement("delete from shop where account=?");){ 73 | ps.setString(1,account); 74 | ps.execute(); 75 | } catch (Exception e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ShoppingCarDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.ShoppingCar; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/3. 9 | */ 10 | public interface ShoppingCarDao { 11 | ShoppingCar getShoppingCar(int userId,int productId); 12 | 13 | 14 | 15 | void addShoppingCar(ShoppingCar shoppingCar); 16 | 17 | boolean deleteShoppingCar(int userId,int productId); 18 | 19 | boolean updateShoppingCar(ShoppingCar shoppingCar); 20 | 21 | List getShoppingCars(int userId); 22 | 23 | boolean deleteShoppingCarByUser(int userId); 24 | 25 | boolean deleteShoppingCarByProduct(int productId); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ShoppingCarDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.ShoppingCar; 4 | import org.hibernate.Query; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by 14437 on 2017/3/3. 13 | */ 14 | 15 | @Repository 16 | public class ShoppingCarDaoImplement implements ShoppingCarDao { 17 | @Resource 18 | private SessionFactory sessionFactory; 19 | 20 | @Override 21 | public ShoppingCar getShoppingCar(int userId, int productId) { 22 | String hql = "from ShoppingCar where userId=? and productId=?"; 23 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 24 | query.setParameter(0, userId); 25 | query.setParameter(1, productId); 26 | return (ShoppingCar) query.uniqueResult(); 27 | } 28 | 29 | @Override 30 | public void addShoppingCar(ShoppingCar shoppingCar) { 31 | sessionFactory.getCurrentSession().save(shoppingCar); 32 | } 33 | 34 | @Override 35 | public boolean deleteShoppingCar(int userId, int productId) { 36 | String hql = "delete ShoppingCar where userId=? and productId=?"; 37 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 38 | query.setParameter(0, userId); 39 | query.setParameter(1, productId); 40 | return query.executeUpdate() > 0; 41 | } 42 | 43 | @Override 44 | public boolean updateShoppingCar(ShoppingCar shoppingCar) { 45 | String hql = "update ShoppingCar set productPrice=?,counts=? where userId=? and productId=?"; 46 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 47 | query.setParameter(0,shoppingCar.getProductPrice()); 48 | query.setParameter(1,shoppingCar.getCounts()); 49 | query.setParameter(2,shoppingCar.getUserId()); 50 | query.setParameter(3,shoppingCar.getProductId()); 51 | return query.executeUpdate() > 0; 52 | } 53 | 54 | @Override 55 | public List getShoppingCars(int userId) { 56 | String hql = "from ShoppingCar where userId=?"; 57 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 58 | query.setParameter(0,userId); 59 | return query.list(); 60 | } 61 | 62 | @Override 63 | public boolean deleteShoppingCarByUser(int userId) { 64 | String hql = "delete ShoppingCar where userId=?"; 65 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 66 | query.setParameter(0, userId); 67 | return query.executeUpdate() > 0; 68 | } 69 | 70 | @Override 71 | public boolean deleteShoppingCarByProduct(int productId) { 72 | System.out.println("deleteShoppingCarByProduct productId is "+productId); 73 | String hql = "delete ShoppingCar where productId=?"; 74 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 75 | query.setParameter(0, productId); 76 | return query.executeUpdate() > 0; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ShoppingRecordDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.ShoppingRecord; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/3. 9 | */ 10 | public interface ShoppingRecordDao { 11 | ShoppingRecord getShoppingRecord(int userId, int productId,String time); 12 | 13 | void addShoppingRecord(ShoppingRecord shoppingRecord); 14 | 15 | boolean deleteShoppingRecord(int userId,int productId); 16 | 17 | 18 | 19 | boolean updateShoppingRecord(ShoppingRecord shoppingRecord); 20 | 21 | List getShoppingRecords(int userId); 22 | 23 | List getAllShoppingRecords(); 24 | 25 | List getShoppingRecordsByOrderStatus(int orderStatus); 26 | 27 | boolean getUserProductRecord(int userId,int productId); 28 | 29 | boolean deleteShoppingRecordByUser(int userId); 30 | 31 | boolean deleteShoppingRecordByProductId(int productId); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/ShoppingRecordDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.ShoppingCar; 4 | import com.shopping.entity.ShoppingRecord; 5 | import org.hibernate.Query; 6 | import org.hibernate.SessionFactory; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by 14437 on 2017/3/3. 15 | */ 16 | @Repository 17 | public class ShoppingRecordDaoImplement implements ShoppingRecordDao { 18 | @Resource 19 | private SessionFactory sessionFactory; 20 | 21 | @Override 22 | public ShoppingRecord getShoppingRecord(int userId, int productId,String time) { 23 | String hql = "from ShoppingRecord where userId=? and productId=? and time=?"; 24 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 25 | query.setParameter(0, userId); 26 | query.setParameter(1, productId); 27 | query.setParameter(2, time); 28 | return (ShoppingRecord) query.uniqueResult(); 29 | } 30 | 31 | @Override 32 | public void addShoppingRecord(ShoppingRecord shoppingRecord) { 33 | System.out.println("传到ShoppingRecordDao里的shopId is "+shoppingRecord.getShopId()); 34 | sessionFactory.getCurrentSession().save(shoppingRecord); 35 | } 36 | 37 | @Override 38 | public boolean deleteShoppingRecord(int userId, int productId) { 39 | String hql = "delete ShoppingRecord where userId=? and productId=?"; 40 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 41 | query.setParameter(0, userId); 42 | query.setParameter(1, productId); 43 | return query.executeUpdate() > 0; 44 | } 45 | 46 | @Override 47 | public boolean updateShoppingRecord(ShoppingRecord shoppingRecord) { 48 | String hql = "update ShoppingReocrd set orderStatus=? where userId=? and productId=? and time=?"; 49 | String sql = "update shopping_record set order_status="+shoppingRecord.getOrderStatus()+" where user_id="+shoppingRecord.getUserId()+" and product_id="+shoppingRecord.getProductId()+" and time='"+shoppingRecord.getTime()+"'"; 50 | // Query query = sessionFactory.getCurrentSession().createQuery(hql); 51 | // query.setParameter(0,shoppingRecord.getOrderStatus()); 52 | // query.setParameter(1,shoppingRecord.getUserId()); 53 | // query.setParameter(2,shoppingRecord.getProductId()); 54 | // query.setParameter(3,shoppingRecord.getTime()); 55 | Query query = sessionFactory.getCurrentSession().createSQLQuery(sql); 56 | return query.executeUpdate() > 0; 57 | } 58 | 59 | @Override 60 | public List getShoppingRecords(int userId) { 61 | String hql = "from ShoppingRecord where userId=?"; 62 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 63 | query.setParameter(0,userId); 64 | List shoppingRecordList=query.list(); 65 | System.out.println("shoppingRecordList的大小是 "+shoppingRecordList.size()); 66 | for(int i=0;i getAllShoppingRecords() { 78 | String hql = "from ShoppingRecord "; 79 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 80 | List records=new ArrayList<>(); 81 | records=query.list(); 82 | System.out.println("这里是dao"); 83 | for(int i=0;i getShoppingRecordsByOrderStatus(int orderStatus) { 91 | String hql = "from ShoppingRecord where orderStatus=?"; 92 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 93 | query.setParameter(0,orderStatus); 94 | return query.list(); 95 | } 96 | 97 | @Override 98 | public boolean getUserProductRecord(int userId,int productId) { 99 | String hql = "from ShoppingRecord where userId=? and productId=?"; 100 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 101 | query.setParameter(0,userId); 102 | query.setParameter(1,productId); 103 | return query.list().size()>0; 104 | } 105 | 106 | @Override 107 | public boolean deleteShoppingRecordByUser(int userId) { 108 | String hql = "delete ShoppingRecord where userId=?"; 109 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 110 | query.setParameter(0, userId); 111 | return query.executeUpdate() > 0; 112 | } 113 | 114 | @Override 115 | public boolean deleteShoppingRecordByProductId(int productId) { 116 | System.out.println("deleteShoppingRecordByProductId id"+productId); 117 | String hql = "delete ShoppingRecord where productId=?"; 118 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 119 | query.setParameter(0, productId); 120 | return query.executeUpdate() > 0; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/UserDAO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/1. 9 | */ 10 | public interface UserDao { 11 | 12 | public User getUser(int id); 13 | 14 | public User getUser(String nameOrEmail); 15 | 16 | public void addUser(User user); 17 | 18 | public boolean deleteUser(int id); 19 | 20 | public boolean updateUser(User user); 21 | 22 | public List getAllUser(); 23 | 24 | public boolean becomeVip(int userId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/UserDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.User; 4 | import com.shopping.entity.UserDetail; 5 | import org.hibernate.Query; 6 | import org.hibernate.SessionFactory; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by 14437 on 2017/3/1. 14 | */ 15 | @Repository 16 | public class UserDaoImplement implements UserDao { 17 | 18 | @Resource 19 | private SessionFactory sessionFactory; 20 | 21 | @Override 22 | public User getUser(int id) { 23 | String hql = "from User where id=?"; 24 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 25 | query.setParameter(0, id); 26 | User user=new User(); 27 | user=(User)query.uniqueResult(); 28 | System.out.println("this is UserDao"); 29 | System.out.println("userId is "+user.getId()); 30 | return (User)query.uniqueResult(); 31 | } 32 | 33 | @Override 34 | public User getUser(String nameOrEmail) { 35 | System.out.println("进入查询"); 36 | String hql = "from User where email=?"; 37 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 38 | query.setParameter(0, nameOrEmail); 39 | System.out.println("email is "+query.uniqueResult()); 40 | if(query.uniqueResult() == null){ 41 | hql = "from User where name=?"; 42 | query = sessionFactory.getCurrentSession().createQuery(hql); 43 | query.setParameter(0, nameOrEmail); 44 | } 45 | return (User)query.uniqueResult(); 46 | } 47 | 48 | @Override 49 | public void addUser(User user) { 50 | sessionFactory.getCurrentSession().save(user); 51 | } 52 | 53 | @Override 54 | public boolean deleteUser(int id) { 55 | String hql = "delete User where id=?"; 56 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 57 | query.setParameter(0, id); 58 | return query.executeUpdate() > 0; 59 | } 60 | 61 | @Override 62 | public boolean updateUser(User user) { 63 | String hql = "update User set name = ?,email=?,nickName=? where id=?"; 64 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 65 | query.setParameter(0,user.getName()); 66 | query.setParameter(1,user.getEmail()); 67 | query.setParameter(2,user.getNickName()); 68 | query.setParameter(3,user.getId()); 69 | return query.executeUpdate() > 0; 70 | } 71 | 72 | @Override 73 | public List getAllUser() { 74 | String hql = "from User"; 75 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 76 | return query.list(); 77 | } 78 | 79 | @Override 80 | public boolean becomeVip(int userId) { 81 | String hql = "update User set role=? where id=?"; 82 | 83 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 84 | query.setParameter(0,2); 85 | query.setParameter(1,userId); 86 | 87 | return query.executeUpdate() > 0; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/UserDetailDao.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.UserDetail; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/1. 9 | */ 10 | public interface UserDetailDao { 11 | 12 | public UserDetail getUserDetail(int id); 13 | 14 | public void addUserDetail(UserDetail userDetail); 15 | 16 | public boolean deleteUserDetail(int id); 17 | 18 | public boolean updateUserDetail(UserDetail userDetail); 19 | 20 | public List getAllUserDetail(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/dao/UserDetailDaoImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.dao; 2 | 3 | import com.shopping.entity.UserDetail; 4 | import org.hibernate.Query; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by 14437 on 2017/3/1. 13 | */ 14 | @Repository 15 | public class UserDetailDaoImplement implements UserDetailDao{ 16 | 17 | @Resource 18 | private SessionFactory sessionFactory; 19 | 20 | @Override 21 | public UserDetail getUserDetail(int id) { 22 | String hql = "from UserDetail where id=?"; 23 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 24 | query.setParameter(0, id); 25 | return (UserDetail)query.uniqueResult(); 26 | } 27 | 28 | @Override 29 | public void addUserDetail(UserDetail userDetail) { 30 | sessionFactory.getCurrentSession().save(userDetail); 31 | } 32 | 33 | @Override 34 | public boolean deleteUserDetail(int id) { 35 | String hql = "delete UserDetail where id=?"; 36 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 37 | query.setParameter(0, id); 38 | return query.executeUpdate() > 0; 39 | } 40 | 41 | @Override 42 | public boolean updateUserDetail(UserDetail userDetail) { 43 | String hql = "update UserDetail set password=?,phoneNumber=?,sex=?,birthday=?,postNumber=?,address=? where id=?"; 44 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 45 | query.setParameter(0,userDetail.getPassword()); 46 | query.setParameter(1,userDetail.getPhoneNumber()); 47 | query.setParameter(2,userDetail.getSex()); 48 | query.setParameter(3,userDetail.getBirthday()); 49 | query.setParameter(4,userDetail.getPostNumber()); 50 | query.setParameter(5,userDetail.getAddress()); 51 | query.setParameter(6,userDetail.getId()); 52 | return query.executeUpdate() > 0; 53 | } 54 | 55 | @Override 56 | public List getAllUserDetail() { 57 | String hql = "from UserDetail"; 58 | Query query = sessionFactory.getCurrentSession().createQuery(hql); 59 | return query.list(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/Card.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | import org.hibernate.annotations.GenericGenerator; 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | import javax.persistence.*; 6 | @Entity 7 | @Table(name="card") 8 | public class Card { 9 | private int id; 10 | private int userId; 11 | private String content; 12 | 13 | @Id 14 | @Column(name = "id") 15 | @GenericGenerator(name = "generator", strategy = "increment") //设置主键自增 16 | @GeneratedValue(generator = "generator") 17 | public int getId() { 18 | return id; 19 | } 20 | 21 | public void setId(int id) { 22 | this.id = id; 23 | } 24 | 25 | 26 | 27 | @Column(name="user_id") 28 | public int getUserId() { 29 | return userId; 30 | } 31 | 32 | public void setUserId(int userId) { 33 | this.userId = userId; 34 | } 35 | 36 | @Column(name="content") 37 | public String getContent() { 38 | return content; 39 | } 40 | 41 | public void setContent(String content) { 42 | this.content = content; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/Evaluation.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by 14437 on 2017/3/7. 7 | */ 8 | @Entity 9 | @Table(name="evaluation") 10 | @IdClass(value=ShoppingRecordPriKey.class) 11 | public class Evaluation { 12 | private int userId; 13 | private int productId; 14 | private String time; 15 | private String content; 16 | 17 | @Id 18 | @Column(name="user_id") 19 | public int getUserId() { 20 | return userId; 21 | } 22 | 23 | public void setUserId(int userId) { 24 | this.userId = userId; 25 | } 26 | 27 | @Id 28 | @Column(name="product_id") 29 | public int getProductId() { 30 | return productId; 31 | } 32 | 33 | public void setProductId(int productId) { 34 | this.productId = productId; 35 | } 36 | 37 | @Id 38 | @Column(name="time") 39 | public String getTime() { 40 | return time; 41 | } 42 | 43 | public void setTime(String time) { 44 | this.time = time; 45 | } 46 | 47 | @Column(name="content") 48 | public String getContent() { 49 | return content; 50 | } 51 | 52 | public void setContent(String content) { 53 | this.content = content; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/Page.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import org.hibernate.annotations.GenericGenerator; 4 | 5 | import javax.persistence.*; 6 | import java.util.List; 7 | @Entity 8 | @Table(name = "page") 9 | public class Page { 10 | private int id; 11 | private int pageSize; 12 | private int beginIndex; 13 | 14 | @Id 15 | @Column(name = "id") 16 | @GenericGenerator(name = "generator", strategy = "increment") //设置主键自增 17 | @GeneratedValue(generator = "generator") 18 | public int getId() { 19 | return id; 20 | } 21 | 22 | public void setId(int id) { 23 | this.id = id; 24 | } 25 | 26 | @Column(name = "page_size") 27 | public int getPageSize() { 28 | return pageSize; 29 | } 30 | 31 | public void setPageSize(int pageSize) { 32 | this.pageSize = pageSize; 33 | } 34 | 35 | @Column(name = "begin_index") 36 | public int getBeginIndex() { 37 | return beginIndex; 38 | } 39 | 40 | public void setBeginIndex(int beginIndex) { 41 | this.beginIndex = beginIndex; 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import org.hibernate.annotations.GenericGenerator; 4 | 5 | import javax.persistence.*; 6 | 7 | 8 | 9 | @Entity 10 | @Table(name="products") 11 | 12 | public class Product { 13 | private int id; 14 | private String name; 15 | private String description; 16 | private String keyWord; 17 | private int price; 18 | private int counts; 19 | private int type; 20 | private int bossId; 21 | private String img; 22 | 23 | @Id 24 | @GenericGenerator(name = "generator", strategy = "increment") //设置主键自增 25 | @GeneratedValue(generator = "generator") 26 | 27 | @Column(name="id") 28 | public int getId() { 29 | return id; 30 | } 31 | 32 | public void setId(int id) { 33 | this.id = id; 34 | } 35 | 36 | @Column(name="name") 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | @Column(name="description") 46 | public String getDescription() { 47 | return description; 48 | } 49 | 50 | public void setDescription(String description) { 51 | this.description = description; 52 | } 53 | 54 | @Column(name="key_word") 55 | public String getKeyWord() { 56 | return keyWord; 57 | } 58 | 59 | public void setKeyWord(String keyWord) { 60 | this.keyWord = keyWord; 61 | } 62 | 63 | @Column(name="price") 64 | public int getPrice() { 65 | return price; 66 | } 67 | 68 | public void setPrice(int price) { 69 | this.price = price; 70 | } 71 | 72 | @Column(name="counts") 73 | public int getCounts() { 74 | return counts; 75 | } 76 | 77 | public void setCounts(int counts) { 78 | this.counts = counts; 79 | } 80 | 81 | @Column(name="type") 82 | public int getType() { 83 | return type; 84 | } 85 | 86 | public void setType(int type) { 87 | this.type = type; 88 | } 89 | 90 | 91 | @Column(name="boss_id") 92 | public int getBossId() { 93 | return bossId; 94 | } 95 | 96 | public void setBossId(int bossId) { 97 | this.bossId = bossId; 98 | } 99 | 100 | @Column(name = "img") 101 | 102 | public String getImg() { 103 | return img; 104 | } 105 | 106 | public void setImg(String img) { 107 | this.img = img; 108 | } 109 | } 110 | 111 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/ProductType.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import org.hibernate.annotations.GenericGenerator; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | 9 | public class ProductType { 10 | private int id; 11 | private String type; 12 | 13 | @Id 14 | @Column(name = "id") 15 | @GenericGenerator(name = "generator", strategy = "increment") //设置主键自增 16 | @GeneratedValue(generator = "generator") 17 | 18 | public int getId() { 19 | return id; 20 | } 21 | 22 | public void setId(int id) { 23 | this.id = id; 24 | } 25 | @Column(name = "type") 26 | public String getType() { 27 | return type; 28 | } 29 | 30 | public void setType(String type) { 31 | this.type = type; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/ShoppingCar.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by 14437 on 2017/3/3. 7 | */ 8 | @Entity 9 | @Table(name="shopping_car") 10 | @IdClass(value=ShoppingCarPriKey.class) 11 | public class ShoppingCar { 12 | private int userId; 13 | private int productId; 14 | private int productPrice; 15 | private int counts; 16 | 17 | @Id 18 | @Column(name="user_id") 19 | public int getUserId() { 20 | return userId; 21 | } 22 | 23 | public void setUserId(int userId) { 24 | this.userId = userId; 25 | } 26 | 27 | @Id 28 | @Column(name="product_id") 29 | public int getProductId() { 30 | return productId; 31 | } 32 | 33 | public void setProductId(int productId) { 34 | this.productId = productId; 35 | } 36 | 37 | @Column(name="product_price") 38 | public int getProductPrice() { 39 | return productPrice; 40 | } 41 | 42 | public void setProductPrice(int productPrice) { 43 | this.productPrice = productPrice; 44 | } 45 | 46 | @Column(name="counts") 47 | public int getCounts() { 48 | return counts; 49 | } 50 | 51 | public void setCounts(int counts) { 52 | this.counts = counts; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/ShoppingCarPriKey.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by 14437 on 2017/3/3. 7 | */ 8 | public class ShoppingCarPriKey implements Serializable { 9 | private int userId; 10 | private int productId; 11 | 12 | public int getUserId() { 13 | return userId; 14 | } 15 | 16 | public void setUserId(int userId) { 17 | this.userId = userId; 18 | } 19 | 20 | public int getProductId() { 21 | return productId; 22 | } 23 | 24 | public void setProductId(int productId) { 25 | this.productId = productId; 26 | } 27 | 28 | @Override 29 | public boolean equals(Object o) { 30 | if (this == o) return true; 31 | if (!(o instanceof ShoppingCarPriKey)) return false; 32 | 33 | ShoppingCarPriKey that = (ShoppingCarPriKey) o; 34 | 35 | if (userId != that.userId) return false; 36 | return productId == that.productId; 37 | 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | int result = userId; 43 | result = 31 * result + productId; 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/ShoppingRecord.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by 14437 on 2017/3/3. 7 | */ 8 | @Entity 9 | @Table(name="shopping_record") 10 | @IdClass(value=ShoppingRecordPriKey.class) 11 | public class ShoppingRecord { 12 | private int userId; 13 | private int productId; 14 | private String time; 15 | private int orderStatus; 16 | private int productPrice; 17 | private int counts; 18 | private int shopId; 19 | 20 | @Id 21 | @Column(name="user_id") 22 | public int getUserId() { 23 | return userId; 24 | } 25 | 26 | public void setUserId(int userId) { 27 | this.userId = userId; 28 | } 29 | 30 | @Id 31 | @Column(name="product_id") 32 | public int getProductId() { 33 | return productId; 34 | } 35 | 36 | public void setProductId(int productId) { 37 | this.productId = productId; 38 | } 39 | 40 | @Id 41 | @Column(name="time") 42 | public String getTime() { 43 | return time; 44 | } 45 | 46 | public void setTime(String time) { 47 | this.time = time; 48 | } 49 | 50 | @Column(name="order_status") 51 | public int getOrderStatus() { 52 | return orderStatus; 53 | } 54 | 55 | public void setOrderStatus(int orderStatus) { 56 | this.orderStatus = orderStatus; 57 | } 58 | 59 | @Column(name="product_price") 60 | public int getProductPrice() { 61 | return productPrice; 62 | } 63 | 64 | public void setProductPrice(int productPrice) { 65 | this.productPrice = productPrice; 66 | } 67 | 68 | @Column(name="counts") 69 | public int getCounts() { 70 | return counts; 71 | } 72 | 73 | public void setCounts(int counts) { 74 | this.counts = counts; 75 | } 76 | 77 | @Id 78 | @Column(name = "shop_id") 79 | 80 | public int getShopId() { 81 | return shopId; 82 | } 83 | 84 | public void setShopId(int shopId) { 85 | this.shopId = shopId; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/ShoppingRecordPriKey.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by 14437 on 2017/3/3. 7 | */ 8 | public class ShoppingRecordPriKey implements Serializable { 9 | private int userId; 10 | private String time; 11 | 12 | 13 | 14 | public int getUserId() { 15 | return userId; 16 | } 17 | 18 | public void setUserId(int userId) { 19 | this.userId = userId; 20 | } 21 | 22 | 23 | 24 | public String getTime() { 25 | return time; 26 | } 27 | 28 | public void setTime(String time) { 29 | this.time = time; 30 | } 31 | 32 | 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (!(o instanceof ShoppingRecordPriKey)) return false; 38 | 39 | ShoppingRecordPriKey that = (ShoppingRecordPriKey) o; 40 | 41 | 42 | return getTime().equals(that.getTime()); 43 | 44 | } 45 | 46 | @Override 47 | public int hashCode() { 48 | int result = getUserId(); 49 | result = 31 * result + getTime().hashCode(); 50 | return result; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import org.hibernate.annotations.GenericGenerator; 4 | 5 | import javax.persistence.*; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/1. 9 | */ 10 | 11 | @Entity 12 | @Table(name="user_main") 13 | public class User { 14 | 15 | private int id; 16 | private String name; 17 | private String email; 18 | private String nickName; 19 | private int role; 20 | 21 | @Id 22 | @GenericGenerator(name = "generator", strategy = "increment") //设置主键自增 23 | @GeneratedValue(generator = "generator") 24 | 25 | @Column(name="id") 26 | public int getId() { 27 | return id; 28 | } 29 | 30 | public void setId(int id) { 31 | this.id = id; 32 | } 33 | 34 | @Column(name="name") 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @Column(name="email") 44 | public String getEmail() { 45 | return email; 46 | } 47 | 48 | public void setEmail(String email) { 49 | this.email = email; 50 | } 51 | 52 | @Column(name="nick_name") 53 | public String getNickName() { 54 | return nickName; 55 | } 56 | 57 | 58 | public void setNickName(String nickName) { 59 | this.nickName = nickName; 60 | } 61 | 62 | @Column(name="role") 63 | public int getRole() { 64 | return role; 65 | } 66 | 67 | public void setRole(int role) { 68 | this.role = role; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/entity/UserDetail.java: -------------------------------------------------------------------------------- 1 | package com.shopping.entity; 2 | 3 | import org.hibernate.annotations.GenericGenerator; 4 | 5 | import javax.persistence.*; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/1. 9 | */ 10 | @Entity 11 | @Table(name="user_detail") 12 | public class UserDetail { 13 | private int id; 14 | private String password; 15 | private String phoneNumber; 16 | private int sex; 17 | private String birthday; 18 | private String postNumber; 19 | private String address; 20 | private String registerTime; 21 | 22 | @Id 23 | @GenericGenerator(name = "generator", strategy = "assigned") 24 | @GeneratedValue(generator = "generator") 25 | 26 | @Column(name="id") 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | public void setId(int id) { 32 | this.id = id; 33 | } 34 | 35 | @Column(name="password") 36 | public String getPassword() { 37 | return password; 38 | } 39 | 40 | public void setPassword(String password) { 41 | this.password = password; 42 | } 43 | @Column(name="phone_number") 44 | public String getPhoneNumber() { 45 | return phoneNumber; 46 | } 47 | 48 | public void setPhoneNumber(String phoneNumber) { 49 | this.phoneNumber = phoneNumber; 50 | } 51 | 52 | @Column(name="sex") 53 | public int getSex() { 54 | return sex; 55 | } 56 | 57 | public void setSex(int sex) { 58 | this.sex = sex; 59 | } 60 | 61 | @Column(name="birthday") 62 | public String getBirthday() { 63 | return birthday; 64 | } 65 | 66 | public void setBirthday(String birthday) { 67 | this.birthday = birthday; 68 | } 69 | 70 | @Column(name="post_number") 71 | public String getPostNumber() { 72 | return postNumber; 73 | } 74 | 75 | public void setPostNumber(String postNumber) { 76 | this.postNumber = postNumber; 77 | } 78 | 79 | @Column(name="address") 80 | public String getAddress() { 81 | return address; 82 | } 83 | 84 | public void setAddress(String address) { 85 | this.address = address; 86 | } 87 | 88 | @Column(name="register_time") 89 | public String getRegisterTime() { 90 | return registerTime; 91 | } 92 | 93 | public void setRegisterTime(String registerTime) { 94 | this.registerTime = registerTime; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/filter/EncodingFilter.java: -------------------------------------------------------------------------------- 1 | package com.shopping.Filter; 2 | 3 | import javax.servlet.*; 4 | import java.io.IOException; 5 | 6 | public class EncodingFilter implements Filter { 7 | 8 | @Override 9 | public void init(FilterConfig filterConfig) throws ServletException { 10 | } 11 | 12 | @Override 13 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 14 | System.out.println("EncodingFilter调用"); 15 | servletRequest.setCharacterEncoding("utf-8"); 16 | servletResponse.setContentType("text/html;charset=utf-8"); 17 | filterChain.doFilter(servletRequest, servletResponse); 18 | } 19 | 20 | @Override 21 | public void destroy() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/filter/LoginFilter.java: -------------------------------------------------------------------------------- 1 | package com.shopping.filter; 2 | 3 | import javax.servlet.*; 4 | import javax.servlet.http.HttpServletRequest; 5 | import javax.servlet.http.HttpServletResponse; 6 | import java.io.IOException; 7 | 8 | public class LoginFilter implements Filter { 9 | @Override 10 | public void init(FilterConfig filterConfig) throws ServletException { 11 | } 12 | 13 | @Override 14 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 15 | HttpServletRequest request=(HttpServletRequest)servletRequest; 16 | HttpServletResponse response=(HttpServletResponse)servletResponse; 17 | Object user = request.getSession().getAttribute("user"); 18 | Object shop = request.getSession().getAttribute("shop"); 19 | Object admin = request.getSession().getAttribute("admin"); 20 | System.out.println("LoginFilter调用,获取到user="+user+",shop="+shop+",admin="+admin); 21 | String uri=request.getRequestURI(); 22 | if (uri.contains("showImage")){ 23 | filterChain.doFilter(servletRequest, servletResponse); 24 | return; 25 | } 26 | if (uri.contains("user")&&user==null){ 27 | request.getSession().setAttribute("shop",null); 28 | request.getSession().setAttribute("admin",null); 29 | } else if (uri.contains("shop")&&shop==null){ 30 | request.getSession().setAttribute("user",null); 31 | request.getSession().setAttribute("admin",null); 32 | } else if (uri.contains("admin")&&admin==null){ 33 | request.getSession().setAttribute("user",null); 34 | request.getSession().setAttribute("shop",null); 35 | } 36 | /** 37 | * 对用户、商户、管理员是否登录进行验证 38 | */ 39 | if (user!=null){ 40 | if (uri.contains("user")){ 41 | filterChain.doFilter(servletRequest, servletResponse); 42 | return; 43 | } else { 44 | response.sendRedirect("/userLogin.jsp"); 45 | } 46 | } 47 | else if (shop!=null){ 48 | if (uri.contains("shop")){ 49 | filterChain.doFilter(servletRequest, servletResponse); 50 | return; 51 | } else { 52 | response.sendRedirect("/shopLogin.jsp"); 53 | } 54 | } 55 | else if (admin!=null){ 56 | if (uri.contains("admin")){ 57 | filterChain.doFilter(servletRequest, servletResponse); 58 | return; 59 | } else { 60 | response.sendRedirect("/adminLogin.jsp"); 61 | } 62 | } 63 | else { 64 | //都为空 65 | if (uri.contains("login")||uri.contains("Login")||uri.contains("Register")||uri.contains("register")){ 66 | filterChain.doFilter(servletRequest,servletResponse); 67 | return; 68 | } else { 69 | if (uri.contains("user"))response.sendRedirect("/userLogin.jsp"); 70 | else if (uri.contains("shop"))response.sendRedirect("/shopLogin.jsp"); 71 | else if (uri.contains("admin"))response.sendRedirect("/adminLogin.jsp"); 72 | else response.sendRedirect("userLogin.jsp");//跳转到主页 73 | } 74 | } 75 | } 76 | 77 | @Override 78 | public void destroy() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/CardService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.Card; 4 | import com.shopping.entity.Page; 5 | import com.shopping.utils.Response; 6 | 7 | import java.util.List; 8 | 9 | public interface CardService { 10 | public List getAllCards(); 11 | public List getCardsByUser(int userId); 12 | public void addCard(Card card); 13 | public List pageQuery(int start,int num); 14 | public Response deleteCard(int id); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/CardServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.Card; 4 | import com.shopping.entity.Page; 5 | import com.shopping.utils.Response; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import com.shopping.dao.CardDao; 9 | import java.util.List; 10 | @Service 11 | public class CardServiceImplement implements CardService { 12 | 13 | @Autowired 14 | private CardDao cardDao; 15 | 16 | private List cards; 17 | 18 | @Override 19 | public List getAllCards() { 20 | return cardDao.getAllCards(); 21 | } 22 | 23 | @Override 24 | public List getCardsByUser(int userId) { 25 | return cardDao.getCardsByUser(userId); 26 | } 27 | 28 | @Override 29 | public void addCard(Card card) { 30 | cardDao.addCard(card); 31 | } 32 | 33 | @Override 34 | public List pageQuery(int start, int num) { 35 | return cardDao.pageQuery(start,num); 36 | } 37 | 38 | @Override 39 | public Response deleteCard(int id) { 40 | try { 41 | cardDao.deleteCard(id); 42 | return new Response(1, "删除帖子成功", null); 43 | }catch (Exception e){ 44 | return new Response(0,"删除帖子失败",null); 45 | } 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/EvaluationService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.Evaluation; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/7. 9 | */ 10 | public interface EvaluationService { 11 | public Evaluation getEvaluation(int userId, int productId, String time); 12 | 13 | public void addEvaluation(Evaluation evaluation); 14 | 15 | public boolean deleteEvaluation(int userId,int productId,String time); 16 | 17 | public boolean updateEvaluation(Evaluation evaluation); 18 | 19 | public List getProductEvaluation(int productId); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/EvaluationServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.EvaluationDao; 4 | import com.shopping.entity.Evaluation; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by 14437 on 2017/3/7. 12 | */ 13 | @Service 14 | public class EvaluationServiceImplement implements EvaluationService { 15 | @Autowired 16 | private EvaluationDao evaluationDao; 17 | 18 | @Override 19 | public Evaluation getEvaluation(int userId, int productId, String time) { 20 | return evaluationDao.getEvaluation(userId,productId,time); 21 | } 22 | 23 | @Override 24 | public void addEvaluation(Evaluation evaluation) { 25 | evaluationDao.addEvaluation(evaluation); 26 | } 27 | 28 | @Override 29 | public boolean deleteEvaluation(int userId, int productId, String time) { 30 | return evaluationDao.deleteEvaluation(userId,productId,time); 31 | } 32 | 33 | @Override 34 | public boolean updateEvaluation(Evaluation evaluation) { 35 | return evaluationDao.updateEvaluation(evaluation); 36 | } 37 | 38 | @Override 39 | public List getProductEvaluation(int productId) { 40 | return evaluationDao.getProductEvaluation(productId); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.Product; 4 | import com.shopping.utils.Response; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by 14437 on 2017/3/2. 10 | */ 11 | public interface ProductService { 12 | public Product getProduct(int id); 13 | 14 | public Product getProduct(String name); 15 | 16 | 17 | 18 | public void addProduct(Product product); 19 | 20 | Response deleteProduct(int id); 21 | 22 | Response deleteProductByBoss(int bossId); 23 | 24 | public boolean updateProduct(Product product); 25 | 26 | public List getProductsByKeyWord(String searchKeyWord); 27 | 28 | public List getProductsByBoss(int bossId); 29 | 30 | public List getProductsByType(int type); 31 | 32 | public List getAllProduct(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ProductServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.EvaluationDao; 4 | import com.shopping.dao.ProductDao; 5 | import com.shopping.dao.ShoppingCarDao; 6 | import com.shopping.dao.ShoppingRecordDao; 7 | import com.shopping.entity.Product; 8 | import com.shopping.utils.Response; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by 14437 on 2017/3/2. 18 | */ 19 | 20 | @Service 21 | public class ProductServiceImplement implements ProductService { 22 | @Autowired 23 | private ProductDao productDao; 24 | @Autowired 25 | private ShoppingRecordDao shoppingRecordDao; 26 | @Autowired 27 | private ShoppingCarDao shoppingCarDao; 28 | @Autowired 29 | private EvaluationDao evaluationDao; 30 | 31 | @Override 32 | public Product getProduct(int id) { 33 | System.out.println("在Product Service里面发斯蒂芬是"); 34 | Product i=new Product(); 35 | i=productDao.getProduct(id); 36 | System.out.println("product is "+i.getName()); 37 | return productDao.getProduct(id); 38 | } 39 | 40 | @Override 41 | public Product getProduct(String name) { 42 | return productDao.getProduct(name); 43 | } 44 | 45 | @Override 46 | public void addProduct(Product product) { 47 | productDao.addProduct(product); 48 | } 49 | 50 | @Override 51 | @Transactional 52 | public Response deleteProduct(int id) { 53 | try { 54 | evaluationDao.deleteEvaluationByProduct(id); 55 | shoppingCarDao.deleteShoppingCarByProduct(id); 56 | shoppingRecordDao.deleteShoppingRecordByProductId(id); 57 | productDao.deleteProduct(id); 58 | return new Response(1, "删除商品成功", null); 59 | }catch (Exception e){ 60 | return new Response(0,"删除商品失败",null); 61 | } 62 | } 63 | @Override 64 | 65 | public Response deleteProductByBoss(int bossId) { 66 | try { 67 | List products=new ArrayList<>(); 68 | products=productDao.getProductsByBoss(bossId); 69 | for(int i=0;i getProductsByKeyWord(String searchKeyWord) { 90 | return productDao.getProductsByKeyWord(searchKeyWord); 91 | } 92 | 93 | @Override 94 | public List getProductsByBoss(int bossId){ 95 | return productDao.getProductsByBoss(bossId); 96 | } 97 | 98 | @Override 99 | public List getProductsByType(int type) { 100 | return productDao.getProductsByType(type); 101 | } 102 | 103 | @Override 104 | public List getAllProduct() { 105 | return productDao.getAllProduct(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ProductTypeService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.ProductType; 4 | 5 | import java.util.List; 6 | 7 | public interface ProductTypeService { 8 | public List getAllProductTypes(); 9 | public void addProductTypes(ProductType productType); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ProductTypeServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.ProductTypeDao; 4 | import com.shopping.entity.ProductType; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | @Service 10 | public class ProductTypeServiceImplement implements ProductTypeService{ 11 | @Autowired 12 | private ProductTypeDao productTypeDao; 13 | @Override 14 | public List getAllProductTypes() { 15 | return productTypeDao.getAllProductTypes(); 16 | } 17 | 18 | @Override 19 | public void addProductTypes(ProductType productType) { 20 | productTypeDao.addProductTypes(productType); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ShoppingCarService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.ShoppingCar; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/3. 9 | */ 10 | public interface ShoppingCarService { 11 | public ShoppingCar getShoppingCar(int userId, int productId); 12 | 13 | public void addShoppingCar(ShoppingCar shoppingCar); 14 | 15 | public boolean deleteShoppingCar(int userId,int productId); 16 | 17 | public boolean updateShoppingCar(ShoppingCar shoppingCar); 18 | 19 | public List getShoppingCars(int userId); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ShoppingCarServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.ShoppingCarDao; 4 | import com.shopping.entity.ShoppingCar; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by 14437 on 2017/3/3. 12 | */ 13 | @Service 14 | public class ShoppingCarServiceImplement implements ShoppingCarService { 15 | @Autowired 16 | private ShoppingCarDao shoppingCarDao; 17 | @Override 18 | public ShoppingCar getShoppingCar(int userId, int productId) { 19 | return shoppingCarDao.getShoppingCar(userId,productId); 20 | } 21 | 22 | @Override 23 | public void addShoppingCar(ShoppingCar shoppingCar) { 24 | shoppingCarDao.addShoppingCar(shoppingCar); 25 | } 26 | 27 | @Override 28 | public boolean deleteShoppingCar(int userId, int productId) { 29 | return shoppingCarDao.deleteShoppingCar(userId,productId); 30 | } 31 | 32 | @Override 33 | public boolean updateShoppingCar(ShoppingCar shoppingCar) { 34 | return shoppingCarDao.updateShoppingCar(shoppingCar); 35 | } 36 | 37 | @Override 38 | public List getShoppingCars(int userId) { 39 | return shoppingCarDao.getShoppingCars(userId); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ShoppingRecordService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.ShoppingRecord; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 14437 on 2017/3/3. 9 | */ 10 | public interface ShoppingRecordService { 11 | public ShoppingRecord getShoppingRecord(int userId, int productId,String time); 12 | 13 | public void addShoppingRecord(ShoppingRecord shoppingRecord); 14 | 15 | public boolean deleteShoppingRecord(int userId,int productId); 16 | 17 | public boolean updateShoppingRecord(ShoppingRecord shoppingRecord); 18 | 19 | public List getShoppingRecordsByOrderStatus(int orderStatus); 20 | 21 | public List getShoppingRecords(int userId); 22 | 23 | public List getAllShoppingRecords(); 24 | 25 | public boolean getUserProductRecord(int userId,int productId); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/ShoppingRecordServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.ShoppingRecordDao; 4 | import com.shopping.entity.ShoppingRecord; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by 14437 on 2017/3/3. 13 | */ 14 | @Service 15 | public class ShoppingRecordServiceImplement implements ShoppingRecordService { 16 | @Autowired 17 | private ShoppingRecordDao shoppingRecordDao; 18 | @Override 19 | public ShoppingRecord getShoppingRecord(int userId, int productId,String time) { 20 | return shoppingRecordDao.getShoppingRecord(userId,productId,time); 21 | } 22 | 23 | @Override 24 | public void addShoppingRecord(ShoppingRecord shoppingRecord) { 25 | System.out.println("传到Service中的shopId is "+shoppingRecord.getShopId()); 26 | shoppingRecordDao.addShoppingRecord(shoppingRecord); 27 | } 28 | 29 | @Override 30 | public boolean deleteShoppingRecord(int userId, int productId) { 31 | return shoppingRecordDao.deleteShoppingRecord(userId,productId); 32 | } 33 | 34 | @Override 35 | public boolean updateShoppingRecord(ShoppingRecord shoppingRecord) { 36 | return shoppingRecordDao.updateShoppingRecord(shoppingRecord); 37 | } 38 | 39 | @Override 40 | public List getShoppingRecordsByOrderStatus(int orderStatus) { 41 | return shoppingRecordDao.getShoppingRecordsByOrderStatus(orderStatus); 42 | } 43 | 44 | @Override 45 | public List getShoppingRecords(int userId) { 46 | 47 | List shoppingRecordList=shoppingRecordDao.getShoppingRecords(userId); 48 | shoppingRecordList.forEach(e->{ 49 | System.out.println("在Service中的productId,userId(买家),shopId(卖家)是:"+e.getProductId()+" " 50 | +e.getUserId()+" "+e.getShopId()+" "+e.getTime()+" "+e.getProductPrice()+" "+e.getCounts()+e.getOrderStatus()); 51 | }); 52 | return shoppingRecordDao.getShoppingRecords(userId); 53 | } 54 | 55 | @Override 56 | public List getAllShoppingRecords() { 57 | System.out.println("这里是Service"); 58 | List records=new ArrayList<>(); 59 | records=shoppingRecordDao.getAllShoppingRecords(); 60 | for(int i=0;i getAllUserDetail(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/UserDetailServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.UserDetailDao; 4 | import com.shopping.entity.UserDetail; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by 14437 on 2017/3/1. 12 | */ 13 | @Service 14 | public class UserDetailServiceImplement implements UserDetailService{ 15 | 16 | @Autowired 17 | private UserDetailDao userDetailDao; 18 | 19 | @Override 20 | public UserDetail getUserDetail(int id) { 21 | return userDetailDao.getUserDetail(id); 22 | } 23 | 24 | @Override 25 | public void addUserDetail(UserDetail userDetail) { 26 | userDetailDao.addUserDetail(userDetail); 27 | } 28 | 29 | @Override 30 | public boolean deleteUserDetail(int id) { 31 | return userDetailDao.deleteUserDetail(id); 32 | } 33 | 34 | @Override 35 | public boolean updateUserDetail(UserDetail userDetail) { 36 | return userDetailDao.updateUserDetail(userDetail); 37 | } 38 | 39 | @Override 40 | public List getAllUserDetail() { 41 | return userDetailDao.getAllUserDetail(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.entity.User; 4 | import com.shopping.utils.Response; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by 14437 on 2017/3/1. 10 | */ 11 | public interface UserService { 12 | User getUser(int id); 13 | 14 | User getUser(String nameOrEmail); 15 | 16 | void addUser(User user); 17 | 18 | //推荐写法 19 | Response deleteUser(int id); 20 | 21 | boolean updateUser(User user); 22 | 23 | List getAllUser(); 24 | 25 | Response deleteBoss(int id); 26 | public boolean becomeVip(int userId); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/service/UserServiceImplement.java: -------------------------------------------------------------------------------- 1 | package com.shopping.service; 2 | 3 | import com.shopping.dao.*; 4 | import com.shopping.entity.Product; 5 | import com.shopping.entity.User; 6 | import com.shopping.entity.UserDetail; 7 | import com.shopping.utils.Response; 8 | import org.hibernate.Query; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by 14437 on 2017/3/1. 17 | */ 18 | @Service 19 | public class UserServiceImplement implements UserService { 20 | 21 | @Autowired 22 | private UserDao userDao; 23 | @Autowired 24 | private UserDetailDao userDetailDao; 25 | @Autowired 26 | private ShoppingRecordDao shoppingRecordDao; 27 | @Autowired 28 | private ShoppingCarDao shoppingCarDao; 29 | @Autowired 30 | private EvaluationDao evaluationDao; 31 | 32 | @Autowired 33 | private ProductDao productDao; 34 | 35 | @Override 36 | public User getUser(int id) { 37 | System.out.println("This is UserService "); 38 | System.out.println("userId is "+userDao.getUser(id).getId()); 39 | 40 | return userDao.getUser(id); 41 | } 42 | 43 | @Override 44 | public User getUser(String nameOrEmail) { 45 | return userDao.getUser(nameOrEmail); 46 | } 47 | 48 | @Override 49 | public void addUser(User user) { 50 | userDao.addUser(user); 51 | } 52 | 53 | //推荐写法,具体业务逻辑放在Service实现方法里面 54 | @Override 55 | @Transactional 56 | public Response deleteUser(int id) { 57 | //判断此用户是否存在购买记录、评价记录、购物车记录,如果存在,则应该先删除对应的记录,否则后续删除会出错 58 | try { 59 | evaluationDao.deleteEvaluationByUser(id); 60 | shoppingCarDao.deleteShoppingCarByUser(id); 61 | shoppingRecordDao.deleteShoppingRecordByUser(id); 62 | userDetailDao.deleteUserDetail(id); 63 | userDao.deleteUser(id); 64 | return new Response(1, "删除成功", null); 65 | }catch (Exception e) { 66 | return new Response(0, "删除失败", null); 67 | } 68 | } 69 | 70 | 71 | 72 | 73 | @Override 74 | @Transactional 75 | public Response deleteBoss(int id) { 76 | //判断此用户是否存在购买记录、评价记录、购物车记录,如果存在,则应该先删除对应的记录,否则后续删除会出错 77 | try { 78 | evaluationDao.deleteEvaluationByUser(id); 79 | shoppingCarDao.deleteShoppingCarByUser(id); 80 | shoppingRecordDao.deleteShoppingRecordByUser(id); 81 | userDetailDao.deleteUserDetail(id); 82 | List products=productDao.getProductsByBoss(id); 83 | for(int i=0;i getAllUser() { 103 | return userDao.getAllUser(); 104 | } 105 | 106 | @Override 107 | public boolean becomeVip(int userId){ 108 | return userDao.becomeVip(userId); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/utils/Response.java: -------------------------------------------------------------------------------- 1 | package com.shopping.utils; 2 | 3 | /** 4 | * Created by IcedSoul on 2018/4/8. 5 | */ 6 | 7 | public class Response { 8 | public int status; 9 | public String message; 10 | public Object content; 11 | 12 | public Response(int status, String message, Object content) { 13 | this.status = status; 14 | this.message = message; 15 | this.content = content; 16 | } 17 | 18 | public int getStatus() { 19 | return status; 20 | } 21 | 22 | public void setStatus(int status) { 23 | this.status = status; 24 | } 25 | 26 | public String getMessage() { 27 | return message; 28 | } 29 | 30 | public void setMessage(String message) { 31 | this.message = message; 32 | } 33 | 34 | public Object getContent() { 35 | return content; 36 | } 37 | 38 | public void setContent(Object content) { 39 | this.content = content; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/resources/05.jpg -------------------------------------------------------------------------------- /src/main/resources/properties/Shopping SQL语句.txt: -------------------------------------------------------------------------------- 1 | create database shopping; 2 | 3 | use shopping; 4 | create table user_main( 5 | id int not null, 6 | name varchar(30) not null, 7 | email varchar(50) not null, 8 | nick_name varchar(30) not null, 9 | role int not null, 10 | primary key(id), 11 | unique(name), 12 | unique(email) 13 | ); 14 | 15 | create table user_detail( 16 | id int not null, 17 | password varchar(20) not null, 18 | phone_number varchar(20) not null, 19 | sex int not null, 20 | birthday varchar(20) not null, 21 | post_number varchar(10) not null, 22 | address varchar(50) not null, 23 | register_time varchar(20) not null, 24 | primary key(id), 25 | foreign key(id) references user_main(id) 26 | ); 27 | 28 | create table products( 29 | id int not null, 30 | name varchar(50) not null, 31 | description varchar(1000) not null, 32 | key_word varchar(1000) not null, 33 | price int not null, 34 | counts int not null, 35 | type int not null, 36 | primary key(id), 37 | unique(name) 38 | ); 39 | 40 | create table shopping_car( 41 | user_id int not null, 42 | product_id int not null, 43 | product_price int not null, 44 | counts int not null, 45 | primary key (user_id,product_id), 46 | foreign key (user_id) references user_main(id), 47 | foreign key (product_id) references products(id) 48 | ); 49 | 50 | create table shopping_record( 51 | user_id int not null, 52 | product_id int not null, 53 | time varchar(20) not null, 54 | order_status int not null, 55 | product_price int not null, 56 | counts int not null, 57 | primary key (user_id,product_id,time), 58 | foreign key (user_id) references user_main(id), 59 | foreign key (product_id) references products(id) 60 | ); 61 | 62 | create table evaluation( 63 | user_id int not null, 64 | product_id int not null, 65 | time varchar(20) not null, 66 | content varchar(1000) not null, 67 | primary key (user_id,product_id,time), 68 | foreign key (user_id) references user_main(id), 69 | foreign key (product_id) references products(id) 70 | ); -------------------------------------------------------------------------------- /src/main/resources/properties/database.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/resources/properties/database.properties -------------------------------------------------------------------------------- /src/main/resources/spring/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | org.hibernate.dialect.MySQLDialect 46 | update 47 | true 48 | true 49 | 50 | false 51 | false 52 | thread 53 | org.springframework.orm.hibernate4.SpringSessionContext 54 | 55 | 56 | 57 | 58 | com.shopping.entity 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | text/plain;charset=UTF-8 48 | application/json;charset=UTF-8 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/all_cards.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 购物+ 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 | 30 | 31 |
32 |
33 |

看帖看帖看帖

34 |
35 | 36 |
37 |
38 |
39 |
40 |
41 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/vip.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: liu 4 | Date: 2018/12/24 5 | Time: 23:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/vipLogin.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 购物+ 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 |

登录

28 |
29 |
30 | 31 |
32 |
33 | 34 |
35 | 36 |
37 |
38 |
39 | 40 |
41 | 42 |
43 |
44 |
45 |
46 | 47 |
48 |
49 |
50 |
51 |
52 |
53 | 54 | 55 | 56 | 57 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 11 | 12 | /WEB-INF/views/main.jsp 13 | 14 | 15 | 16 | 17 | 18 | org.springframework.web.context.ContextLoaderListener 19 | 20 | 21 | 22 | 23 | 24 | contextConfigLocation 25 | classpath:spring/applicationContext.xml 26 | 27 | 28 | 29 | 30 | spring 31 | / 32 | 33 | 34 | 35 | spring 36 | org.springframework.web.servlet.DispatcherServlet 37 | 38 | contextConfigLocation 39 | classpath:spring/spring-mvc.xml 40 | 41 | 1 42 | true 43 | 44 | 45 | 46 | 47 | openSession 48 | /* 49 | 50 | 51 | 52 | openSession 53 | org.springframework.orm.hibernate4.support.OpenSessionInViewFilter 54 | 55 | 56 | 57 | 58 | encodingFilter 59 | org.springframework.web.filter.CharacterEncodingFilter 60 | 61 | encoding 62 | UTF-8 63 | 64 | 65 | forceEncoding 66 | true 67 | 68 | 69 | 70 | encodingFilter 71 | /* 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/webapp/static/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | font-family: "Microsoft YaHei"; 4 | } 5 | div:hover { 6 | text-decoration: none; 7 | } 8 | .table th, .table td { 9 | text-align: center; 10 | vertical-align: middle!important; 11 | } 12 | 13 | .navbar-fixed-top { 14 | border: 0; 15 | } 16 | .sidebar { 17 | display: none; 18 | } 19 | @media (min-width: 768px) { 20 | .sidebar { 21 | position: fixed; 22 | top: 51px; 23 | bottom: 0; 24 | left: 0; 25 | z-index: 1000; 26 | display: block; 27 | padding: 20px; 28 | overflow-x: hidden; 29 | overflow-y: auto; 30 | background-color: #f5f5f5; 31 | border-right: 1px solid #eee; 32 | } 33 | } 34 | 35 | .nav-sidebar { 36 | margin-right: -21px; 37 | margin-bottom: 20px; 38 | margin-left: -20px; 39 | } 40 | .nav-sidebar > li > a { 41 | padding-right: 20px; 42 | padding-left: 20px; 43 | } 44 | .nav-sidebar > .active > a, 45 | .nav-sidebar > .active > a:hover, 46 | .nav-sidebar > .active > a:focus { 47 | color: #fff; 48 | background-color: #428bca; 49 | } 50 | 51 | .main { 52 | padding: 20px; 53 | } 54 | @media (min-width: 768px) { 55 | .main { 56 | padding-right: 40px; 57 | padding-left: 40px; 58 | } 59 | } 60 | 61 | 62 | 63 | .sidebar-1 { 64 | height: 100%; 65 | } 66 | .big { 67 | width: 280px; 68 | height: 160px; 69 | overflow: hidden; 70 | position: relative; 71 | text-align: center; 72 | cursor: pointer; 73 | } 74 | .big img { 75 | display:block; 76 | position: relative; 77 | } 78 | .bigimg img { 79 | opacity:1; 80 | -moz-transform:scale(1, 1); 81 | -webkit-transform:scale(1, 1); 82 | -o-transform:scale(1, 1); 83 | -ms-transform:scale(1, 1); 84 | transform:scale(1, 1); 85 | -webkit-transition: all 0.4s ease-in; 86 | -moz-transition: all 0.4s ease-in; 87 | -o-transition: all 0.4s ease-in; 88 | -ms-transition: all 0.4s ease-in; 89 | transition: all 0.4s ease-in; 90 | } 91 | .bigimg:hover img { 92 | opacity:1; 93 | -moz-transform:scale(1.2, 1.2); 94 | -webkit-transform:scale(1.2, 1.2); 95 | -o-transform:scale(1.2, 1.2); 96 | -ms-transform:scale(1.2, 1.2); 97 | transform:scale(1.2, 1.2); 98 | } 99 | .boxes { 100 | width:280px; 101 | height:245px; 102 | background-color:#f5f5f5; 103 | border:none; 104 | overflow:hidden; 105 | z-index:10 106 | } 107 | .foot-style { 108 | text-align: center; 109 | font-size: 14px; 110 | } 111 | .margin-t { 112 | margin-top: 30px; 113 | } 114 | .pd-10 { 115 | padding-top: 30px; 116 | } 117 | 118 | .center { 119 | text-align: center; 120 | } 121 | .margin-l { 122 | margin-left: 8%; 123 | } 124 | .big-button { 125 | margin-left: 10px; 126 | } 127 | .detail-img { 128 | width: 100%; 129 | } 130 | .detail-x { 131 | font-size: 18px; 132 | } 133 | .pd-5 { 134 | padding-top: 30px; 135 | } 136 | .pointer:hover { 137 | cursor: pointer; 138 | } 139 | .confirm-margin { 140 | margin-top: 10px; 141 | } 142 | .bigHead { 143 | padding-top: 10px; 144 | } 145 | .product-name { 146 | text-align: center; 147 | font-size: 20px; 148 | padding-top: 10px; 149 | } 150 | .product-price { 151 | text-align: center; 152 | color: #b92c28; 153 | font-size: 24px; 154 | padding-bottom: 5px; 155 | } 156 | .delete-button { 157 | margin-left: 36px; 158 | } 159 | 160 | .search-padding{ 161 | padding-left: 5%; 162 | padding-right: 5%; 163 | padding-top:15px; 164 | padding-bottom:15px; 165 | } 166 | 167 | .list-group-item-diy{ 168 | color: #555555; 169 | text-align: center; 170 | } 171 | .list-group-item-diy a,.list-group-item-diy a:hover,.list-group-item-diy a:visited{ 172 | color: #555555; 173 | } 174 | 175 | .division { 176 | padding-top: 15px; 177 | padding-bottom: 15px; 178 | } 179 | 180 | .evaluationTable td{ 181 | text-align: left; 182 | } 183 | 184 | .evaluationButton { 185 | padding-top: 10px; 186 | } -------------------------------------------------------------------------------- /src/main/webapp/static/img/0045e07dd23e1845063c823cb7cfaeee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/0045e07dd23e1845063c823cb7cfaeee.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/1.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/2.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/3.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/4.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/46f46cfac8b8a702f970353f7fec5618.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/46f46cfac8b8a702f970353f7fec5618.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/5.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/6.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/662072618.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/662072618.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/B1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/B1.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/img/key-lime.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junyi-tiger/Shopping/8e96cf1bc6575b9149254d12e9f9ff53a6fa07c5/src/main/webapp/static/img/key-lime.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document); -------------------------------------------------------------------------------- /src/main/webapp/static/js/mobile/layer.js: -------------------------------------------------------------------------------- 1 | /*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */ 2 | ;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'

'+(e?n.title[0]:n.title)+"

":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e=''+n.btn[0]+"",2===t&&(e=''+n.btn[1]+""+e),'
'+e+"
"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='

'+(n.content||"")+"

"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"
':"")+'
"+l+'
'+n.content+"
"+c+"
",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;odiv{line-height:22px;padding-top:7px;margin-bottom:20px;font-size:14px}.layui-m-layerbtn{display:box;display:-moz-box;display:-webkit-box;width:100%;height:50px;line-height:50px;font-size:0;border-top:1px solid #D0D0D0;background-color:#F2F2F2}.layui-m-layerbtn span{display:block;-moz-box-flex:1;box-flex:1;-webkit-box-flex:1;font-size:14px;cursor:pointer}.layui-m-layerbtn span[yes]{color:#40AFFE}.layui-m-layerbtn span[no]{border-right:1px solid #D0D0D0;border-radius:0 0 0 5px}.layui-m-layerbtn span:active{background-color:#F6F6F6}.layui-m-layerend{position:absolute;right:7px;top:10px;width:30px;height:30px;border:0;font-weight:400;background:0 0;cursor:pointer;-webkit-appearance:none;font-size:30px}.layui-m-layerend::after,.layui-m-layerend::before{position:absolute;left:5px;top:15px;content:'';width:18px;height:1px;background-color:#999;transform:rotate(45deg);-webkit-transform:rotate(45deg);border-radius:3px}.layui-m-layerend::after{transform:rotate(-45deg);-webkit-transform:rotate(-45deg)}body .layui-m-layer .layui-m-layer-footer{position:fixed;width:95%;max-width:100%;margin:0 auto;left:0;right:0;bottom:10px;background:0 0}.layui-m-layer-footer .layui-m-layercont{padding:20px;border-radius:5px 5px 0 0;background-color:rgba(255,255,255,.8)}.layui-m-layer-footer .layui-m-layerbtn{display:block;height:auto;background:0 0;border-top:none}.layui-m-layer-footer .layui-m-layerbtn span{background-color:rgba(255,255,255,.8)}.layui-m-layer-footer .layui-m-layerbtn span[no]{color:#FD482C;border-top:1px solid #c2c2c2;border-radius:0 0 5px 5px}.layui-m-layer-footer .layui-m-layerbtn span[yes]{margin-top:10px;border-radius:5px}body .layui-m-layer .layui-m-layer-msg{width:auto;max-width:90%;margin:0 auto;bottom:-150px;background-color:rgba(0,0,0,.7);color:#fff}.layui-m-layer-msg .layui-m-layercont{padding:10px 20px} -------------------------------------------------------------------------------- /src/main/webapp/static/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /src/main/webapp/static/js/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl 2 | * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT 3 | * */ 4 | 5 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b