基于javaweb+mysql的springboot前台后台玩具商城系统(java+ssm+springboot+html+maven+mysql+redis)

基于javaweb+mysql的springboot前台后台玩具商城系统(java+ssm+springboot+html+maven+mysql+redis)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot前台后台玩具商城系统(java+ssm+springboot+html+maven+mysql+redis)

一、项目简述本系统主要实现的功能有: 网上商城系统,前台+后台管理,用户注册,登录,商品展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管理,订单管理,用户管理,信息修改等等。

二、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

Springboot+ SpringMVC + MyBatis + Html+ JavaScript + JQuery + Ajax + maven等等


    @Autowired
    private RoleService roleService;

    /**
     * 登录
     * @return
     */
    @GetMapping("login.html")
    public String login(){
        return "login";
    }

    /**
     * 登录
     * @return
     */
    @GetMapping("logout.htm")
    public String logout(HttpServletResponse response){
        Cookie cookie = new Cookie("login_key_auth","");
        cookie.setPath("/");
        cookie.setMaxAge(0);
        response.addCookie(cookie);
        return "redirect:/login.html";
    }

    /**
     * 登录
     * @param loginName
     * @param password
     * @return
     * @throws Exception
     */
    @PostMapping("loginData.html")
    @ResponseBody
    @ImLog(type = "登录",mark = "用户 {loginName} 登录")
    public Result loginData(String loginName, String password, HttpServletResponse response)throws Exception{
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq(UserTable.LOGIN_NAME,loginName);
        UserEntity userEntity = userService.selectOne(entityWrapper);
        if(userEntity==null){
            return Result.error("用户名或密码错误");
        }
        if(!password.equals(userEntity.getPassword())){
            return Result.error("用户名或密码错误");
        }
        RoleEntity roleEntity = roleService.selectById(userEntity.getRoleId());
        if(roleEntity==null || roleEntity.getStatus()==false ){
            return Result.error("用户无角色可用");
        }
        Cookie cookie = new Cookie("login_key_auth",userEntity.getId());
        orderEntity.setStatus(3);
        orderService.updateById(orderEntity);
        return Result.success("欢迎下次光临");
    }

    /**
     * 退货收货
     *
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("tuihuo.do")
    @ResponseBody
    public Result tuihuo(String id) throws Exception {
        orderService.deleteById(id);
        return Result.success("下次再买 - -");
    }

    /**
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model) throws Exception {
        CustomerEntity userEntity = Contants.getCustomer();
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.eq(OrderTable.CUSTOMER_ID, userEntity.getId()).orderBy("time", false);
        List<OrderEntity> orders = orderService.selectList(wrapper);
        if (orders != null) {
            for (OrderEntity order : orders) {
                wrapper = new EntityWrapper();
                wrapper.eq("order_id", order.getId());
                List<OrderShopEntity> orderShops = orderShopService.selectList(wrapper);
                order.setOrderShops(orderShops);
            }
        }
        model.addAttribute("orders", orders);
        return "mobile/orderList";
    }

    /**
     * 订单结算
     *
     * @param ids  购物车ids
     * @param nums 数量
     * @return

    /**
     * 删除
     * @param id
     * @return
     * @throws Exception
     */
    @PostMapping("del.do")
    @ResponseBody
    public Result del(String id)throws Exception{
        service.deleteById(id);
        return Result.success("保存成功");
    }
}

@Controller
@RequestMapping("royalty")
public class RoyaltyController {

    @Autowired
    private RoyaltyService royaltyService;

    @Autowired
    private CustomerService customerService;
    /**
     * 列表界面
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model)throws Exception{
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq("customer",Contants.getCustomer().getId());
        entityWrapper.orderBy("time",false);

@Controller
@RequestMapping("customerAddress")
public class CustomerAddressController {

    @Autowired
    private CustomerAddressService service;

    /**
     * 列表界面
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model)throws Exception{
        CustomerEntity customerEntity = Contants.getCustomer();
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.eq(CustomerAddressTable.CUSTOMER_ID,customerEntity.getId());
        List<CustomerAddressEntity> list = service.selectList(wrapper);
        model.addAttribute("list",list);
        return "mobile/address_list";
    }

    /**
     * 保存界面
     * @param model
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("save.do")
    public String save(Model model,String id)throws Exception{
        CustomerAddressEntity entity = new CustomerAddressEntity();

    /**
     * 根据文章ID推荐商品
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("shopList.html")
    @ResponseBody
    public Result shopList(String id)throws Exception{
        ArticleEntity articleEntity = articleService.selectById(id);
        if(StringUtils.isEmpty(articleEntity.getLabel())){
            return Result.success("无");
        }
        String[] lebel = articleEntity.getLabel().split(",");
        //查询
        List<String> ids = new ArrayList<>();
        for (String s : lebel) {
            EntityWrapper wrapper = new EntityWrapper();
            wrapper.like("label",s);
            List<ShopEntity> shops = shopService.selectList(wrapper);
            if(shops!=null){
                for (ShopEntity shop : shops) {
                    ids.add(shop.getId());
                }
            }
        }
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.in("id",ids).orderBy("rand()");
        List<ShopEntity> shops = shopService.selectList(wrapper);
        if(shops!=null){
            if(shops.size()>3){
                shops = shops.subList(0,3);
            }
        }
        return Result.success(shops);
    }

    /**
     * 界面
     * @return
     * @throws Exception

}

@Controller
public class LoginController {

    @Autowired
    private UserService userService;

    @Autowired
    private RoleService roleService;

    /**
     * 登录
     * @return
     */
    @GetMapping("login.html")
    public String login(){
        return "login";
    }

