基于java+springboot+vue的二手车交易系统

项目介绍

如今社会上各行各业,都喜欢用自己行业的专属软件工作,互联网发展到这个时候,人们已经发现离不开了互联网。新技术的产生,往往能解决一些老技术的弊端问题。因为传统二手车交易信息管理难度大,容错率低,管理人员处理数据费工费时,所以专门为解决这个难题开发了一个二手车交易系统,可以解决许多问题。

二手车交易系统可以实现汽车管理,汽车留言管理,汽车收藏管理,汽车品牌管理,公告类型管理,论坛管理,商家管理,用户管理等功能。该系统采用了Mysql数据库,Java语言,Spring Boot框架等技术进行编程实现。

二手车交易系统可以提高二手车交易信息管理问题的解决效率,优化二手车交易信息处理流程,保证二手车交易信息数据的安全,它是一个非常可靠,非常安全的应用程序。

4.2 功能结构设计
图4.1即为设计的管理员功能结构,管理员权限操作的功能包括增删改查商家,用户,公告,管理论坛信息,管理汽车和汽车留言以及汽车收藏信息等。
在这里插入图片描述
图4.2即为设计的商家功能结构,商家权限操作的功能包括新增汽车,上架汽车,下架汽车,回复汽车留言,管理汽车收藏,管理论坛信息。
在这里插入图片描述
图4.3即为设计的用户功能结构,用户权限操作的功能包括收藏汽车,发布关于汽车的留言,查看汽车的介绍信息,通过论坛进行信息讨论与交流,查看公告等。
在这里插入图片描述

开发环境

编程语言:Java
数据库 :Mysql
系统架构:B/S
后端框架:SpringBoot
编译工具:idea或者eclipse,jdk1.8,maven
支持定做:java/php/python/android/小程序vue/爬虫/c#/asp.net

系统实现

5.1 管理员功能实现
5.1.1 商家管理
图5.1 即为编码实现的商家管理界面,商家信息包括联系方式,邮箱,商家名称等信息。管理可以使用修改功能对登记有误的商家信息进行修改,可以删除需要删除的商家信息等。
在这里插入图片描述

图5.1 商家管理界面

5.1.2 公告信息管理
图5.2 即为编码实现的公告信息管理界面,公告信息包括公告内容,图片等信息。管理可以使用修改功能对登记有误的公告信息进行修改,可以删除需要删除的公告信息等。
在这里插入图片描述

图5.2 公告信息管理界面

5.1.3 论坛管理
图5.3 即为编码实现的论坛管理界面,论坛信息包括帖子标题,内容,发帖时间等信息,管理员可以删除需要删除的帖子信息,可以查看帖子的回复信息,可以修改帖子等。
在这里插入图片描述

图5.3 论坛管理界面

5.2 商家功能实现
5.2.1 汽车管理
图5.4 即为编码实现的汽车管理界面,汽车信息包括价格,汽车照片等信息,商家可以新增汽车信息,可以下架汽车,上架汽车以及删除需要删除的汽车信息等。
在这里插入图片描述

图5.4 汽车管理界面

5.2.2 汽车留言管理
图5.5 即为编码实现的汽车留言管理界面,汽车留言内容是用户发布的信息,而汽车的回复内容是商家的回复信息。
在这里插入图片描述

图5.5 汽车留言管理界面

5.2.3 论坛管理
图5.6 即为编码实现的论坛管理界面,商家也能通过论坛管理功能新增帖子,跟踪发布的帖子,比如随时查看帖子的评论,以及查看帖子的详情等。
在这里插入图片描述

图5.6 论坛管理界面

5.3 用户功能实现
5.3.1 汽车信息
图5.7 即为编码实现的汽车信息界面,用户查看汽车信息界面右侧区域展示的系统推荐的汽车信息,用户可以通过汽车介绍的查看来了解汽车,用户可以对汽车点赞或踩,也能在汽车信息界面下方的留言区域发布汽车的留言。
在这里插入图片描述

图5.7 汽车信息界面

5.3.2 在线论坛
图5.8 即为编码实现的在线论坛界面,用户通过在线论坛发布帖子,查看所有的帖子内容,以及用户把自己查看帖子的个人看法通过评论帖子的功能进行发布。
在这里插入图片描述

