基于Springboot+Vue的Java项目-鲜牛奶订购系统开发实战(附演示视频+源码+LW)

发布于:2024-05-08 ⋅ 阅读:(28) ⋅ 点赞:(0)

大家好!我是程序员一帆,感谢您阅读本文,欢迎一键三连哦。

💞当前专栏:Java毕业设计

精彩专栏推荐👇🏻👇🏻👇🏻

🎀 Python毕业设计
🌎微信小程序毕业设计

开发环境

开发语言:Java
框架:Springboot+Vue
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7
数据库工具:Navicat12
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器

演示视频

springboot278鲜牛奶订购系统的设计与实现录像

原版高清演示视频-编号:278
https://pan.quark.cn/s/5cda95b17ee0

源码下载地址:

https://download.csdn.net/download/2301_76953549/89100207

LW目录

【如需全文请按文末获取联系】
在这里插入图片描述
在这里插入图片描述

一、项目简介

鲜牛奶订购系统可以实现商家管理,商品订单管理,用户管理,商品管理,商品评价管理等功能。该系统采用了Mysql数据库,Java语言,Spring Boot框架等技术进行编程实现。

二、系统设计

2.1软件功能模块设计

图4.1即为设计的管理员功能结构,管理员权限操作的功能包括管理商家,管理商家星级信息,管理用户,管理商品等。
在这里插入图片描述
图4.2即为设计的商家功能结构,商家权限操作的功能包括管理商品,回复商品评价,管理商品订单等。
在这里插入图片描述
图4.3即为设计的用户功能结构,用户权限操作的功能包括查看商家,购买商品,提交订单,管理商品订单等。
在这里插入图片描述

2.2数据库设计

(1)图4.4即为商品这个实体所拥有的属性值。商品有商品类型,商品现价,商品名称等。
在这里插入图片描述
图4.4 商品实体属性图
(2)图4.5即为商品订单这个实体所拥有的属性值。商品订单有订购数量,订单类型,收货地址等。
在这里插入图片描述
(3)图4.6即为商家这个实体所拥有的属性值。商家有邮箱,营业执照,商家星级类型等。
在这里插入图片描述
图4.6 商家实体属性图
(4)图4.7即为用户这个实体所拥有的属性值。用户有手机号,电子邮箱,用户头像等。
在这里插入图片描述
(5)图4.8即为上面介绍的实体中存在的联系。
在这里插入图片描述

三、系统项目部分截图

3.1管理员功能实现

公告信息管理
图5.1 即为编码实现的公告信息管理界面,公告信息包括了公告图片,公告类型,公告标题等,管理员在公告信息管理界面中可以对界面中显示的所有公告信息进行更改,查询,删除。
在这里插入图片描述
商家管理
图5.3 即为编码实现的商家管理界面,商家信息有营业执照,商家星级类型,商家名称等信息。管理员在商家管理界面中新增商家,更改商家的营业执照,商家星级信息等,可以删除需要删除的商家信息。
在这里插入图片描述

3.2商家功能实现

商品管理
图5.5 即为编码实现的商品管理界面,商品信息有商品是否上架,剩余订购数量,商品原价等信息,商家在商品管理界面中为商品的可订购数量进行增加,为商品的可订购数量进行减少,可以上架商品,下架商品以及更改商品信息等。
在这里插入图片描述
商品订单管理
图5.7 即为编码实现的商品订单管理界面,商品订单有订单号,实付价格,支付类型,商品照片等信息。商家在商品订单管理界面中对商品订单查询,查询条件有商品类型,商品名称,用户姓名等。管理员也能对商品订单详情进行查看。
在这里插入图片描述

3.3用户功能实现

商家信息
图5.8 即为编码实现的商家信息界面,用户在商家信息界面中查看商家介绍还有商家的营业执照以及商家的星级信息等。
在这里插入图片描述
确认下单
图5.10 即为编码实现的确认下单界面,用户在确认下单界面中可以提交订单,前提是检查购买的物品以及收货的地址信息等是否正确,也需要查看总金额信息以及实付款信息,最后根据实付款的金额进行支付。
在这里插入图片描述

四、部分核心代码

4.1 用户部分


package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 商品收藏
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/xiannaiCollection")
public class XiannaiCollectionController {
    private static final Logger logger = LoggerFactory.getLogger(XiannaiCollectionController.class);

