package com.soecode.lyf.web;
import com.google.gson.Gson;
import com.soecode.lyf.entity.*;
import com.soecode.lyf.service.*;
import com.soecode.lyf.util.anonymity;
import com.soecode.lyf.util.email1;
import org.apache.commons.mail.EmailException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
@Controller
public class userController {
String s="";
String forgets="";
@Autowired
private userService userService;
@Autowired
private categoryService categoryService;
@Autowired
private productService productService;
@Autowired
private productImageService productImageService;
@Autowired
private couponService couponService;
@Autowired
private addressService addressService;
@Autowired
private orderService orderService;
@Autowired
private orderItemService orderItemService;
@Autowired
private carItemService carItemService;
@Autowired
private presonCenterService presonCenterService;
@Autowired
private evaluationService evaluationService;
@RequestMapping("/registerPage")
public ModelAndView regist(){
ModelAndView modelAndView=new ModelAndView();
modelAndView.setViewName("registerPage");
return modelAndView;
}
//。。。。。。。。。。。。。。。。。。。。。。。。。。用户登录注册功能。。。。。。。。。。。。。。。。。。。。。。。。。。。
@RequestMapping(value = "/registerPage",method = RequestMethod.POST)
public ModelAndView registSuccess(@RequestParam("username") String username,@RequestParam("password") String password){
ModelAndView modelAndView=new ModelAndView();
user user1=new user();
user1.setUsername(username);
user1.setPassword(password);
userService.add(user1);
modelAndView.setViewName("login");
return modelAndView;
}
@RequestMapping(value = "/ajaxCheck")
public void ajaxCheck(HttpServletRequest req, HttpServletResponse resp) throws IOException {
boolean flag=true;
ModelAndView modelAndView=new ModelAndView();
String username = req.getParameter("username");
int exit = userService.isExit(username);
Map<String,Object> map=new HashMap<>();
if(exit!=0){
flag=true;
}
else {
flag=false;
}
map.put("flag",flag);
Gson gson=new Gson();
String s = gson.toJson(map);
resp.getWriter().write(s);
}
@RequestMapping("/index")
public ModelAndView index(){
ModelAndView modelAndView=new ModelAndView();
List<product> products = productService.listAll();
List<category> categories = categoryService.listAll();
List<productImage> listProductImages = productImageService.listAll();
modelAndView.addObject("products",products);
modelAndView.addObject("categories",categories);
modelAndView.addObject("listProductImages",listProductImages);
modelAndView.setViewName("index");
return modelAndView;
}
@RequestMapping("/login")
public ModelAndView login(){
ModelAndView modelAndView=new ModelAndView();
modelAndView.setViewName("login");
return modelAndView;
}
@RequestMapping(value = "/ajaxLogin")
public void loginSuccess(HttpServletRequest req, HttpServletResponse resp) throws IOException {
boolean flag=true;
String contextPath = req.getContextPath();
System.out.println(contextPath);
String username = req.getParameter("username");
System.out.println(username);
String password = req.getParameter("password");
user login = userService.login(username, password);
Map<String, Boolean> map=new HashMap<>();
if(login!=null){
flag=true;
req.getSession().setAttribute("login",login);
}else {
flag=false;
}
map.put("flag",flag);
Gson gson=new Gson();
String s = gson.toJson(map);
resp.getWriter().write(s);
}
@RequestMapping("/checkOut")
public ModelAndView checkOut(HttpServletRequest req) throws IOException {
req.getSession().invalidate();
ModelAndView modelAndView=new ModelAndView();
modelAndView.setViewName("redirect:/index");
return modelAndView;
}
//。。。。。。。。。。。。。。。。。。。。。。。前台展示功能。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
@RequestMapping("detail")
public ModelAndView detail(@RequestParam("pid") int pid){
ModelAndView modelAndView=new ModelAndView();
List<productImage> oneListImage = productImageService.getById(pid);
product oneProduct = productService.getById(pid);
modelAndView.addObject("oneProduct",oneProduct);
modelAndView.addObject("oneListImage",oneListImage);
List<evaluation> evaluations = evaluationService.listPid(pid);
modelAndView.addObject("evaluations",evaluations);
modelAndView.setViewName("productPage");
return modelAndView;
}
@RequestMapping("likeSelect")
public ModelAndView likeSelect(@RequestParam("keyword") String keyword){
List<product> list =new ArrayList<>();
ModelAndView modelAndView=new ModelAndView();
List<category> categories = categoryService.likeSelect(keyword);
List<productImage> productImages = productImageService.listAll();
if(categories.size()<=0){
List<product> products = productService.likeSelect(keyword);
modelAndView.addObject("list",products);
}
else{
for (int i = 0; i < categories.size(); i++) {
List<product> byId1 = productService.getById1(categories.get(i).getId());
for (int j = 0; j < byId1.size(); j++) {
list.add(byId1.get(j));
}
}
modelAndView.addObject("list",list);
}
modelAndView.addObject("productImage",productImages);
modelAndView.setViewName("searchByCategoryResult");
return modelAndView;
}
@RequestMapping("pageSelect")
public ModelAndView pageSelect(@RequestParam("pageNo") int pageNo,@RequestParam("keyword") String keyword){
ModelAndView modelAndView=new ModelAndView("searchByCategoryResult2");
List<page> categories = categoryService.page(keyword, pageNo-1, 4);
System.out.println(categories.size());
if(categories.get(0).getListItem().size()<=0){
List<page> page = productService.page(keyword, pageNo-1,4);
modelAndView.addObject("lists",page);
}
else {
modelAndView.addObject("lists",categories);
}
List<productImage> productImages = productImageService.listAll();
modelAndView.addObject("productImage",productImages);
modelAndView.addObject("keyword",keyword);
return modelAndView;
}
//。。。。。。。。。。。。。。。。。。。。。。。优惠卷增加和查看所有。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
@RequestMapping("selectCoupon")
public ModelAndView selectCoupon(HttpServletRequest req){
ModelAndView modelA
没有合适的资源?快使用搜索试试~ 我知道了~
基于ssm的天猫商城源码+项目说明(模块商品显示模块+个人中心模块+购物车模块+卡卷模块+订单模块+购买模块等).zip
共780个文件
png:130个
class:119个
xml:109个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 120 浏览量
2024-01-31
23:48:20
上传
评论
收藏 51.41MB ZIP 举报
温馨提示
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于ssm的天猫商城源码+项目说明(模块商品显示模块+个人中心模块+购物车模块+卡卷模块+订单模块+购买模块+忘记密码模块+地址模块+评价模块).zip 基于ssm的天猫商城源码+项目说明(模块商品显示模块+个人中心模块+购物车模块+卡卷模块+订单模块+购买模块+忘记密码模块+地址模块+评价模块).zip 基于ssm的天猫商城源码+项目说明(模块商品显示模块+个人中心模块+购物车模块+卡卷模块+订单模块+购买模块+忘记密码模块+地址模块+评价模块).zip 基于ssm的天猫商城源码+项目说明(模块商品显示模块+个人中心模块+购物车模块+卡卷模块+订单模块+购买模块+忘记密码模块+地址模块+评价模块).zip
资源推荐
资源详情
资源评论
收起资源包目录
基于ssm的天猫商城源码+项目说明(模块商品显示模块+个人中心模块+购物车模块+卡卷模块+订单模块+购买模块等).zip (780个子文件)
userController.class 25KB
userController.class 25KB
productController.class 7KB
productController.class 7KB
BookControllerTest.class 5KB
categoryController.class 4KB
categoryController.class 4KB
productServiceImpl.class 3KB
productServiceImpl.class 3KB
categoryServiceImpl.class 3KB
categoryServiceImpl.class 3KB
orderController.class 3KB
orderController.class 3KB
order.class 3KB
order.class 3KB
fileFuntion.class 2KB
fileFuntion.class 2KB
Result.class 2KB
Result.class 2KB
orderItemServiceImpl.class 2KB
orderItemServiceImpl.class 2KB
orderServiceImpl.class 2KB
email1.class 2KB
orderServiceImpl.class 2KB
email1.class 2KB
presoncenter.class 2KB
presoncenter.class 2KB
product.class 2KB
product.class 2KB
userServiceImpl.class 2KB
userServiceImpl.class 2KB
carItemServiceImpl.class 2KB
carItemServiceImpl.class 2KB
presonCenterServiceImpl.class 2KB
presonCenterServiceImpl.class 2KB
address.class 1KB
address.class 1KB
orderItem.class 1KB
orderItem.class 1KB
productImageServiceImpl.class 1KB
productImageServiceImpl.class 1KB
addressServiceImpl.class 1KB
addressServiceImpl.class 1KB
evaluation.class 1KB
evaluation.class 1KB
user.class 1KB
user.class 1KB
productDao.class 1KB
productDao.class 1KB
evaluationServiceImpl.class 1KB
evaluationServiceImpl.class 1KB
couponServiceImpl.class 1KB
couponServiceImpl.class 1KB
page.class 1KB
page.class 1KB
productImage.class 1KB
productImage.class 1KB
carItem.class 1KB
carItem.class 1KB
categoryDao.class 998B
categoryDao.class 998B
daoTest.class 997B
daoTest.class 997B
anonymity.class 919B
anonymity.class 919B
productService.class 906B
productService.class 906B
coupon.class 860B
coupon.class 860B
orderItemDao.class 848B
orderItemDao.class 848B
AbstractContextControllerTests.class 789B
category.class 746B
category.class 746B
orderItemService.class 709B
orderItemService.class 709B
userDao.class 691B
userDao.class 691B
categoryService.class 679B
categoryService.class 679B
orderDao.class 670B
orderDao.class 670B
carItemDao.class 625B
carItemDao.class 625B
RepeatAppointException.class 591B
RepeatAppointException.class 591B
orderService.class 582B
orderService.class 582B
NoNumberException.class 576B
BaseTest.class 576B
NoNumberException.class 576B
AppointException.class 573B
AppointException.class 573B
presonCenterService.class 568B
presonCenterService.class 568B
productImageDao.class 563B
productImageDao.class 563B
presonCenterDao.class 556B
presonCenterDao.class 556B
addressDao.class 507B
共 780 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
土豆片片
- 粉丝: 1569
- 资源: 5636
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功