Java项目:Springboot汽车配件销售管理系统(计算机毕业设计)

作者主页:Java毕设网

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

一、项目介绍

本项目为后台管理系统,
主要功能包括:

公告增删改查,用户管理,登录页面,订单查询,配件添加等等

二、环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
4.数据库:MySql 5.7/8.0版本均可;

5.是否Maven项目:是;

三、技术栈

1. 后端:SpringBoot

2. 前端:HTML+CSS+JavaScript+layui

四、使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:18081/ 登录

五、运行截图


六、相关代码

配件管理配置器

/**
 * 配件控制器
 */
@Api("配件接口API")
@RestController
public class GoodsController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private GoodsService goodsService;

    private String image = "";

    @ApiOperation(value = "配件列表接口", notes = "配件结果集列表")
    @GetMapping("/admin/goodsList")
    public ServerLayResult<Goods> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                       @RequestParam(value = "limit", defaultValue = "10") Integer limit) {
        //查询结果总数
        int count = goodsService.count();
        List<Goods> goods = goodsService.selectAll(page, limit);
        //组装Json数据
        ServerLayResult result = new ServerLayResult(0, "", count, goods);
        return result;
    }

    @ApiOperation(value = "配件删除接口", notes = "根据配件ID删除配件")
    @GetMapping("/admin/goods/del")
    public String delete(Integer id) {
        System.out.println("id = " + id);
        int row = goodsService.deleteByPrimaryKey(id);
        if (row > 0) {
            return "success";
        }
        return "error";
    }

    @ApiOperation(value = "配件更新接口", notes = "根据json数据对象来更新接口")
    @PostMapping("/admin/goods/update")
    public String update(@RequestBody JSONObject ob) {
        com.alibaba.fastjson.JSONObject json = JSON.parseObject(ob.toJSONString());
        logger.info(ob.toJSONString());
        String gname = json.getString("gname");
        Integer id = json.getInteger("id");
        Double goprice = json.getDouble("goprice");
        Double grprice = json.getDouble("grprice");
        Integer gstore = json.getInteger("gstore");
        String goodstypeId = json.getString("goodstypeId");
        if (goodstypeId == null) {
            return "error";
        }
        Goods goods = new Goods();
        goods.setId(id);
        goods.setGname(gname);
        goods.setGoprice(goprice);
        goods.setGrprice(grprice);
        goods.setGstore(gstore);
        GoodsType goodsType = new GoodsType();
        goodsType.setId(Integer.parseInt(goodstypeId));
        goods.setGoodstypeId(goodsType);
        goods.setIputTime(new Date());

//        goods.setGpicture("http://www.csbishe.cn:18081/views/upload/" + image);
        goods.setGpicture("http://localhost:18081/views/upload/" + image);
        logger.info(String.valueOf(goods));
        int insert = goodsService.updateByPrimaryKey(goods);
        if (insert > 0) {
            return "success";
        }
        return "error";
    }

    @ApiOperation(value = "配件保存接口", notes = "根据json数据来保存配件")
    @PostMapping("/admin/goods/add")
    public String addGoods(@RequestBody JSONObject ob) {
        com.alibaba.fastjson.JSONObject json = JSON.parseObject(ob.toJSONString());
        String gname = json.getString("gname");
        Double goprice = json.getDouble("goprice");
        Double grprice = json.getDouble("grprice");
        Integer gstore = json.getInteger("gstore");
        String goodstypeId = json.getString("goodstypeId");
        Goods goods = new Goods();
        goods.setGname(gname);
        goods.setGoprice(goprice);
        goods.setGrprice(grprice);
        goods.setGstore(gstore);
        GoodsType goodsType = new GoodsType();
        goodsType.setId(Integer.parseInt(goodstypeId));
        goods.setGoodstypeId(goodsType);
        goods.setIputTime(new Date());

        goods.setGpicture("http://localhost:18081/views/upload/" + image);
        int insert = goodsService.insert(goods);
        if (insert > 0) {
            return "success";
        }
        return "error";
    }

    /**
     * 实现文件上传
     */
    @ApiOperation(value = "图片上传接口", notes = "根据MultipartFile类上传文件")
    @PostMapping(value = "/admin/uploadImg")
    public Map<String, Object> ramanage(@RequestParam("file") MultipartFile file,
                                        HttpServletRequest request) {
        Map<String, Object> result = new HashMap<>();
        try {
            //获取跟目录
            File path = new File(ResourceUtils.getURL("classpath:").getPath());
            if (!path.exists()) path = new File("");
            System.out.println("path:" + path.getAbsolutePath());
            File upload = new File(path.getAbsolutePath(), "static/images/upload/");
            if (!upload.exists())
                upload.mkdirs();
            String realPath = path.getAbsolutePath() + "/static/views/upload";
            request.setAttribute("path", realPath);
            image = FileUploadUtils.uploadFile(file, realPath);
            result.put("code", 0);
            result.put("image", image);
        } catch (Exception e) {
            result.put("code", 1);
            e.printStackTrace();
        }
        return result;
    }


}

公共控制器

/**
 * 公告控制器
 */
@Api(value = "公告模块AIP接口")
@RestController
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * 查询结果列表
     *
     * @param page
     * @param limit
     * @return
     */
    @SuppressWarnings("rawtypes")
	@ApiOperation(value = "公告模块接口",notes = "公告结果列表")
    @GetMapping("/admin/notice/list")
    public ServerLayResult<Notice> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                        @RequestParam(value = "limit", defaultValue = "10") Integer limit) {
        @SuppressWarnings("unchecked")
		ServerLayResult<Notice> result = new ServerLayResult(0, "", noticeService.count(), noticeService.selectAll(page, limit));
        return result;
    }

    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "公告删除接口",notes = "根据公告id删除公告")
    @GetMapping("/admin/notice/del")
    public String delete(Integer id) {
        System.out.println("id = " + id);
        int row = noticeService.deleteByPrimaryKey(id);
        if (row > 0) {
            return "success";
        }
        return "error";
    }


    /**
     * 更新
     *
     * @param notice
     * @return
     */
    @ApiOperation(value = "更新公告接口",notes = "根据公告前台json数据对象进行删除公告!")
    @PostMapping("/admin/notice/update")
    public String update(@RequestBody Notice notice) {
        Notice upNotice = notice;
        upNotice.setNtime(new Date());
        if (upNotice != null) {
            int index = noticeService.updateByPrimaryKey(upNotice);
            if (index > 0) {
                return "success";
            }
        }
        return "error";
    }

    /**
     * 保存操作
     *
     * @param notice
     * @return
     */
    @ApiOperation(value = "保存公告接口",notes = "根据前台传入json数据对象进行保存公告")
    @PostMapping("/admin/notice/save")
    public String save(@RequestBody Notice notice) {
        Notice saveNotice = notice;
        saveNotice.setNtime(new Date());
        if (saveNotice != null) {
            int index = noticeService.insert(saveNotice);
            if (index > 0) {
                return "success";
            }
        }
        return "error";
    }
}

七、如果也想学习本系统,下面领取。关注并回复:069sb

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值