运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot仓库管理系统设计和实现(java+ssm+springboot+layui+thymeleaf+html+maven)
主要功能模块
1.用户模块管理:用户登录、用户注册、用户的查询、添加、删除操作、
2.客户信息管理:.客户列表的展示、添加、修改、删除操作、
3.供应商管理:供应商详情列表的查看、添加、删除等操作、
4.退货管理和退货查询
5.公告信息管理:公告信息的查看、添加、修改、删除操作、
6.角色管理:角色查询、添加、删除、
7.系统管理、菜单管理以及权限控制
8.管理员信息管理:管理员信息的查看、修改
给大家截一部分效果图:
主要技术:springboot Java、springmvc mysql layui jquery mybatis
userService.page(page,queryWrapper);
//将所有用户数据放入list中
List<User> list = page.getRecords();
for (User user : list) {
Integer deptId = user.getDeptid();
if (deptId!=null){
//先从缓存中去取,如果缓存中没有就去数据库中取
Dept one = deptService.getById(deptId);
//设置user的部门名称
user.setDeptname(one.getName());
}
Integer mgr = user.getMgr();
if (mgr!=null&&mgr!=0){
User one = userService.getById(mgr);
//设置user的领导名称
user.setLeadername(one.getName());
}
}
return new DataGridView(page.getTotal(),list);
}
/**
* 加载排序码
* @return
*/
@RequestMapping("loadUserMaxOrderNum")
public Map<String,Object> loadUserMaxOrderNum(){
Map<String,Object> map = new HashMap<String,Object>();
QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
queryWrapper.orderByDesc("ordernum");
IPage<User> page = new Page<>(1,1);
List<User> list = userService.page(page,queryWrapper).getRecords();
if (list.size()>0){
map.put("value",list.get(0).getOrdernum()+1);
}else {
map.put("value",1);
}
return map;
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("permission")
public class PermissionController {
@Autowired
private IPermissionService permissionService;
/**
* 加载权限左边的权限树
* @param permissionVo
* @return
*/
@RequestMapping("loadPermissionManagerLeftTreeJson")
public DataGridView loadPermissionManagerLeftTreeJson(PermissionVo permissionVo){
QueryWrapper<Permission> queryWrapper = new QueryWrapper<Permission>();
queryWrapper.eq("type", Constast.TYPE_MENU);
//查询出所有的权限,存放进list中
List<Permission> list = permissionService.list(queryWrapper);
List<TreeNode> treeNodes = new ArrayList<TreeNode>();
//将权限放入treeNodes中,组装成json
for (Permission permission : list) {
Boolean open = permission.getOpen()==1?true:false;
treeNodes.add(new TreeNode(permission.getId(),permission.getPid(),permission.getTitle(),open));
}
userService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/**
* 根据用户ID查询当前用户是否是其他用户的直属领导
* @param userId
* @return
*/
@RequestMapping("queryMgrByUserId")
public ResultObj queryMgrByUserId(Integer userId){
Boolean isMgr = userService.queryMgrByUserId(userId);
if (isMgr){
return ResultObj.DELETE_ERROR_NEWS;
}else {
return ResultObj.DELETE_QUERY;
}
}
/**
* 重置用户密码
* @param id
* @return
*/
@RequestMapping("resetPwd/{id}")
public ResultObj resetPwd(@PathVariable("id") Integer id){
try {
User user = new User();
user.setId(id);
//设置盐 32位(大写英文字母(A-Z)加数字(0-9))
String salt = IdUtil.simpleUUID().toUpperCase();
user.setSalt(salt);
//设置密码
user.setPwd(new Md5Hash(Constast.USER_DEFAULT_PWD,salt,2).toString());
userService.updateById(user);
return ResultObj.RESET_SUCCESS;
} catch (Exception e) {
User user = new User();
user.setId(id);
//设置盐 32位(大写英文字母(A-Z)加数字(0-9))
String salt = IdUtil.simpleUUID().toUpperCase();
user.setSalt(salt);
//设置密码
user.setPwd(new Md5Hash(Constast.USER_DEFAULT_PWD,salt,2).toString());
userService.updateById(user);
return ResultObj.RESET_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.RESET_ERROR;
}
}
/**
* 根据用户id查询角色并选中已拥有的角色
* @param id 用户id
* @return
*/
@RequestMapping("initRoleByUserId")
public DataGridView initRoleByUserId(Integer id){
//1.查询所有可用的角色
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
List<Map<String, Object>> listMaps = roleService.listMaps(queryWrapper);
//2.查询当前用户拥有的角色ID集合
List<Integer> currentUserRoleIds = roleService.queryUserRoleIdsByUid(id);
for (Map<String, Object> map : listMaps) {
Boolean LAY_CHECKED=false;
Integer roleId = (Integer) map.get("id");
for (Integer rid : currentUserRoleIds) {
//如果当前用户已有该角色,则让LAY_CHECKED为true。LAY_CHECKED为true时,复选框选中
if (rid.equals(roleId)){
LAY_CHECKED=true;
break;
}
}
map.put("LAY_CHECKED",LAY_CHECKED);
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/outport")
public class OutportController {
@Autowired
private IOutportService outportService;
@Autowired
private IProviderService providerService;
@Autowired
private IGoodsService goodsService;
/**
* 添加退货信息
* @param id 进货单ID
* @param number 退货数量
* @param remark 备注
* @return
*/
@RequestMapping("addOutport")
public ResultObj addOutport(Integer id,Integer number,String remark){
try {
outportService.addOutport(id,number,remark);
return ResultObj.BACKINPORT_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.BACKINPORT_ERROR;
}
}
/**t
* 查询商品退货
* @param outportVo
* @return
*/
@RequestMapping("loadAllOutport")
public DataGridView loadAllOuport(OutportVo outportVo){
return "system/loginfo/loginfoManager";
}
/**
* 跳转到公告管理
* @return
*/
@RequestMapping("toNoticeManager")
public String toNoticeManager(){
return "system/notice/noticeManager";
}
/**
* 跳转到部门管理
* @return
*/
@RequestMapping("toDeptManager")
public String toDeptManager(){
return "system/dept/deptManager";
}
/**
* 跳转到部门管理--left
* @return
*/
@RequestMapping("toDeptLeft")
public String toDeptLeft(){
return "system/dept/deptLeft";
}
/**
* 跳转到部门管理--right
* @return
*/
@RequestMapping("toDeptRight")
public String toDeptRight(){
return "system/dept/deptRight";
}
/**
* 跳转到菜单管理
* @return
*/
@RequestMapping("toMenuManager")
public String toMenuManager(){
return "system/menu/menuManager";
}
/**
//设置商品名称
ouport.setGoodsname(goods.getGoodsname());
//设置商品规格
ouport.setSize(goods.getSize());
}
}
return new DataGridView(page1.getTotal(),page1.getRecords());
}
/**
* 删除退货信息
* @param id
* @return
*/
@RequestMapping("deleteOutport")
public ResultObj deleteOutport(Integer id){
try {
outportService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RequestMapping("deleteSales")
public ResultObj deleteSales(Integer id){
try {
salesService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("notice")
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("notice")
public class NoticeController {
@Autowired
private INoticeService noticeService;
/**
* 公告的查询
* @param noticeVo
* @return
*/
@RequestMapping("loadAllNotice")
public DataGridView loadAllNotice(NoticeVo noticeVo){
IPage<Notice> page = new Page<Notice>(noticeVo.getPage(),noticeVo.getLimit());
QueryWrapper<Notice> queryWrapper = new QueryWrapper<Notice>();
//进行模糊查询
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
/**
* 修改公告
* @param noticeVo
* @return
*/
@RequestMapping("updateNotice")
public ResultObj updateNotice(NoticeVo noticeVo){
try {
noticeService.updateById(noticeVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/**
* 删除公告
* @param noticeVo
* @return
*/
@RequestMapping("deleteNotice")
public ResultObj deleteNotice(NoticeVo noticeVo){
try {
noticeService.removeById(noticeVo);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/**
* 批量删除公告
* @param noticeVo
* @return
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/sales")
public class SalesController {
@Autowired
private ISalesService salesService;
@Autowired
private ICustomerService customerService;
@Autowired
private IGoodsService goodsService;
/**
* 查询所有商品销售信息
* @param salesVo
* @param permissionVo
* @return
*/
@RequestMapping("deletePermission")
public ResultObj deletePermission(PermissionVo permissionVo){
try {
permissionService.removeById(permissionVo.getId());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/dept")
try {
outportService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/provider")
/**
* <p>
* InnoDB free: 9216 kB 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/provider")
public class ProviderController {
@Autowired
private IProviderService providerService;
/**
* 查询所有的供应商
* @param providerVo
* @return
*/
@RequestMapping("loadAllProvider")
public DataGridView loadAllProvider(ProviderVo providerVo){
//1.声明一个分页page对象
IPage<Provider> page = new Page(providerVo.getPage(),providerVo.getLimit());
//2.声明一个queryWrapper
QueryWrapper<Provider> queryWrapper = new QueryWrapper();
queryWrapper.like(StringUtils.isNotBlank(providerVo.getProvidername()),"providername",providerVo.getProvidername());
queryWrapper.like(StringUtils.isNotBlank(providerVo.getConnectionperson()),"connectionperson",providerVo.getConnectionperson());
queryWrapper.like(StringUtils.isNotBlank(providerVo.getPhone()),"phone",providerVo.getPhone());
providerService.page(page,queryWrapper);
return new DataGridView(page.getTotal(),page.getRecords());
}
/**
* 添加一个供应商
* @param providerVo
* @return
*/
@RequestMapping("addProvider")
public ResultObj addProvider(ProviderVo providerVo){
try {
providerService.save(providerVo);
return ResultObj.ADD_SUCCESS;
*/
@RequestMapping("updateMenu")
public ResultObj updateMenu(PermissionVo permissionVo){
try {
permissionService.updateById(permissionVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/**
* 检查当前菜单是否有子菜单
* @param permissionVo
* @return
*/
@RequestMapping("checkMenuHasChildrenNode")
public Map<String,Object> checkMenuHasChildrenNode(PermissionVo permissionVo){
Map<String,Object> map = new HashMap<String, Object>();
QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pid",permissionVo.getId());
List<Permission> list = permissionService.list(queryWrapper);
if (list.size()>0){
map.put("value",true);
}else {
map.put("value",false);
}
return map;
}
/**
* 删除菜单
* @param permissionVo
* @return
*/
@RequestMapping("deleteMenu")
public ResultObj deleteMenu(PermissionVo permissionVo){
try {
permissionService.removeById(permissionVo.getId());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
private IPermissionService permissionService;
@Autowired
private IUserService userService;
@Autowired
private IRoleService roleService;
@RequestMapping("loadIndexLeftMenuJson")
public DataGridView loadIndexLeftMenuJson(PermissionVo permissionVo){
//查询所有菜单
QueryWrapper<Permission> queryWrapper = new QueryWrapper<Permission>();
//设置查询条件
//查询的必须是菜单,不能是crud的权限
queryWrapper.eq("type",Constast.TYPE_MENU);
//菜单必须可用
queryWrapper.eq("available", Constast.AVAILABLE_TRUE);
//获得用户 判断用户的类型
User user = (User) WebUtils.getSession().getAttribute("user");
List<Permission> list = null;
if (user.getType().equals(Constast.USER_TYPE_SUPER)){
//用户类型为超级管理员
list = permissionService.list(queryWrapper);
}else {
//用户类型为 普通用户
//根据用户ID+角色+权限去查询
Integer userId = user.getId();
//1.根据用户ID查询角色
List<Integer> currentUserRoleIds = roleService.queryUserRoleIdsByUid(userId);
//2.根据角色ID查询菜单ID和权限ID
//使用set去重
Set<Integer> pids = new HashSet<>();
for (Integer rid : currentUserRoleIds) {
//根据角色ID查询菜单ID和权限ID
List<Integer> permissionIds = roleService.queryRolePermissionIdsByRid(rid);
//将菜单ID和权限ID放入Set中去重
pids.addAll(permissionIds);
}
//3.根据角色ID查询权限
if (pids.size()>0){
queryWrapper.in("id",pids);
list = permissionService.list(queryWrapper);
}else {
list=new ArrayList<>();
}
}
List<TreeNode> treeNodes = new ArrayList<TreeNode>();
for (Permission p : list) {
Integer id =p.getId();
Integer pid = p.getPid();
String title = p.getTitle();
/**
* 查询所有用户
* @param userVo
* @return
*/
@RequestMapping("loadAllUser")
public DataGridView loadAllUser(UserVo userVo){
IPage<User> page = new Page<User>(userVo.getPage(),userVo.getLimit());
QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
//根据用户登录名称以及用户名称模糊查询用户
queryWrapper.like(StringUtils.isNotBlank(userVo.getName()),"loginname",userVo.getName()).or().eq(StringUtils.isNotBlank(userVo.getName()),"name",userVo.getName());
queryWrapper.like(StringUtils.isNotBlank(userVo.getAddress()),"address",userVo.getAddress());
//查询系统用户
queryWrapper.eq("type", Constast.USER_TYPE_NORMAL);
queryWrapper.eq(userVo.getDeptid()!=null,"deptid",userVo.getDeptid());
queryWrapper.orderByDesc("id");
userService.page(page,queryWrapper);
//将所有用户数据放入list中
List<User> list = page.getRecords();
for (User user : list) {
Integer deptId = user.getDeptid();
if (deptId!=null){
//先从缓存中去取,如果缓存中没有就去数据库中取
Dept one = deptService.getById(deptId);
//设置user的部门名称
user.setDeptname(one.getName());
}
Integer mgr = user.getMgr();
if (mgr!=null&&mgr!=0){
User one = userService.getById(mgr);
//设置user的领导名称
user.setLeadername(one.getName());
}
}
return new DataGridView(page.getTotal(),list);
}
/**
* 加载排序码
* @return
*/
@RequestMapping("loadUserMaxOrderNum")
public Map<String,Object> loadUserMaxOrderNum(){
* @param permissionVo
* @return
*/
@RequestMapping("loadMenuManagerLeftTreeJson")
public DataGridView loadMenuManagerLeftTreeJson(PermissionVo permissionVo){
QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type",Constast.TYPE_MENU);
//查询出所有的菜单,存放进list中
List<Permission> list = permissionService.list(queryWrapper);
List<TreeNode> treeNodes = new ArrayList<>();
//将菜单放入treeNodes中,组装成json
for (Permission menu : list) {
Boolean open = menu.getOpen()==1?true:false;
treeNodes.add(new TreeNode(menu.getId(),menu.getPid(),menu.getTitle(),open));
}
return new DataGridView(treeNodes);
}
/**
* 查询所有菜单数据
* @param permissionVo
* @return
*/
@RequestMapping("loadAllMenu")
public DataGridView loadAllMenu(PermissionVo permissionVo){
IPage<Permission> page = new Page<>(permissionVo.getPage(),permissionVo.getLimit());
//进行模糊查询
QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(permissionVo.getId()!=null,"id",permissionVo.getId()).or().eq(permissionVo.getId()!=null,"pid",permissionVo.getId());
//只能查询菜单
queryWrapper.eq("type",Constast.TYPE_MENU);
queryWrapper.like(StringUtils.isNotBlank(permissionVo.getTitle()),"title",permissionVo.getTitle());
queryWrapper.orderByAsc("ordernum");
//进行查询
permissionService.page(page,queryWrapper);
//返回DataGridView
return new DataGridView(page.getTotal(),page.getRecords());
}
/**
* 添加菜单
* @param permissionVo
* @return
*/
@RequestMapping("addMenu")
public ResultObj addMenu(PermissionVo permissionVo){
try {
//设置添加类型为 menu
permissionVo.setType(Constast.TYPE_MENU);
permissionService.save(permissionVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {