作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目为前后端分离的项目;
系统分为用户、管理员和超级管理员三个角色
本系统包含登录、主页、个人中心、用户信息管理、仓库信息管理(出库、入库)、物品分类管理、物品信息管理、操作日志等功能
使用人群:
正在做毕设的学生,或者需要项目实战练习的Java学习者
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 前端推荐使用vscode;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;
6.是否为前后端分离项目:是;
技术栈
后端框架:Springboot
前端技术:ElementUI、Vue、nodejs
使用说明
后端项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入源码中的WarehouseManager项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,控制台提示运行成功后再去运行前端项目;
前端项目运行:
1.打开运行中的cmd;
2.cd到WarehouseManagerVue文件夹目录;
3.执行命令:npm run serve
4. 运行成功后,在浏览器中输入地址:http://localhost:9132/
超级管理员:superadmin/123456
管理员:admin/123456
用户:user/123456
运行截图
相关代码
GoodsController
package com.rabbiter.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.common.QueryPageParam;
import com.rabbiter.common.Result;
import com.rabbiter.entity.Goods;
import com.rabbiter.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
/**
* <p>
* 前端控制器:物品管理
* </p>
*
* @author rabbiter
* @since 2023-01-06
*/
@RestController
@RequestMapping("/goods")
public class GoodsController {
@Autowired
private GoodsService goodsService;
/*
* 新增物品
* @author rabbiter
* @date 2023/1/6 12:12
*/
@PostMapping("/save")
public Result save(@RequestBody Goods goods){
return goodsService.save(goods)?Result.success():Result.fail();
}
/*
* 更新物品
* @author rabbiter
* @date 2023/1/6 13:22
*/
@PostMapping("/update")
public Result update(@RequestBody Goods goods){
return goodsService.updateById(goods)?Result.success():Result.fail();
}
/*
* 删除物品
* @author rabbiter
* @date 2023/1/6 13:24
*/
@GetMapping("/del")
public Result del(@RequestParam String id){
return goodsService.removeById(id)?Result.success():Result.fail();
}
/*
* 模糊查询:根据输入查询物品并以分页的形式展示
* @author rabbiter
* @date 2023/1/6 13:31
*/
@PostMapping("/listPage")
public Result listPage(@RequestBody QueryPageParam query){
HashMap param = query.getParam();
String name = (String)param.get("name");
String goodstype = (String)param.get("goodstype");
String storage = (String)param.get("storage");
Page<Goods> page = new Page();
page.setCurrent(query.getPageNum());
page.setSize(query.getPageSize());
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
if(StringUtils.isNotBlank(name) && !"null".equals(name)){
queryWrapper.like(Goods::getName,name);
}
if(StringUtils.isNotBlank(goodstype) && !"null".equals(goodstype)){
queryWrapper.like(Goods::getGoodstype,goodstype);
}
if(StringUtils.isNotBlank(storage) && !"null".equals(storage)){
queryWrapper.like(Goods::getStorage,storage);
}
IPage result = goodsService.pageCC(page,queryWrapper);
return Result.success(result.getRecords(),result.getTotal());
}
}
GoodstypeController
package com.rabbiter.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.common.QueryPageParam;
import com.rabbiter.common.Result;
import com.rabbiter.entity.Goodstype;
import com.rabbiter.service.GoodstypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* 前端控制器:物品分类管理
* </p>
*
* @author rabbiter
* @since 2023-01-05
*/
@RestController
@RequestMapping("/goodstype")
public class GoodstypeController {
@Autowired
private GoodstypeService goodstypeService;
/*
* 新增物品分类
* @author rabbiter
* @date 2023/1/5 20:39
*/
@PostMapping("/save")
public Result save(@RequestBody Goodstype goodstype){
return goodstypeService.save(goodstype)?Result.success():Result.fail();
}
/*
* 更新物品分类
* @author rabbiter
* @date 2023/1/5 20:41
*/
@PostMapping("/update")
public Result update(@RequestBody Goodstype goodstype){
return goodstypeService.updateById(goodstype)?Result.success():Result.fail();
}
/*
* 删除物品分类
* @author rabbiter
* @date 2023/1/5 20:43
*/
@GetMapping("/del")
public Result del(@RequestParam String id){
return goodstypeService.removeById(id)?Result.success():Result.fail();
}
/*
* 查询物品分类列表
* @author rabbiter
* @date 2023/1/5 21:06
*/
@GetMapping("/list")
public Result list(){
List list = goodstypeService.list();
return Result.success(list);
}
/*
* 模糊查询:根据输入查询物品分类并以分页的形式展示
* @author rabbiter
* @date 2023/1/5 21:13
*/
@PostMapping("/listPage")
public Result listPage(@RequestBody QueryPageParam query){
HashMap param = query.getParam();
String name = (String)param.get("name");
Page<Goodstype> page = new Page();
page.setCurrent(query.getPageNum());
page.setSize(query.getPageSize());
LambdaQueryWrapper<Goodstype> queryWrapper = new LambdaQueryWrapper();
if(StringUtils.isNotBlank(name) && !"null".equals(name)){
queryWrapper.like(Goodstype::getName,name);
}
IPage result = goodstypeService.pageCC(page,queryWrapper);
return Result.success(result.getRecords(),result.getTotal());
}
}
StorageController
package com.rabbiter.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.common.QueryPageParam;
import com.rabbiter.common.Result;
import com.rabbiter.entity.Storage;
import com.rabbiter.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* 前端控制器:仓库管理模块
* </p>
*
* @author rabbiter
* @since 2023-01-05
*/
@RestController
@RequestMapping("/storage")
public class StorageController {
@Autowired
private StorageService storageService;
/*
* 新增仓库
* @author rabbiter
* @date 2023/1/5 19:36
*/
@PostMapping("/save")
public Result save(@RequestBody Storage storage){
return storageService.save(storage)?Result.success():Result.fail();
}
/*
* 更新仓库
* @author rabbiter
* @date 2023/1/5 19:38
*/
@PostMapping("/update")
public Result update(@RequestBody Storage storage){
return storageService.updateById(storage)?Result.success():Result.fail();
}
/*
* 删除仓库
* @author rabbiter
* @date 2023/1/5 19:40
*/
@GetMapping("/del")
public Result del(@RequestParam String id){
return storageService.removeById(id)?Result.success():Result.fail();
}
/*
* 查询仓库列表
* @author rabbiter
* @date 2023/1/5 19:42
*/
@GetMapping("/list")
public Result list(){
List list = storageService.list();
return Result.success(list);
}
/*
* 模糊查询:根据输入查询仓库并以分页的形式展示
* @author rabbiter
* @date 2023/1/5 19:43
*/
@PostMapping("/listPage")
public Result listPage(@RequestBody QueryPageParam query){
HashMap param = query.getParam();
String name = (String)param.get("name");
Page<Storage> page = new Page();
page.setCurrent(query.getPageNum());
page.setSize(query.getPageSize());
LambdaQueryWrapper<Storage> queryWrapper = new LambdaQueryWrapper<>();
if(StringUtils.isNotBlank(name) && !"null".equals(name)){
queryWrapper.like(Storage::getName,name);
}
IPage result = storageService.pageCC(page,queryWrapper);
return Result.success(result.getRecords(),result.getTotal());
}
}
RecordController
package com.rabbiter.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.common.QueryPageParam;
import com.rabbiter.common.Result;
import com.rabbiter.entity.Goods;
import com.rabbiter.service.GoodsService;
import com.rabbiter.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.rabbiter.entity.Record;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.HashMap;
/**
* <p>
* 前端控制器:记录管理
* </p>
*
* @author rabbiter
* @since 2023-01-06
*/
@RestController
@RequestMapping("/record")
public class RecordController {
@Autowired
private RecordService recordService;
@Autowired
private GoodsService goodsService;
/*
*
* @author rabbiter
* @date 2023/1/6 20:58
*/
@PostMapping("/listPage")
public Result listPage(@RequestBody QueryPageParam query){
HashMap param = query.getParam();
String name = (String)param.get("name");
String goodstype = (String)param.get("goodstype");
String storage = (String)param.get("storage");
String roleId = (String)param.get("roleId");
String userId = (String)param.get("userId");
Page page = new Page();
page.setCurrent(query.getPageNum());
page.setSize(query.getPageSize());
QueryWrapper<Record> queryWrapper = new QueryWrapper();
queryWrapper.apply("a.goods=b.id and b.storage=c.id and b.goodsType=d.id ");
if("2".equals(roleId)){
// queryWrapper.eq(Record::getUserid,userId);
queryWrapper.apply(" a.userId= "+userId);
}
if(StringUtils.isNotBlank(name) && !"null".equals(name)){
queryWrapper.like("b.name",name);
}
if(StringUtils.isNotBlank(goodstype) && !"null".equals(goodstype)){
queryWrapper.eq("d.id",goodstype);
}
if(StringUtils.isNotBlank(storage) && !"null".equals(storage)){
queryWrapper.eq("c.id",storage);
}
IPage result = recordService.pageCC(page,queryWrapper);
return Result.success(result.getRecords(),result.getTotal());
}
/*
* 新增记录
* @author rabbiter
* @date 2023/1/6 21:21
*/
@PostMapping("/save")
public Result save(@RequestBody Record record){
Goods goods = goodsService.getById(record.getGoods());
int n = record.getCount();
// 出库
if("2".equals(record.getAction())){
n = -n;
record.setCount(n);
}
int num = goods.getCount()+n;
if(num < 0) {
return Result.fail();
}
goods.setCount(num);
goodsService.updateById(goods);
record.setCreatetime(LocalDateTime.now());
return recordService.save(record)?Result.success():Result.fail();
}
}
如果也想学习本系统,下面领取。关注并回复:227boot
标签:vue,Java,rabbiter,name,String,Result,import,com,Springboot From: https://blog.csdn.net/hanyunlong1989/article/details/142887073