计算机毕业设计 助农产品采购平台的设计与实现 Java实战项目 附源码+文档+视频讲解

博主介绍:✌从事软件开发10年之余,专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌
🍅文末获取源码联系🍅
👇🏻 精彩专栏推荐订阅👇🏻 不然下次找不到哟
————————————————
计算机毕业设计《1000套》

Python毕设精品项目

微信小程序毕设精品项目

大数据及机器学习毕设精品项目

目录

1、项目介绍及开发技术

1.1 项目介绍

1.2 开发技术

2、系统功能设计结构图

3、功能截图

3.1 前台功能

3.2 后台功能

4、数据库表结构设计

5、关键代码

5.1 农产品Controller模块 

5.2 农产品Service模块 

5.3 农产品ServiceImpl模块

5.4  农产品Dao模块

6、论文目录结构

7、源码获取


1、项目介绍及开发技术

1.1 项目介绍

在推动乡村振兴和农业现代化的背景下,助农产品采购平台应运而生,旨在通过电子商务模式促进农产品的销售,帮助农民增收。随着互联网技术的普及和消费者对健康、绿色食品需求的增长,农产品的在线销售渠道逐渐成为重要的市场力量。然而,农民往往缺乏有效的在线销售途径和推广手段,这限制了农产品的市场潜力。

背景: 传统的农产品销售模式面临着诸多挑战,如销售渠道单一、市场信息不对称、物流配送不便等。为了解决这些问题,提供一个集农产品展示、在线交易、物流跟踪、客户服务于一体的平台显得尤为重要。

目的意义:

  1. 拓宽销售渠道: 平台为农产品提供了一个在线展示和销售的窗口,拓宽了销售渠道,增加了农民的收入来源。
  2. 提高市场透明度: 商品资讯和论坛功能使消费者能够更好地了解农产品,提高了市场的透明度。
  3. 促进信息交流: 通过论坛和在线客服,消费者和商家可以进行实时交流,提升了购物体验。
  4. 优化物流配送: 个人中心的订单管理功能帮助商家有效管理订单和物流,提高了配送效率。
  5. 支持乡村振兴: 平台的捐赠项目和捐赠记录管理功能支持社会力量参与乡村振兴,促进了农业可持续发展。

综上所述,助农产品采购平台不仅为农产品的销售提供了新的解决方案,也为消费者购买绿色、健康的农产品提供了便捷的途径,同时支持了乡村振兴战略的实施。

1.2 开发技术

类别技术名称用途/描述
开发语言Java一种广泛使用的面向对象编程语言。
框架Spring Boot简化Spring应用的初始搭建以及开发过程。
ORM工具MyBatis PlusMyBatis的增强工具,简化CRUD操作。
数据库MySQL流行的关系型数据库管理系统。
构建工具Maven项目管理和理解工具。
开发工具IDEA集成开发环境,用于代码编写和调试。
JDK版本JDK 1.8+Java开发工具包,提供运行Java程序所需的环境。
前端框架Vue用于构建用户界面的渐进式JavaScript框架。
UI框架Element UI基于Vue的桌面端组件库。
前端技术HTML网页内容的标准标记语言。
前端技术CSS描述HTML文档的样式。
前端技术JS网页脚本语言,用于实现网页的动态效果。

2、系统功能设计结构图

功能模块结构图

├── 前端
│   ├── 登录/注册
│   ├── 首页
│   ├── 论坛
│   ├── 捐赠项目
│   ├── 商品资讯
│   ├── 商品
│   ├── 商家
│   └── 个人中心
│       ├── 个人信息
│       ├── 收货地址
│       ├── 捐赠记录
│       ├── 商品收藏
│       ├── 商品评价
│       └── 商品订单
│   ├── 购物车
│   └── 在线客服

└── 后端
    ├── 登录
    ├── 个人中心
    ├── 管理员管理
    ├── 商家管理
    ├── 用户管理
    ├── 商品管理
    ├── 捐赠项目管理
    ├── 捐赠记录管理
    ├── 客服聊天管理
    ├── 基础数据管理
    ├── 论坛管理
    ├── 商品资讯管理
    └── 轮播图信息管理

系统MVC框架,请求流程展示:

3、功能截图

3.1 前台功能

3.2 后台功能

4、数据库表结构设计

/*Table structure for table `chat` */

DROP TABLE IF EXISTS `chat`;