    /**
     * 登录
     * @return
     */
    @GetMapping("logout.htm")
    public String logout(HttpServletResponse response){
        Cookie cookie = new Cookie("login_key_auth","");
    public Result shopList(String id)throws Exception{
        ArticleEntity articleEntity = articleService.selectById(id);
        if(StringUtils.isEmpty(articleEntity.getLabel())){
            return Result.success("无");
        }
        String[] lebel = articleEntity.getLabel().split(",");
        //查询
        List<String> ids = new ArrayList<>();
        for (String s : lebel) {
            EntityWrapper wrapper = new EntityWrapper();
            wrapper.like("label",s);
            List<ShopEntity> shops = shopService.selectList(wrapper);
            if(shops!=null){
                for (ShopEntity shop : shops) {
                    ids.add(shop.getId());
                }
            }
        }
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.in("id",ids).orderBy("rand()");
        List<ShopEntity> shops = shopService.selectList(wrapper);
        if(shops!=null){
            if(shops.size()>3){
                shops = shops.subList(0,3);
            }
        }
        return Result.success(shops);
    }

    /**
     * 界面
     * @return
     * @throws Exception
     */
    @GetMapping("info.html")
    public String info(String id, Model model)throws Exception{
        ArticleEntity articleEntity = articleService.selectById(id);
        model.addAttribute("article",articleEntity);
        model.addAttribute("id",id);
        String[]  lebel = articleEntity.getLabel().split(",");
        model.addAttribute("lebels",lebel);
        CustomerEntity customerEntity = customerService.selectById(articleEntity.getCustomerId());
        model.addAttribute("customerEntity",customerEntity);
        if(!StringUtils.isEmpty(articleEntity.getShopIds())){
            String articles[] = articleEntity.getShopIds().split(",");
            List<String> str = new ArrayList<>();
     * @return
     * @throws Exception
     */
    @GetMapping("list.htm")
    public String list(Model model)throws Exception{
        return "article/list";
    }

    /**
     * 分页
     * @return
     * @throws Exception
     */
    @GetMapping("page.htm")
    @ResponseBody
    public PageVo page(String title, String  summary,int page , int limit)throws Exception{
        EntityWrapper entityWrapper = new EntityWrapper();
        if(!StringUtils.isEmpty(title)){
            entityWrapper.like(ArticleTable.TITLE,title);
        }
        if(!StringUtils.isEmpty(summary)){
            entityWrapper.like(ArticleTable.SUMMARY,summary);
        }
        entityWrapper.orderBy("top",false).orderBy("time",false);
        Page<ArticleEntity> paged = new Page();
        paged.setSize(limit);
        paged.setCurrent(page);
        Page<ArticleEntity> userTablePage = articleService.selectPage(paged, entityWrapper);

        List<ArticleEntity> list = userTablePage.getRecords();
        if(list!=null && !list.isEmpty()){
            for (ArticleEntity articleEntity : list) {
                CustomerEntity customerEntity = customerService.selectById(articleEntity.getCustomerId());
                if(customerEntity!=null){
                    articleEntity.setCustomerName(customerEntity.getName());
                }
                ChildTypeEntity childTypeEntity = childTypeService.selectById(articleEntity.getChildType());
                if(childTypeEntity!=null){
                    articleEntity.setChildName(childTypeEntity.getName());
                }
            }
        }
        PageVo<ArticleEntity> pageVo = new PageVo<>();
        pageVo.setCode(0);
        pageVo.setCount(paged.getTotal());
        pageVo.setData(list);
        pageVo.setPageNum(limit);
        pageVo.setPageSize(page);
        return pageVo;

    }

    /**
                str.add(article);
            }
            List<ShopEntity> shopEntities = shopService.selectBatchIds(str);
            model.addAttribute("shopEntities",shopEntities);
        }
        return "article/info";
    }

    /**
     * 界面
     * @return
     * @throws Exception
     */
    @GetMapping("edit.htm")
    public String edit(String id, Model model )throws Exception{
        ArticleEntity articleEntity = articleService.selectById(id);
        model.addAttribute("articleEntity",articleEntity);
        List<ShopEntity> shopEntities =  shopService.selectList(new EntityWrapper<>());
        model.addAttribute("shopEntities",shopEntities);
        return "article/edit";
    }

    /**
     * 保存数据
     * @return
     * @throws Exception
     */
    @RequestMapping("editData.htm")
    @ResponseBody
    public Result editData(ArticleEntity articleEntity)throws Exception{
        articleService.updateById(articleEntity);
        return Result.success("保存成功");
    }

}


@Controller
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @Autowired
    private MenuService menuService;

    @Autowired
    private RoleMenuService roleMenuService;

    /**
     * 角色界面
     * @param model
     * @return
     * @throws Exception
     */
    @GetMapping("list.htm")
    public String list(Model model)throws Exception{
        List<RoleEntity> list = roleService.selectList(new EntityWrapper<>());
        model.addAttribute("list",list);
        return "role/list";
    }

        //循环添加新的权限
        for (MenuEntity menuEntity : menuEntities) {
            set.add(menuEntity.getPId());
        }
        for (String s : set) {
            RoleMenuEntity roleMenuEntity = new RoleMenuEntity();
            roleMenuEntity.setId(IdWorkerUtil.getId());
            roleMenuEntity.setMenuId(s);
            roleMenuEntity.setRoleId(roleId);
            roleMenuService.insert(roleMenuEntity);
        }
        for (String s : list) {
            RoleMenuEntity roleMenuEntity = new RoleMenuEntity();
            roleMenuEntity.setId(IdWorkerUtil.getId());
            roleMenuEntity.setMenuId(s);
            roleMenuEntity.setRoleId(roleId);
            roleMenuService.insert(roleMenuEntity);
        }
        return Result.success("权限保存成功");
    }

}

@Controller
@RequestMapping("mobileCustomer")
public class MobileCustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * 我的界面
     * @param model
     * @return
     * @throws Exception
//        try {
//            File file1 = transferToFile(file);
//            // 1 初始化用户身份信息(secretId, secretKey)。
//            COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
//            // 2 设置 bucket 的地域, COS 地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
 clientConfig 中包含了设置 region, https(默认 http), 超时, 代理等 set 方法, 使用可参见源码或者常见问题 Java SDK 部分。
//            Region region = new Region(REGION);
//            ClientConfig clientConfig = new ClientConfig(region);
 这里建议设置使用 https 协议
//            clientConfig.setHttpProtocol(HttpProtocol.https);
//            // 3 生成 cos 客户端。
//            COSClient cosClient = new COSClient(cred, clientConfig);
//            // 指定要上传的文件
//            // 指定文件将要存放的存储桶
//            String bucketName = BUCKETNAME;
//            // 指定文件上传到 COS 上的路径,即对象键。例如对象键为folder/picture.jpg,则表示将文件 picture.jpg 上传到 folder 路径下
//            String key = KEY + fileName;
//            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file1);
//            PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Result.error("上传文件失败");
//        }
//        return Result.success(BASEURL + fileName, "文件上传成功");
//    }

