当前位置:   article > 正文

java项目:基于springboot的商城系统(springBoot+mybatis+layui+jquery)1003_利用jquery写商城项目

利用jquery写商城项目

项目描述

爱购商城:分为前端和后端两部分,主要功能包括:用户管理,轮播图管理,商品分类管理,商品品牌管理,商品管理 等功能

运行环境

jdk8+mysql+IntelliJ IDEA+maven

项目技术

springBoot+mybatis+layui+jquery+jsp

项目截图

首页
在这里插入图片描述
收货地址
在这里插入图片描述
购物车
在这里插入图片描述
订单页
在这里插入图片描述

商品管理
在这里插入图片描述
修改商品
在这里插入图片描述

用户管理
在这里插入图片描述

部分代码

用户Controller代码

@Controller
@RequestMapping("/admin")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/user/list")
    public String list(@RequestParam(defaultValue = "1")Integer pageNo,
                       @RequestParam(defaultValue = "10") Integer pageSize, Model model){
        PageModel<User> userPages = userService.queryUserList(pageNo, pageSize);
        model.addAttribute("userPages",userPages);
        return "admin/user/list";
    }
    @RequestMapping("/user/addPage")
    public String addPage(){
        return "admin/user/add";
    }
    @RequestMapping("/user/add")
    public String addUser(User user,Model model){
        try {
            user.setType(0);
            int i = userService.addUser(user);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙添加失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        model.addAttribute("url", "admin/user/list");
        return "success";

    }
    @RequestMapping("user/updatePage")
    public String updatePage(String id,Model model){
        User user = userService.queryUserById(id);
        model.addAttribute("user",user);
        return "admin/user/update";
    }
    @RequestMapping("/user/update")
    public String updateUser(User user,Model model){
        try {
            int i = userService.updateUser(user);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙修改失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        model.addAttribute("url", "admin/user/list");
        return "success";

    }
    @RequestMapping("user/deletePage")
    public String deletePage(String id,Model model){
        model.addAttribute("id",id);
        return "admin/user/delete";
    }
    @RequestMapping("user/delete")
    public String deleteUser(String id,Model model){
        try {
            int i = userService.deleteUser(id);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙修改失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        model.addAttribute("url", "admin/user/list");
        return "success";
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 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
  • 48
  • 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

商品Controller控制层


@Controller
@RequestMapping("admin/product")
public class ProductController {
    @Autowired
    private ProductService productService;
    @Autowired
    private ProductTypeService productTypeService;
    @Autowired
    private BrandService brandService;
    @RequestMapping("/list")
    public String list( @RequestParam(defaultValue = "1") Integer pageNo,
                        @RequestParam(defaultValue = "5")Integer pageSize,
                        String productName,
                        String productTypeID,
                        Model model){
        try {
            List<ProductType> productTypes = productTypeService.queryProductTypeAll();
            model.addAttribute("productTypes", productTypes);
            model.addAttribute("productName",productName);
            model.addAttribute("type",productTypeID);
            PageModel<Product> productPages= productService.queryProductPage(pageNo,pageSize,productName,productTypeID);
            model.addAttribute("productPages",productPages);
        } catch (Exception e) {
            e.printStackTrace();
            model.addAttribute("errMessage", "查询失败:"+e.getMessage());
            return  "500";
        }
        return "admin/product/list";
    }
    @RequestMapping("addPage")
    public String addPage(Model model){
        List<ProductType> productTypes= productTypeService.queryProductTypeAll();
        List<Brand> brands=  brandService.queryBrandAll();
        model.addAttribute("productTypes",productTypes);
        model.addAttribute("brands",brands);
        return "admin/product/add";
    }
    @RequestMapping("add")
    private String addProduct(Product product,Model model){
        try {
            int i = productService.addProduct(product);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙操作失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        model.addAttribute("url", "admin/product/list");
        return "success";


    }
    @RequestMapping("updatePage")
    public String update(String id,Model model){
        Product product= productService.queryProductById(id);
        List<ProductType> productTypes= productTypeService.queryProductTypeAll();
        List<Brand> brands=  brandService.queryBrandAll();
        model.addAttribute("productTypes",productTypes);
        model.addAttribute("brands",brands);
        model.addAttribute("product",product);
        return "admin/product/update";
    }
    @RequestMapping("update")
    private String update(Product product,Model model){
        try {
            int i = productService.updateProduct(product);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙操作失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        model.addAttribute("url", "admin/product/list");
        return "success";


    }
    @RequestMapping("deletePage")
    public String deletePage(String id,Model model){
        model.addAttribute("id",id);
        return "admin/product/delete";
    }
    @RequestMapping("/delete")
    public String delete(String id, Model model){
        try {
            int i = productService.delete(id);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙操作失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        model.addAttribute("url", "admin/product/list");
        return "success";

    }
    @RequestMapping("batchDel")
    @ResponseBody
    public String batchDel(String[] ids) {
        System.out.println("进来了");
        productService.batchProductTypeDel(ids);
        return "/admin/product/list";

    }

}


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 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
  • 48
  • 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
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115

登录Controller 代码


@Controller
@RequestMapping("/admin")
public class LoginController {
    @Autowired
    private UserService userService;

    @RequestMapping("/index")
    public String index(){
        return "admin/index/index";
    }
    @RequestMapping("/loginPage")
    public String loginPage(){
        return "admin/login/login";
    }
    @RequestMapping("/login")
    public String login(String username, String password, Model model, HttpSession session){
        try {
            User user= userService.queryUserByName(username,0);
            if (user==null){
                model.addAttribute("errMsg","用户名不存在");
                return "admin/login/login";
            }else {
                String password1 = user.getPassword();
                if (!EncryptionUtils.encryptMD5(password).equals(password1)){
                    model.addAttribute("errMsg","密码错误");
                    return "admin/login/login";
                }else {
                    session.setAttribute("_admin",username);
                    return "redirect: index";
                }
            }
        }catch (Exception e){
            model.addAttribute("errMsg","服务器繁忙登录失败!");
            return "admin/login/login";
        }

    }
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.removeAttribute("_admin");
        return "admin/login/login";
    }
   @RequestMapping("/user/changePasswordPage")
   public String changePasswordPage(){
       return "admin/login/changePassword";
   }
   @RequestMapping("/user/changePassword")
   public String changePassword(String oldPassword,String newPassword,HttpSession session,Model model){
       String username = (String) session.getAttribute("_admin");
       User user= userService.queryUserByName(username,0);
       if (!EncryptionUtils.encryptMD5(oldPassword).equals(user.getPassword())){
            model.addAttribute("errMessage","密码错误修改失败");
            return "500";
       }else {
           user.setPassword(newPassword);
           try {
               int i = userService.updateUser(user);
               if (i==0){
                   model.addAttribute("errMessage","服务器繁忙修改失败");
                   return "500";
               }
           }catch (Exception e){
               model.addAttribute("errMessage",e.getMessage());
               return "500";
           }
           model.addAttribute("url", "admin/index");
           return "success";
       }
   }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 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
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72

注意事项

图片数据请修改路径

源码地址

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

闽ICP备14008679号