CREATE TABLE `chat` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '提问用户',
  `chat_issue` varchar(200) DEFAULT NULL COMMENT '问题',
  `issue_time` timestamp NULL DEFAULT NULL COMMENT '问题时间 Search111',
  `chat_reply` varchar(200) DEFAULT NULL COMMENT '回复',
  `reply_time` timestamp NULL DEFAULT NULL COMMENT '回复时间 Search111',
  `zhuangtai_types` int(255) DEFAULT NULL COMMENT '状态',
  `chat_types` int(11) DEFAULT NULL COMMENT '数据类型',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='客服聊天';


/*Table structure for table `juanzeng` */

DROP TABLE IF EXISTS `juanzeng`;

CREATE TABLE `juanzeng` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',
  `juanzeng_name` varchar(200) DEFAULT NULL COMMENT '捐赠项目标题  Search111 ',
  `juanzeng_photo` varchar(200) DEFAULT NULL COMMENT '捐赠项目封面',
  `juanzeng_types` int(11) DEFAULT NULL COMMENT '捐赠项目类型 Search111',
  `juanzeng_new_money` decimal(10,2) DEFAULT NULL COMMENT '已捐金额',
  `juanzeng_content` text COMMENT '捐赠项目介绍 ',
  `juanzeng_delete` int(11) DEFAULT NULL COMMENT '逻辑删除',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '录入时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间  show1 show2 photoShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='捐赠项目';


/*Table structure for table `news` */

DROP TABLE IF EXISTS `news`;

CREATE TABLE `news` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `news_name` varchar(200) DEFAULT NULL COMMENT '资讯标题  Search111 ',
  `news_types` int(11) DEFAULT NULL COMMENT '资讯类型  Search111 ',
  `news_photo` varchar(200) DEFAULT NULL COMMENT '资讯图片',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '添加时间',
  `news_content` text COMMENT '资讯详情',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show1 show2 nameShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='商品资讯';


/*Table structure for table `nongchanpin_collection` */

DROP TABLE IF EXISTS `nongchanpin_collection`;

CREATE TABLE `nongchanpin_collection` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `nongchanpin_id` int(11) DEFAULT NULL COMMENT '商品',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '用户',
  `nongchanpin_collection_types` int(11) DEFAULT NULL COMMENT '类型',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '收藏时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 photoShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COMMENT='商品收藏';


CREATE TABLE `nongchanpin_order` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `nongchanpin_order_uuid_number` varchar(200) DEFAULT NULL COMMENT '订单号 Search111 ',
  `address_id` int(11) DEFAULT NULL COMMENT '收货地址 ',
  `nongchanpin_id` int(11) DEFAULT NULL COMMENT '商品',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '用户',
  `buy_number` int(11) DEFAULT NULL COMMENT '购买数量',
  `jiezhi_time` timestamp NULL DEFAULT NULL COMMENT '拼团结束时间',
  `nongchanpin_order_true_price` decimal(10,2) DEFAULT NULL COMMENT '实付价格',
  `nongchanpin_order_courier_name` varchar(200) DEFAULT NULL COMMENT '快递公司',
  `nongchanpin_order_courier_number` varchar(200) DEFAULT NULL COMMENT '订单快递单号',
  `nongchanpin_order_types` int(11) DEFAULT NULL COMMENT '订单类型 Search111 ',
  `nongchanpin_order_payment_types` int(11) DEFAULT NULL COMMENT '支付类型',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '订单创建时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 listShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='商品订单';


DROP TABLE IF EXISTS `token`;

CREATE TABLE `token` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `userid` bigint(20) NOT NULL COMMENT '用户id',
  `username` varchar(100) NOT NULL COMMENT '用户名',
  `tablename` varchar(100) DEFAULT NULL COMMENT '表名',
  `role` varchar(100) DEFAULT NULL COMMENT '角色',
  `token` varchar(200) NOT NULL COMMENT '密码',
  `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',
  `expiratedtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '过期时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='token表';


DROP TABLE IF EXISTS `yonghu`;

CREATE TABLE `yonghu` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `username` varchar(200) DEFAULT NULL COMMENT '账户',
  `password` varchar(200) DEFAULT NULL COMMENT '密码',
  `yonghu_name` varchar(200) DEFAULT NULL COMMENT '用户姓名 Search111 ',
  `yonghu_phone` varchar(200) DEFAULT NULL COMMENT '联系方式',
  `yonghu_id_number` varchar(200) DEFAULT NULL COMMENT '身份证号',
  `yonghu_photo` varchar(200) DEFAULT NULL COMMENT '用户头像',
  `sex_types` int(11) DEFAULT NULL COMMENT '性别 Search111',
  `yonghu_email` varchar(200) DEFAULT NULL COMMENT '电子邮箱',
  `new_money` decimal(10,2) DEFAULT NULL COMMENT '余额 ',
  `yonghu_sum_jifen` decimal(10,2) DEFAULT NULL COMMENT '总积分',
  `huiyuandengji_types` int(11) DEFAULT NULL COMMENT '会员等级',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='用户';