图5.8 在线论坛界面

5.3.3 公告信息
图5.9 即为编码实现的公告信息界面,用户在查询框中编辑公告标题即可实现对公告信息的查询,用户可以查看公告信息界面展示的任意一条公告信息。
在这里插入图片描述

图5.9 公告信息界面

核心代码

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

    @Autowired
    private CheliangService cheliangService;


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

    //级联表service
    @Autowired
    private ShangjiaService shangjiaService;

    @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"));
        params.put("cheliangDeleteStart",1);params.put("cheliangDeleteEnd",1);
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = cheliangService.queryPage(params);

        //字典表数据转换
        List<CheliangView> list =(List<CheliangView>)page.getList();
        for(CheliangView 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);
        CheliangEntity cheliang = cheliangService.selectById(id);
        if(cheliang !=null){
            //entity转view
            CheliangView view = new CheliangView();
            BeanUtils.copyProperties( cheliang , view );//把实体数据重构到view中

                //级联表
                ShangjiaEntity shangjia = shangjiaService.selectById(cheliang.getShangjiaId());
                if(shangjia != null){
                    BeanUtils.copyProperties( shangjia , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到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 CheliangEntity cheliang, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,cheliang:{}",this.getClass().getName(),cheliang.toString());

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

        Wrapper<CheliangEntity> queryWrapper = new EntityWrapper<CheliangEntity>()
            .eq("shangjia_id", cheliang.getShangjiaId())
            .eq("cheliang_name", cheliang.getCheliangName())
            .eq("cheliang_types", cheliang.getCheliangTypes())
            .eq("cheliang_clicknum", cheliang.getCheliangClicknum())
            .eq("zan_number", cheliang.getZanNumber())
            .eq("cai_number", cheliang.getCaiNumber())
            .eq("shangxia_types", cheliang.getShangxiaTypes())
            .eq("cheliang_delete", cheliang.getCheliangDelete())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CheliangEntity cheliangEntity = cheliangService.selectOne(queryWrapper);
        if(cheliangEntity==null){
            cheliang.setCheliangClicknum(1);
            cheliang.setShangxiaTypes(1);
            cheliang.setCheliangDelete(1);
            cheliang.setCreateTime(new Date());
            cheliangService.insert(cheliang);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

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

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
//        else if("商家".equals(role))
//            cheliang.setShangjiaId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
        //根据字段查询是否有相同数据
        Wrapper<CheliangEntity> queryWrapper = new EntityWrapper<CheliangEntity>()
            .notIn("id",cheliang.getId())
            .andNew()
            .eq("shangjia_id", cheliang.getShangjiaId())
            .eq("cheliang_name", cheliang.getCheliangName())
            .eq("cheliang_types", cheliang.getCheliangTypes())
            .eq("cheliang_clicknum", cheliang.getCheliangClicknum())
            .eq("zan_number", cheliang.getZanNumber())
            .eq("cai_number", cheliang.getCaiNumber())
            .eq("shangxia_types", cheliang.getShangxiaTypes())
            .eq("cheliang_delete", cheliang.getCheliangDelete())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CheliangEntity cheliangEntity = cheliangService.selectOne(queryWrapper);
        if("".equals(cheliang.getCheliangPhoto()) || "null".equals(cheliang.getCheliangPhoto())){
                cheliang.setCheliangPhoto(null);
        }
        if(cheliangEntity==null){
            cheliangService.updateById(cheliang);//根据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());
        ArrayList<CheliangEntity> list = new ArrayList<>();
        for(Integer id:ids){
            CheliangEntity cheliangEntity = new CheliangEntity();
            cheliangEntity.setId(id);
            cheliangEntity.setCheliangDelete(2);
            list.add(cheliangEntity);
        }
        if(list != null && list.size() >0){
            cheliangService.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<CheliangEntity> cheliangList = 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){
                            //循环
                            CheliangEntity cheliangEntity = new CheliangEntity();
//                            cheliangEntity.setShangjiaId(Integer.valueOf(data.get(0)));   //商家 要改的
//                            cheliangEntity.setCheliangName(data.get(0));                    //汽车名称 要改的
//                            cheliangEntity.setCheliangPhoto("");//详情和图片
//                            cheliangEntity.setCheliangTypes(Integer.valueOf(data.get(0)));   //汽车品牌 要改的
//                            cheliangEntity.setCheliangNewMoney(data.get(0));                    //价格 要改的
//                            cheliangEntity.setCheliangClicknum(Integer.valueOf(data.get(0)));   //点击次数 要改的
//                            cheliangEntity.setZanNumber(Integer.valueOf(data.get(0)));   //赞 要改的
//                            cheliangEntity.setCaiNumber(Integer.valueOf(data.get(0)));   //踩 要改的
//                            cheliangEntity.setCheliangContent("");//详情和图片
//                            cheliangEntity.setShangxiaTypes(Integer.valueOf(data.get(0)));   //是否上架 要改的
//                            cheliangEntity.setCheliangDelete(1);//逻辑删除字段
//                            cheliangEntity.setCreateTime(date);//时间
                            cheliangList.add(cheliangEntity);


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

                        //查询是否重复
                        cheliangService.insertBatch(cheliangList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            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");
        }
        if(StringUtils.isBlank(String.valueOf(params.get("cheliangNewMoneyStart")))){
            params.remove("cheliangNewMoneyStart");
        }
        if(StringUtils.isBlank(String.valueOf(params.get("cheliangNewMoneyEnd")))){
            params.remove("cheliangNewMoneyEnd");
        }
        PageUtils page = cheliangService.queryPage(params);

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

                //点击数量加1
                cheliang.setCheliangClicknum(cheliang.getCheliangClicknum()+1);
                cheliangService.updateById(cheliang);

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

                //级联表
                    ShangjiaEntity shangjia = shangjiaService.selectById(cheliang.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 CheliangEntity cheliang, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,cheliang:{}",this.getClass().getName(),cheliang.toString());
        Wrapper<CheliangEntity> queryWrapper = new EntityWrapper<CheliangEntity>()
            .eq("shangjia_id", cheliang.getShangjiaId())
            .eq("cheliang_name", cheliang.getCheliangName())
            .eq("cheliang_types", cheliang.getCheliangTypes())
            .eq("cheliang_clicknum", cheliang.getCheliangClicknum())
            .eq("zan_number", cheliang.getZanNumber())
            .eq("cai_number", cheliang.getCaiNumber())
            .eq("shangxia_types", cheliang.getShangxiaTypes())
            .eq("cheliang_delete", cheliang.getCheliangDelete())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CheliangEntity cheliangEntity = cheliangService.selectOne(queryWrapper);
        if(cheliangEntity==null){
            cheliang.setCheliangDelete(1);
            cheliang.setCreateTime(new Date());
        cheliangService.insert(cheliang);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


}

论文参考

在这里插入图片描述

目 录
摘 要 I
Abstract II
第1章 绪论 1
1.1 课题背景 1
1.2 课题意义 1
1.3 研究内容 1
第2章 开发环境与技术 3
2.1 Java语言 3
2.2 MYSQL数据库 3
2.3 IDEA开发工具 4
2.4 Spring Boot框架 4
第3章 系统分析 5
3.1 可行性分析 5
3.1.1 技术可行性 5
3.1.2 经济可行性 5
3.1.3 操作可行性 5
3.2 系统流程 5
3.2.1 操作流程 6
3.2.2 登录流程 6
3.2.3 删除信息流程 7
3.2.4 添加信息流程 7
3.3 性能需求 8
3.4 功能需求 9
第4章 系统设计 12
4.1 系统设计思想 12
4.2 功能结构设计 13
4.3 数据库设计 15
4.3.1 数据库概念设计 15
4.3.2 数据库物理设计 18
第5章 系统实现 22
5.1 管理员功能实现 22
5.1.1 商家管理 22
5.1.2 公告信息管理 22
5.1.3 论坛管理 23
5.2 商家功能实现 23
5.2.1 汽车管理 23
5.2.2 汽车留言管理 24
5.2.3 论坛管理 24
5.3 用户功能实现 25
5.3.1 汽车信息 25
5.3.2 在线论坛 25
5.3.3 公告信息 26
第6章 系统测试 27
6.1 功能测试 27
6.1.1 登录功能测试 27
6.1.2 修改密码功能测试 28
6.2 系统测试结果 29
结 论 30
参考文献 31
致 谢 32

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值