	 public static final String FILE_PATH = "D:\\immersive_shopping\\";
	    static {
	        File file = new File(FILE_PATH);
	        file.mkdirs();
	    }

	    /**
	     * 文件上传返回code为200
	     * @param file
	     * @return
	     * @throws Exception
	     */
	    @PostMapping("/upload")
	    @ResponseBody
	    public Result uplaod(@RequestParam("file") MultipartFile file)throws Exception {
	        //用来检测程序运行时间
	        String fileName =  IdWorker.get32UUID() +file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
	        try {
	            File file1 = new File(FILE_PATH+"\\"+fileName);
	            file1.createNewFile();
	            //获取输出流
	            OutputStream os=new FileOutputStream(file1.getPath());
	            //获取输入流 CommonsMultipartFile 中可以直接得到文件的流
	            InputStream is=file.getInputStream();

    @Autowired
    private CustomerService customerService;
    /**
     * 列表界面
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model)throws Exception{
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq("customer",Contants.getCustomer().getId());
        entityWrapper.orderBy("time",false);
        List<RoyaltyEntity> list = royaltyService.selectList(entityWrapper);
        model.addAttribute("list",list);
        BigDecimal all = new BigDecimal(0);
        if(list!=null){
            for (RoyaltyEntity royaltyEntity : list) {
                all =  all.add(royaltyEntity.getMoney());
            }
        }
        model.addAttribute("all",all);
        return "mobile/royalty";
    }

    /**
     * 用户提取佣金
     * @param money
     * @return
     * @throws Exception
     */
    @RequestMapping("tiqu.do")
    @ResponseBody
    public Result tiqu(String money)throws Exception{
        RoyaltyEntity royaltyEntity = new RoyaltyEntity();
        String id = Contants.getCustomer().getId();
        BigDecimal bigDecimal = new BigDecimal(money);
        royaltyEntity.setId(IdWorkerUtil.getId());
        royaltyEntity.setCustomer(id);
        royaltyEntity.setMark("用户提取佣金");
        royaltyEntity.setTime(new Date());
        royaltyEntity.setMoney(bigDecimal);
        royaltyService.insert(royaltyEntity);
        CustomerEntity customerEntity = customerService.selectById(id);
        money = money.replace("-","");
        Integer integer = Integer.valueOf(money);
        customerEntity.setIntegral(customerEntity.getIntegral()+integer/10);
     * 登陆界面
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("reg.html")
    public String reg(Model model) throws Exception{
        return "mobile/reg";
    }

    /**
     * 登陆
     * @return
     * @throws Exception
     */
    @RequestMapping("regData.html")
    @ResponseBody
    public Result regData( CustomerEntity customerEntity, HttpServletResponse response)throws Exception{
        customerEntity.setId(IdWorkerUtil.getId());
        customerEntity.setHeader("/img/a5.jpg");
        customerService.insert(customerEntity);
        Cookie cookie = new Cookie("login_key_auth_customer",customerEntity.getId());
        cookie.setPath("/");
        cookie.setMaxAge(3600000);
        response.addCookie(cookie);
        return Result.success(customerEntity.getId(),"登陆成功");
    }

}

    }

}

@Controller
@RequestMapping("mobileCustomer")
public class MobileCustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * 我的界面
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("jump.html")
    public String my(Model model,String url)throws Exception{
        model.addAttribute("url",url);
        return "mobile/jump";
    }