5、关键代码

5.1 农产品Controller模块 



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("/nongchanpin")
public class NongchanpinController {
    private static final Logger logger = LoggerFactory.getLogger(NongchanpinController.class);

    private static final String TABLE_NAME = "nongchanpin";

    @Autowired
    private NongchanpinService nongchanpinService;


    @Autowired
    private TokenService tokenService;

    @Autowired
    private AddressService addressService;//收货地址
    @Autowired
    private CartService cartService;//购物车
    @Autowired
    private ChatService chatService;//客服聊天
    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private ForumService forumService;//论坛
    @Autowired
    private JuanzengService juanzengService;//捐赠项目
    @Autowired
    private JuanzengYuyueService juanzengYuyueService;//捐赠记录
    @Autowired
    private NewsService newsService;//商品资讯
    @Autowired
    private NongchanpinCollectionService nongchanpinCollectionService;//商品收藏
    @Autowired
    private NongchanpinCommentbackService nongchanpinCommentbackService;//商品评价
    @Autowired
    private NongchanpinOrderService nongchanpinOrderService;//商品订单
    @Autowired
    private ShangjiaService shangjiaService;//商家
    @Autowired
    private YonghuService yonghuService;//用户
    @Autowired
    private UsersService usersService;//管理员


    /**
    * 后端列表
    */
    @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"));
        params.put("nongchanpinDeleteStart",1);params.put("nongchanpinDeleteEnd",1);
        CommonUtil.checkMap(params);
        PageUtils page = nongchanpinService.queryPage(params);