    @Autowired
    private XiannaiCollectionService xiannaiCollectionService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service
    @Autowired
    private XiannaiService xiannaiService;
    @Autowired
    private YonghuService yonghuService;



    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        else if("商家".equals(role))
            params.put("shangjiaId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = xiannaiCollectionService.queryPage(params);

        //字典表数据转换
        List<XiannaiCollectionView> list =(List<XiannaiCollectionView>)page.getList();
        for(XiannaiCollectionView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        XiannaiCollectionEntity xiannaiCollection = xiannaiCollectionService.selectById(id);
        if(xiannaiCollection !=null){
            //entity转view
            XiannaiCollectionView view = new XiannaiCollectionView();
            BeanUtils.copyProperties( xiannaiCollection , view );//把实体数据重构到view中

                //级联表
                XiannaiEntity xiannai = xiannaiService.selectById(xiannaiCollection.getXiannaiId());
                if(xiannai != null){
                    BeanUtils.copyProperties( xiannai , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setXiannaiId(xiannai.getId());
                }
                //级联表
                YonghuEntity yonghu = yonghuService.selectById(xiannaiCollection.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody XiannaiCollectionEntity xiannaiCollection, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,xiannaiCollection:{}",this.getClass().getName(),xiannaiCollection.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");
        else if("用户".equals(role))
            xiannaiCollection.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        Wrapper<XiannaiCollectionEntity> queryWrapper = new EntityWrapper<XiannaiCollectionEntity>()
            .eq("xiannai_id", xiannaiCollection.getXiannaiId())
            .eq("yonghu_id", xiannaiCollection.getYonghuId())
            .eq("xiannai_collection_types", xiannaiCollection.getXiannaiCollectionTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        XiannaiCollectionEntity xiannaiCollectionEntity = xiannaiCollectionService.selectOne(queryWrapper);
        if(xiannaiCollectionEntity==null){
            xiannaiCollection.setInsertTime(new Date());
            xiannaiCollection.setCreateTime(new Date());
            xiannaiCollectionService.insert(xiannaiCollection);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody XiannaiCollectionEntity xiannaiCollection, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,xiannaiCollection:{}",this.getClass().getName(),xiannaiCollection.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
//        else if("用户".equals(role))
//            xiannaiCollection.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
        //根据字段查询是否有相同数据
        Wrapper<XiannaiCollectionEntity> queryWrapper = new EntityWrapper<XiannaiCollectionEntity>()
            .notIn("id",xiannaiCollection.getId())
            .andNew()
            .eq("xiannai_id", xiannaiCollection.getXiannaiId())
            .eq("yonghu_id", xiannaiCollection.getYonghuId())
            .eq("xiannai_collection_types", xiannaiCollection.getXiannaiCollectionTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        XiannaiCollectionEntity xiannaiCollectionEntity = xiannaiCollectionService.selectOne(queryWrapper);
        if(xiannaiCollectionEntity==null){
            xiannaiCollectionService.updateById(xiannaiCollection);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        xiannaiCollectionService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        try {
            List<XiannaiCollectionEntity> xiannaiCollectionList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            XiannaiCollectionEntity xiannaiCollectionEntity = new XiannaiCollectionEntity();
//                            xiannaiCollectionEntity.setXiannaiId(Integer.valueOf(data.get(0)));   //商品 要改的
//                            xiannaiCollectionEntity.setYonghuId(Integer.valueOf(data.get(0)));   //用户 要改的
//                            xiannaiCollectionEntity.setXiannaiCollectionTypes(Integer.valueOf(data.get(0)));   //类型 要改的
//                            xiannaiCollectionEntity.setInsertTime(date);//时间
//                            xiannaiCollectionEntity.setCreateTime(date);//时间
                            xiannaiCollectionList.add(xiannaiCollectionEntity);


                            //把要查询是否重复的字段放入map中
                        }

                        //查询是否重复
                        xiannaiCollectionService.insertBatch(xiannaiCollectionList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }





    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = xiannaiCollectionService.queryPage(params);

        //字典表数据转换
        List<XiannaiCollectionView> list =(List<XiannaiCollectionView>)page.getList();
        for(XiannaiCollectionView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        XiannaiCollectionEntity xiannaiCollection = xiannaiCollectionService.selectById(id);
            if(xiannaiCollection !=null){


                //entity转view
                XiannaiCollectionView view = new XiannaiCollectionView();
                BeanUtils.copyProperties( xiannaiCollection , view );//把实体数据重构到view中

                //级联表
                    XiannaiEntity xiannai = xiannaiService.selectById(xiannaiCollection.getXiannaiId());
                if(xiannai != null){
                    BeanUtils.copyProperties( xiannai , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setXiannaiId(xiannai.getId());
                }
                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(xiannaiCollection.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody XiannaiCollectionEntity xiannaiCollection, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,xiannaiCollection:{}",this.getClass().getName(),xiannaiCollection.toString());
        Wrapper<XiannaiCollectionEntity> queryWrapper = new EntityWrapper<XiannaiCollectionEntity>()
            .eq("xiannai_id", xiannaiCollection.getXiannaiId())
            .eq("yonghu_id", xiannaiCollection.getYonghuId())
            .eq("xiannai_collection_types", xiannaiCollection.getXiannaiCollectionTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        XiannaiCollectionEntity xiannaiCollectionEntity = xiannaiCollectionService.selectOne(queryWrapper);
        if(xiannaiCollectionEntity==null){
            xiannaiCollection.setInsertTime(new Date());
            xiannaiCollection.setCreateTime(new Date());
        xiannaiCollectionService.insert(xiannaiCollection);
            return R.ok();
        }else {
            return R.error(511,"您已经收藏过了");
        }
    }


}

获取源码或论文

如需对应的LW或源码,以及其他定制需求,也可以点我头像查看个人简介联系。


网站公告

今日签到

点亮在社区的每一天
去签到