博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
一、项目介绍
仓库管理系统基于SpringBoot+Mybatis开发,系统使用shiro框架做权限安全控制,超级管理员登录系统后可根据自己的实际需求配角色,然后新建用户选择角色即可。
超级管理员功能如下:
- 客户管理
- 供应商管理
- 商品管理
- 商品进货
- 商品销售
- 退货查询
- 系统管理
- 部门管理
- 菜单管理
- 角色管理
- 权限管理
- 用户管理
- 公告管理
- 系统日志
二、技术框架
- 后端:SpringBoot,Mybatis
- 前端:layui
三、安装教程
- 用idea打开项目
- 在idea中配置jdk环境
- 配置maven环境并下载依赖
- 新建数据库,导入数据库文件
- 在application.yml文件中将数据库账号密码改成自己本地的
- 系统的静态资源存储在F盘,如果你的电脑没有F盘,则需要改成其他盘,具体位置在file.properties和FileConfig.java两个文件,将文件里面的F:/upload 改成你本地的即可。
- 启动运行, 管理员账号密码 admin/123456 ,普通用户账号密码 user/123456
四、项目截图
五、相关代码
GoodsController
package com.yeqifu.bus.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeqifu.bus.entity.Goods;
import com.yeqifu.bus.entity.Provider;
import com.yeqifu.bus.service.IGoodsService;
import com.yeqifu.bus.service.IProviderService;
import com.yeqifu.bus.vo.GoodsVo;
import com.yeqifu.sys.common.AppFileUtils;
import com.yeqifu.sys.common.Constast;
import com.yeqifu.sys.common.DataGridView;
import com.yeqifu.sys.common.ResultObj;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* InnoDB free: 9216 kB; (`providerid`) REFER `warehouse/bus_provider`(`id`) 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/goods")
public class GoodsController {
@Autowired
private IGoodsService goodsService;
@Autowired
private IProviderService providerService;
/**
* 查询商品
* @param goodsVo
* @return
*/
@RequestMapping("loadAllGoods")
public DataGridView loadAllGoods(GoodsVo goodsVo){
IPage<Goods> page = new Page<Goods>(goodsVo.getPage(),goodsVo.getLimit());
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
queryWrapper.eq(goodsVo.getProviderid()!=null&&goodsVo.getProviderid()!=0,"providerid",goodsVo.getProviderid());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getGoodsname()),"goodsname",goodsVo.getGoodsname());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getProductcode()),"productcode",goodsVo.getProductcode());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getPromitcode()),"promitcode",goodsVo.getPromitcode());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getDescription()),"description",goodsVo.getDescription());
queryWrapper.like(StringUtils.isNotBlank(goodsVo.getSize()),"size",goodsVo.getSize());
queryWrapper.orderByDesc("id");
goodsService.page(page,queryWrapper);
List<Goods> records = page.getRecords();
for (Goods goods : records) {
Provider provider = providerService.getById(goods.getProviderid());
if (null!=provider){
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridView(page.getTotal(),page.getRecords());
}
/**
* 添加商品
* @param goodsVo
* @return
*/
@RequestMapping("addGoods")
public ResultObj addGoods(GoodsVo goodsVo){
try {
System.out.println("====================================");
System.out.println(goodsVo.getGoodsimg());
if (goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().endsWith("_temp")){
String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg());
goodsVo.setGoodsimg(newName);
}
goodsService.save(goodsVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
/**
* 修改商品
* @param goodsVo
* @return
*/
@RequestMapping("updateGoods")
public ResultObj updateGoods(GoodsVo goodsVo){
try {
//商品图片不是默认图片
if (!(goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().equals(Constast.DEFAULT_IMG_GOODS))){
if (goodsVo.getGoodsimg().endsWith("_temp")){
String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg());
goodsVo.setGoodsimg(newName);
//删除原先的图片
String oldPath = goodsService.getById(goodsVo.getId()).getGoodsimg();
AppFileUtils.removeFileByPath(oldPath);
}
}
goodsService.updateById(goodsVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/**
* 删除商品
* @param id 商品id
* @return
*/
@RequestMapping("deleteGoods")
public ResultObj deleteGoods(Integer id,String goodsimg){
try {
//删除商品的图片
AppFileUtils.removeFileByPath(goodsimg);
// goodsService.removeById(id);
goodsService.deleteGoodsById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/**
* 加载所有可用的商品
* @return
*/
@RequestMapping("loadAllGoodsForSelect")
public DataGridView loadAllGoodsForSelect(){
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
List<Goods> list = goodsService.list(queryWrapper);
for (Goods goods : list) {
Provider provider = providerService.getById(goods.getProviderid());
if (null!=provider){
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridView(list);
}
/**
* 根据供应商ID查询商品信息
* @param providerid 供应商ID
* @return
*/
@RequestMapping("loadGoodsByProviderId")
public DataGridView loadGoodsByProviderId(Integer providerid){
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
queryWrapper.eq(providerid!=null,"providerid",providerid);
List<Goods> list = goodsService.list(queryWrapper);
for (Goods goods : list) {
Provider provider = providerService.getById(goods.getProviderid());
if (null!=provider){
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridView(list);
}
@RequestMapping("loadAllWarningGoods")
public DataGridView loadAllWarningGoods(){
List<Goods> goods = goodsService.loadAllWarning();
return new DataGridView((long) goods.size(),goods);
}
}
InportController
package com.yeqifu.bus.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeqifu.bus.entity.Goods;
import com.yeqifu.bus.entity.Inport;
import com.yeqifu.bus.entity.Provider;
import com.yeqifu.bus.service.IGoodsService;
import com.yeqifu.bus.service.IInportService;
import com.yeqifu.bus.service.IProviderService;
import com.yeqifu.bus.vo.InportVo;
import com.yeqifu.sys.common.DataGridView;
import com.yeqifu.sys.common.ResultObj;
import com.yeqifu.sys.common.WebUtils;
import com.yeqifu.sys.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
/**
* <p>
* InnoDB free: 9216 kB; (`providerid`) REFER `warehouse/bus_provider`(`id`); (`goo 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("inport")
public class InportController {
@Autowired
private IInportService inportService;
@Autowired
private IProviderService providerService;
@Autowired
private IGoodsService goodsService;
/**
* 查询商品进货
* @param inportVo
* @return
*/
@RequestMapping("loadAllInport")
public DataGridView loadAllInport(InportVo inportVo){
IPage<Inport> page = new Page<Inport>(inportVo.getPage(),inportVo.getLimit());
QueryWrapper<Inport> queryWrapper = new QueryWrapper<Inport>();
//对供应商进行查询
queryWrapper.eq(inportVo.getProviderid()!=null&&inportVo.getProviderid()!=0,"providerid",inportVo.getProviderid());
//对商品进行查询
queryWrapper.eq(inportVo.getGoodsid()!=null&&inportVo.getGoodsid()!=0,"goodsid",inportVo.getGoodsid());
//对时间进行查询要求大于开始时间小于结束时间
queryWrapper.ge(inportVo.getStartTime()!=null,"inporttime",inportVo.getStartTime());
queryWrapper.le(inportVo.getEndTime()!=null,"inporttime",inportVo.getEndTime());
//通过进货时间对商品进行排序
queryWrapper.orderByDesc("inporttime");
IPage<Inport> page1 = inportService.page(page, queryWrapper);
List<Inport> records = page1.getRecords();
for (Inport inport : records) {
Provider provider = providerService.getById(inport.getProviderid());
if (provider!=null){
//设置供应商姓名
inport.setProvidername(provider.getProvidername());
}
Goods goods = goodsService.getById(inport.getGoodsid());
if (goods!=null){
//设置商品名称
inport.setGoodsname(goods.getGoodsname());
//设置商品规格
inport.setSize(goods.getSize());
}
}
return new DataGridView(page1.getTotal(),page1.getRecords());
}
/**
* 添加进货商品
* @param inportVo
* @return
*/
@RequestMapping("addInport")
public ResultObj addInport(InportVo inportVo){
try {
//获得当前系统用户
User user = (User) WebUtils.getSession().getAttribute("user");
//设置操作人
inportVo.setOperateperson(user.getName());
//设置进货时间
inportVo.setInporttime(new Date());
inportService.save(inportVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
/**
* 更新进货商品
* @param inportVo
* @return
*/
@RequestMapping("updateInport")
public ResultObj updateInport(InportVo inportVo){
try {
inportService.updateById(inportVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/**
* 删除进货商品
* @param id
* @return
*/
@RequestMapping("deleteInport")
public ResultObj deleteInport(Integer id){
try {
inportService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 100