基于Spring Boot+Vue的超市管理系统

目录

功能描述

系统设计

功能展示

实现代码

为什么选择我?

项目推荐

获取源码


结尾名片获取源码

开发语言:Java

框架:SpringBoot

持久化框架:Mybatis-plus

JDK版本:JDK1.8

服务器:tomcat7\8\9

数据库:mysql 5.7以上

数据库工具:Navicat11以上

开发软件:eclipse/myeclipse/idea

Maven:Maven3.5.4

浏览器:谷歌浏览器\Edge

功能描述

近年来,人们的生活方式以网络为主题不断进化,超市管理就是其中的一部分。现在,无论是大型的还是小型的网站,都随处可见,不知不觉中已经成为我们生活中不可或缺的存在。随着社会的发展,除了对系统的需求外,我们还要促进经济发展,提高工作效率同时还要做好对商品信息、商品进货、商品出库等管理,网络广泛化的运用使信息技术快速发展。在保证高效率的基础上,要保证员工便捷在线查询商品信息、商品进货[1]前,由代码编程实现的各种管理工具和系统替代传统的人工操作,不但提升了可靠性还降低了人力成本,节省了时间,提升了工作效率。全球视域下信息技术逐步渗透到各个领域,多样化的数据信息为超市管理带来了深刻变革。电子商务是新时代发展的一种产品,它是一种被广泛接受的、顺应时代潮流的新型管理模式。它有助于改变现状,提高工作效率,加强专业化、信息化、规范化管理,在这个阶段,超市管理系统提高整体工作效率的一种方式,它是超市经济的基础。

系统设计

为了更好的去理清本系统整体思路,对该系统以结构图的形式表达出来,设计实现该超市管理系统的功能结构图如下所示:

 

功能展示

管理员通过登录页面填写用户名和密码,选择角色完成后进行登录,如图5-1所示。

 管理员登录进入超市管理系统的实现可以查看首页、个人中心、员工管理、商品类型管理、商品信息管理、商品进货管理、商品出库管理、商品销量管理、销售退回管理等信息,如图5-2所示。

 管理员点击员工管理;在员工管理页面对员工工号、员工姓名、性别、岗位、年龄、入职时间、联系方式、邮箱、身份证信息,进行查询,新增或删除员工信息操作如图5-3所示。

 管理员点击商品信息管理;在商品信息管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、过期时间、产地、生产日期、进货时间信息,进行查询,新增或删除商品信息操作如图5-4所示。

 管理员点击商品进货管理;在商品进货管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、进货价、产地、生产日期、过期时间、入库时间、员工工号、员工姓名信息,进行查询或删除商品进货操作如图5-5所示。

 管理员点击商品出库管理;在商品出库管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、产地、生产日期、过期时间、出库时间、员工工号、员工姓名信息,进行查询或删除商品出库操作如图5-6所示。

 管理员点击商品销量管理;在商品销量管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、合计、产地、生产日期、过期时间、销售时间、员工工号、员工姓名信息,进行查询或删除商品销量操作如图5-7所示。

 登录界面首先双击打开系统,连上网络之后会显示出本系统的登录界面,这是进入系统的第初始页面“登录”,能成功进入到该登录界面则代表系统的开启是成功的,接下来就可以操作本系统所带有的其他所有的功能如图5-8所示。

 员工登录系统后,可以对首页、个人中心、商品信息管理、商品进货管理、商品出库管理、商品销量管理、销售退回管理等功能进行相应操作,如图5-9所示。

 员工点击商品信息管理;在商品信息管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、过期时间、产地、生产日期、进货时间信息,进行查询商品信息操作如图5-10所示。

 员工点击商品出库管理;在商品出库管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、产地、生产日期、过期时间、出库时间、员工工号、员工姓名信息,进行查询或删除商品出库操作如图5-11所示。

 员工点击商品销量管理;在商品销量管理页面对商品编号、商品名称、商品类型、图片、数量、零售价格、合计、产地、生产日期、过期时间、销售时间、员工工号、员工姓名信息,进行查询或者删除商品销量操作如图5-12所示。

 

实现代码

Controller层


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

Dao层


package com.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.entity.UserEntity;

/**
 * 用户
 */
public interface UserDao extends BaseMapper<UserEntity> {
	
	List<UserEntity> selectListView(@Param("ew") Wrapper<UserEntity> wrapper);

	List<UserEntity> selectListView(Pagination page,@Param("ew") Wrapper<UserEntity> wrapper);
	
}

Server层


package com.service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.IService;
import com.entity.UserEntity;
import com.utils.PageUtils;


/**
 * 系统用户
 */