    /**
     * 我的Data
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("infoData.do")
    @ResponseBody
    public Result infoData(Model model)throws Exception{
        CustomerEntity customerEntity = Contants.getCustomer();
        return Result.success(customerEntity);
    }

    /**
     * @throws Exception
     */
    @RequestMapping("comment.do")
    public String comment(String id, Model model) throws Exception {
        OrderShopEntity orderShopEntity = orderShopService.selectById(id);
        model.addAttribute("entity", orderShopEntity);
        return "mobile/comment";
    }

    @RequestMapping("commentData.do")
    @ResponseBody
    public Result commentData(OrderShopEntity orderShopEntity) throws Exception {
        String content = orderShopEntity.getContent();
        content = content.replace("操", "*");
        content = content.replace("sb", "**");
        content = content.replace("傻", "*");
        orderShopEntity.setContent(content);
        orderShopService.updateById(orderShopEntity);
        orderShopEntity = orderShopService.selectById(orderShopEntity.getId());
        Double num = orderShopDao.num(orderShopEntity.getShopId());
        ShopEntity shopEntity = new ShopEntity();
        shopEntity.setId(orderShopEntity.getShopId());
        shopEntity.setScore(num);
        shopService.updateById(shopEntity);
        return Result.success(1);
    }

    /**
     * 收货
     *
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("shouhuo.do")
    @ResponseBody
    public Result shouhuo(String id) throws Exception {
        OrderEntity orderEntity = orderService.selectById(id);
    public String indexPage(Model model)throws Exception{
       return "childType/list";
    }

    /**
     * 分页
     * @param model
     * @return
     * @throws Exception
     */
    @GetMapping("page.htm")
    @ResponseBody
    public PageVo indexPage(Model model, String name, int page , int limit)throws Exception{

        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.like(ChildTypeTable.NAME,name);

        Page<ChildTypeEntity> paged = new Page();
        paged.setSize(limit);
        paged.setCurrent(page);
        Page<ChildTypeEntity> userTablePage = childTypeService.selectPage(paged, entityWrapper);

        PageVo<ChildTypeEntity> pageVo = new PageVo<>();
        pageVo.setCode(0);
        pageVo.setCount(paged.getTotal());
        pageVo.setData(userTablePage.getRecords());
        pageVo.setPageNum(limit);
        pageVo.setPageSize(page);
        return pageVo;

    }

    /**
     * 保存界面
     * @param model
     * @return
     */
    @GetMapping("savePage.htm")
    public String savePage(Model model){
        return  "childType/save";
    }

    /**

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值