        //字典表数据转换
        List<NongchanpinView> list =(List<NongchanpinView>)page.getList();
        for(NongchanpinView 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);
        NongchanpinEntity nongchanpin = nongchanpinService.selectById(id);
        if(nongchanpin !=null){
            //entity转view
            NongchanpinView view = new NongchanpinView();
            BeanUtils.copyProperties( nongchanpin , view );//把实体数据重构到view中
            //级联表 商家
            //级联表
            ShangjiaEntity shangjia = shangjiaService.selectById(nongchanpin.getShangjiaId());
            if(shangjia != null){
            BeanUtils.copyProperties( shangjia , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "shangjiaId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setShangjiaId(shangjia.getId());
            }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

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

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");
        else if("商家".equals(role))
            nongchanpin.setShangjiaId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        Wrapper<NongchanpinEntity> queryWrapper = new EntityWrapper<NongchanpinEntity>()
            .eq("shangjia_id", nongchanpin.getShangjiaId())
            .eq("nongchanpin_name", nongchanpin.getNongchanpinName())
            .eq("nongchanpin_types", nongchanpin.getNongchanpinTypes())
            .eq("nongchanpin_kucun_number", nongchanpin.getNongchanpinKucunNumber())
            .eq("nongchanpin_price", nongchanpin.getNongchanpinPrice())
            .eq("nongchanpin_pintuan", nongchanpin.getNongchanpinPintuan())
            .eq("zan_number", nongchanpin.getZanNumber())
            .eq("cai_number", nongchanpin.getCaiNumber())
            .eq("shangxia_types", nongchanpin.getShangxiaTypes())
            .eq("nongchanpin_delete", nongchanpin.getNongchanpinDelete())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        NongchanpinEntity nongchanpinEntity = nongchanpinService.selectOne(queryWrapper);
        if(nongchanpinEntity==null){
            nongchanpin.setNongchanpinClicknum(1);
            nongchanpin.setShangxiaTypes(1);
            nongchanpin.setNongchanpinDelete(1);
            nongchanpin.setInsertTime(new Date());
            nongchanpin.setCreateTime(new Date());
            nongchanpinService.insert(nongchanpin);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody NongchanpinEntity nongchanpin, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,nongchanpin:{}",this.getClass().getName(),nongchanpin.toString());
        NongchanpinEntity oldNongchanpinEntity = nongchanpinService.selectById(nongchanpin.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
//        else if("商家".equals(role))
//            nongchanpin.setShangjiaId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
        if("".equals(nongchanpin.getNongchanpinPhoto()) || "null".equals(nongchanpin.getNongchanpinPhoto())){
                nongchanpin.setNongchanpinPhoto(null);
        }

            nongchanpinService.updateById(nongchanpin);//根据id更新
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<NongchanpinEntity> oldNongchanpinList =nongchanpinService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        ArrayList<NongchanpinEntity> list = new ArrayList<>();
        for(Integer id:ids){
            NongchanpinEntity nongchanpinEntity = new NongchanpinEntity();
            nongchanpinEntity.setId(id);
            nongchanpinEntity.setNongchanpinDelete(2);
            list.add(nongchanpinEntity);
        }
        if(list != null && list.size() >0){
            nongchanpinService.updateBatchById(list);
        }

        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName, HttpServletRequest request){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            List<NongchanpinEntity> nongchanpinList = 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){
                            //循环
                            NongchanpinEntity nongchanpinEntity = new NongchanpinEntity();
//                            nongchanpinEntity.setShangjiaId(Integer.valueOf(data.get(0)));   //商家 要改的
//                            nongchanpinEntity.setNongchanpinName(data.get(0));                    //商品名称 要改的
//                            nongchanpinEntity.setNongchanpinUuidNumber(data.get(0));                    //商品编号 要改的
//                            nongchanpinEntity.setNongchanpinPhoto("");//详情和图片
//                            nongchanpinEntity.setNongchanpinTypes(Integer.valueOf(data.get(0)));   //商品类型 要改的
//                            nongchanpinEntity.setNongchanpinKucunNumber(Integer.valueOf(data.get(0)));   //商品库存 要改的
//                            nongchanpinEntity.setNongchanpinOldMoney(data.get(0));                    //商品原价 要改的
//                            nongchanpinEntity.setNongchanpinNewMoney(data.get(0));                    //现价 要改的
//                            nongchanpinEntity.setNongchanpinPrice(Integer.valueOf(data.get(0)));   //购买获得积分 要改的
//                            nongchanpinEntity.setNongchanpinPintuan(Integer.valueOf(data.get(0)));   //拼团限制/人 要改的
//                            nongchanpinEntity.setNongchanpinClicknum(Integer.valueOf(data.get(0)));   //商品热度 要改的
//                            nongchanpinEntity.setZanNumber(Integer.valueOf(data.get(0)));   //赞 要改的
//                            nongchanpinEntity.setCaiNumber(Integer.valueOf(data.get(0)));   //踩 要改的
//                            nongchanpinEntity.setNongchanpinContent("");//详情和图片
//                            nongchanpinEntity.setShangxiaTypes(Integer.valueOf(data.get(0)));   //是否上架 要改的
//                            nongchanpinEntity.setNongchanpinDelete(1);//逻辑删除字段
//                            nongchanpinEntity.setInsertTime(date);//时间
//                            nongchanpinEntity.setCreateTime(date);//时间
                            nongchanpinList.add(nongchanpinEntity);


                            //把要查询是否重复的字段放入map中
                                //商品编号
                                if(seachFields.containsKey("nongchanpinUuidNumber")){
                                    List<String> nongchanpinUuidNumber = seachFields.get("nongchanpinUuidNumber");
                                    nongchanpinUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> nongchanpinUuidNumber = new ArrayList<>();
                                    nongchanpinUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("nongchanpinUuidNumber",nongchanpinUuidNumber);
                                }
                        }

                        //查询是否重复
                         //商品编号
                        List<NongchanpinEntity> nongchanpinEntities_nongchanpinUuidNumber = nongchanpinService.selectList(new EntityWrapper<NongchanpinEntity>().in("nongchanpin_uuid_number", seachFields.get("nongchanpinUuidNumber")).eq("nongchanpin_delete", 1));
                        if(nongchanpinEntities_nongchanpinUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(NongchanpinEntity s:nongchanpinEntities_nongchanpinUuidNumber){
                                repeatFields.add(s.getNongchanpinUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [商品编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        nongchanpinService.insertBatch(nongchanpinList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }



    /**
    * 个性推荐
    */
    @IgnoreAuth
    @RequestMapping("/gexingtuijian")
    public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("gexingtuijian方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        CommonUtil.checkMap(params);
        List<NongchanpinView> returnNongchanpinViewList = new ArrayList<>();

        //查询订单
        Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));
        PageUtils pageUtils = nongchanpinOrderService.queryPage(params1);
        List<NongchanpinOrderView> orderViewsList =(List<NongchanpinOrderView>)pageUtils.getList();
        Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型list
        for(NongchanpinOrderView orderView:orderViewsList){
            Integer nongchanpinTypes = orderView.getNongchanpinTypes();
            if(typeMap.containsKey(nongchanpinTypes)){
                typeMap.put(nongchanpinTypes,typeMap.get(nongchanpinTypes)+1);
            }else{
                typeMap.put(nongchanpinTypes,1);
            }
        }
        List<Integer> typeList = new ArrayList<>();//排序后的有序的类型 按最多到最少
        typeMap.entrySet().stream().sorted((o1, o2) -> o2.getValue() - o1.getValue()).forEach(e -> typeList.add(e.getKey()));//排序
        Integer limit = Integer.valueOf(String.valueOf(params.get("limit")));
        for(Integer type:typeList){
            Map<String, Object> params2 = new HashMap<>(params);params2.put("nongchanpinTypes",type);
            PageUtils pageUtils1 = nongchanpinService.queryPage(params2);
            List<NongchanpinView> nongchanpinViewList =(List<NongchanpinView>)pageUtils1.getList();
            returnNongchanpinViewList.addAll(nongchanpinViewList);
            if(returnNongchanpinViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环
        }
        //正常查询出来商品,用于补全推荐缺少的数据
        PageUtils page = nongchanpinService.queryPage(params);
        if(returnNongchanpinViewList.size()<limit){//返回数量还是小于要求数量
            int toAddNum = limit - returnNongchanpinViewList.size();//要添加的数量
            List<NongchanpinView> nongchanpinViewList =(List<NongchanpinView>)page.getList();
            for(NongchanpinView nongchanpinView:nongchanpinViewList){
                Boolean addFlag = true;
                for(NongchanpinView returnNongchanpinView:returnNongchanpinViewList){
                    if(returnNongchanpinView.getId().intValue() ==nongchanpinView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品
                }
                if(addFlag){
                    toAddNum=toAddNum-1;
                    returnNongchanpinViewList.add(nongchanpinView);
                    if(toAddNum==0) break;//够数量了
                }
            }
        }else {
            returnNongchanpinViewList = returnNongchanpinViewList.subList(0, limit);
        }

        for(NongchanpinView c:returnNongchanpinViewList)
            dictionaryService.dictionaryConvert(c, request);
        page.setList(returnNongchanpinViewList);
        return R.ok().put("data", page);
    }

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

        CommonUtil.checkMap(params);
        PageUtils page = nongchanpinService.queryPage(params);

        //字典表数据转换
        List<NongchanpinView> list =(List<NongchanpinView>)page.getList();
        for(NongchanpinView 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);
        NongchanpinEntity nongchanpin = nongchanpinService.selectById(id);
            if(nongchanpin !=null){

                //点击数量加1
                nongchanpin.setNongchanpinClicknum(nongchanpin.getNongchanpinClicknum()+1);
                nongchanpinService.updateById(nongchanpin);

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

                //级联表
                    ShangjiaEntity shangjia = shangjiaService.selectById(nongchanpin.getShangjiaId());
                if(shangjia != null){
                    BeanUtils.copyProperties( shangjia , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setShangjiaId(shangjia.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody NongchanpinEntity nongchanpin, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,nongchanpin:{}",this.getClass().getName(),nongchanpin.toString());
        Wrapper<NongchanpinEntity> queryWrapper = new EntityWrapper<NongchanpinEntity>()
            .eq("shangjia_id", nongchanpin.getShangjiaId())
            .eq("nongchanpin_name", nongchanpin.getNongchanpinName())
            .eq("nongchanpin_uuid_number", nongchanpin.getNongchanpinUuidNumber())
            .eq("nongchanpin_types", nongchanpin.getNongchanpinTypes())
            .eq("nongchanpin_kucun_number", nongchanpin.getNongchanpinKucunNumber())
            .eq("nongchanpin_price", nongchanpin.getNongchanpinPrice())
            .eq("nongchanpin_pintuan", nongchanpin.getNongchanpinPintuan())
            .eq("nongchanpin_clicknum", nongchanpin.getNongchanpinClicknum())
            .eq("zan_number", nongchanpin.getZanNumber())
            .eq("cai_number", nongchanpin.getCaiNumber())
            .eq("shangxia_types", nongchanpin.getShangxiaTypes())
            .eq("nongchanpin_delete", nongchanpin.getNongchanpinDelete())
//            .notIn("nongchanpin_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        NongchanpinEntity nongchanpinEntity = nongchanpinService.selectOne(queryWrapper);
        if(nongchanpinEntity==null){
            nongchanpin.setNongchanpinDelete(1);
            nongchanpin.setInsertTime(new Date());
            nongchanpin.setCreateTime(new Date());
        nongchanpinService.insert(nongchanpin);

            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

}

5.2 农产品Service模块 

 package com.service;

import com.baomidou.mybatisplus.service.IService;
import com.utils.PageUtils;
import com.entity.NongchanpinEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;

/**
 * 商品 服务类
 */
public interface NongchanpinService extends IService<NongchanpinEntity> {

    /**
    * @param params 查询参数
    * @return 带分页的查询出来的数据
    */
     PageUtils queryPage(Map<String, Object> params);

}

5.3 农产品ServiceImpl模块


package com.service.impl;

import com.utils.StringUtil;
import com.service.DictionaryService;
import com.utils.ClazzDiff;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.*;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.dao.NongchanpinDao;
import com.entity.NongchanpinEntity;
import com.service.NongchanpinService;
import com.entity.view.NongchanpinView;

/**
 * 商品 服务实现类
 */
@Service("nongchanpinService")
@Transactional
public class NongchanpinServiceImpl extends ServiceImpl<NongchanpinDao, NongchanpinEntity> implements NongchanpinService {

    @Override
    public PageUtils queryPage(Map<String,Object> params) {
        Page<NongchanpinView> page =new Query<NongchanpinView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page,params));
        return new PageUtils(page);
    }


}

5.4  农产品Dao模块


package com.dao;

import com.entity.NongchanpinEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;

import org.apache.ibatis.annotations.Param;
import com.entity.view.NongchanpinView;

/**
 * 商品 Dao 接口
 *
 * @author 
 */
public interface NongchanpinDao extends BaseMapper<NongchanpinEntity> {

   List<NongchanpinView> selectListView(Pagination page,@Param("params")Map<String,Object> params);

}

6、论文目录结构

摘要... I

Abstract... II

1 绪论... 1
   1.1 项目简介... 1
   1.2 调查研究... 1
       1.2.1 研究背景及意义... 1
       1.2.2 国内外研究现状... 2
       1.2.3 研究主要内容... 2
   1.3 论文的章节安排... 3

2 系统相关技术介绍... 4
   2.1 Java语言... 4
   2.2 SpringBoot框架... 4
   2.3 Vue框架... 4
   2.4 MySQL数据库... 4

3 系统需求分析... 6
   3.1 可行性分析... 6
       3.1.1 技术可行性... 6
       3.1.2 经济可行性... 6
       3.1.3 操作可行性... 6
   3.2 系统功能需求... 6
       3.2.1 用户端功能需求... 6
       3.2.2 XX端功能需求... 6
       3.2.3 管理员端功能需求... 6
   3.3 系统性能需求... 6

4 系统总体设计... 7
   4.1 系统总体架构设计... 7
   4.2 系统的功能设计... 7
   4.3 数据库设计... 7
       4.3.1 概念设计E-R图... 7
       4.3.2 逻辑设计关系模式... 7
       4.3.3 数据库物理设计... 7

5 系统详细实现... 14
   5.1 系统实现环境... 14
   5.2 用户端... 14
       5.2.1 登录页面... 14
       5.2.2 注册页面... 14
       5.2.3 XXXX页面... 14
       5.2.4 XXXX页面... 14
       5.2.5 XXXX页面... 14
   5.3 XXXX端... 15
       5.3.1 XXXX页面... 15
       5.3.2 XXXX页面... 15
       5.3.3 XXXX页面... 15
       5.3.4 XXXX页面... 15
   5.4 管理端... 15
       5.4.1 用户管理页面... 15
       5.4.2 XXXX页面... 15
       5.4.3 XXXX页面... 16
       5.4.4 XXXX页面... 16

6 系统测试... 16
   6.1 测试目的... 16
   6.2 测试方法... 16
   6.3 测试用例... 16
       6.3.1 XXXX测试... 16
       6.3.2 XXXX测试... 16
   6.4 测试结果... 16

结论... 17

参考文献... 18

致谢... 19

更多源码:

计算机毕业设计选题1000套等你来!!!

Python毕设精品项目

微信小程序毕设精品项目  

大数据及机器学习毕设精品项目 

7、源码获取

感谢大家的阅读,如有不懂的问题可以评论区交流或私聊!

喜欢文章可以点赞、收藏、关注、评论

下方联系方式获取源码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值