public interface UserService extends IService<UserEntity> {
 	PageUtils queryPage(Map<String, Object> params);
    
   	List<UserEntity> selectListView(Wrapper<UserEntity> wrapper);
   	
   	PageUtils queryPage(Map<String, Object> params,Wrapper<UserEntity> wrapper);
	   	
}

package com.service.impl;


import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dao.UserDao;
import com.entity.UserEntity;
import com.service.UserService;
import com.utils.PageUtils;
import com.utils.Query;


/**
 * 系统用户
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

	@Override
	public PageUtils queryPage(Map<String, Object> params) {
		Page<UserEntity> page = this.selectPage(
                new Query<UserEntity>(params).getPage(),
                new EntityWrapper<UserEntity>()
        );
        return new PageUtils(page);
	}

	@Override
	public List<UserEntity> selectListView(Wrapper<UserEntity> wrapper) {
		return baseMapper.selectListView(wrapper);
	}

	@Override
	public PageUtils queryPage(Map<String, Object> params,
			Wrapper<UserEntity> wrapper) {
		 Page<UserEntity> page =new Query<UserEntity>(params).getPage();
	        page.setRecords(baseMapper.selectListView(page,wrapper));
	    	PageUtils pageUtil = new PageUtils(page);
	    	return pageUtil;
	}
}

权限验证

package com.interceptor;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import com.annotation.IgnoreAuth;
import com.entity.EIException;
import com.entity.TokenEntity;
import com.service.TokenService;
import com.utils.R;

/**
 * 权限(Token)验证
 */
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {

    public static final String LOGIN_TOKEN_KEY = "Token";

    @Autowired
    private TokenService tokenService;
    
	@Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        //支持跨域请求
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));

        IgnoreAuth annotation;
        if (handler instanceof HandlerMethod) {
            annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);
        } else {
            return true;
        }

        //从header中获取token
        String token = request.getHeader(LOGIN_TOKEN_KEY);
        
        /**
         * 不需要验证权限的方法直接放过
         */
        if(annotation!=null) {
        	return true;
        }
        
        TokenEntity tokenEntity = null;
        if(StringUtils.isNotBlank(token)) {
        	tokenEntity = tokenService.getTokenEntity(token);
        }
        
        if(tokenEntity != null) {
        	request.getSession().setAttribute("userId", tokenEntity.getUserid());
        	request.getSession().setAttribute("role", tokenEntity.getRole());
        	request.getSession().setAttribute("tableName", tokenEntity.getTablename());
        	request.getSession().setAttribute("username", tokenEntity.getUsername());
        	return true;
        }
        
		PrintWriter writer = null;
		response.setCharacterEncoding("UTF-8");
		response.setContentType("application/json; charset=utf-8");
		try {
		    writer = response.getWriter();
		    writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));
		} finally {
		    if(writer != null){
		        writer.close();
		    }
		}
//				throw new EIException("请先登录", 401);
		return false;
    }
}

为什么选择我?

选择我作为您的毕业设计系统开发伙伴,是基于以下几个关键理由:

  1. 专业经验:我拥有丰富的软件开发经验,特别是在教育技术和信息系统方面。我了解毕业设计流程的复杂性,能够针对性地提供解决方案,确保系统的实用性和高效性。

  2. 定制化服务:我明白每个教育机构都有其独特的需求和挑战。我将与您紧密合作,深入了解您的具体要求,从而开发出完全符合您需求的定制化系统。

  3. 技术专长:我对最新的编程语言和开发工具有深入的了解,能够运用先进的技术来构建安全、稳定且易于维护的系统。无论是前端用户体验还是后端数据处理,我都能够提供专业的技术支持。

  4. 项目管理能力:我具备良好的项目管理技能,能够确保项目按时按质完成。我会制定详细的项目计划,并与您保持密切沟通,确保项目的每个阶段都能满足预期目标。

  5. 持续支持与维护:系统开发完成后,我将提供持续的技术支持和维护服务。这包括定期的系统更新、故障排除以及根据用户反馈进行的功能改进。

  6. 成本效益:我提供的是高性价比的服务。通过高效的项目管理和合理的资源配置,我能够在保证质量的前提下,为您节省不必要的开支。

综上所述,我的专业技能、定制化服务、技术专长、项目管理能力以及对客户的长期承诺,都是您选择我作为毕业设计系统开发伙伴的有力理由。

项目推荐

👇题目未定的小伙伴可以看看下面找找灵感👇

Java Spring Boot框架合集

Java 微信小程序(UNIAPP、云原生)合集

Java Android合集

Java SSM框架合集

Python Djaogo框架合集

获取源码

大家点赞、关注加收藏!👇下方名片获取源码啦!👇

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值