一、前言
随着信息时代的来临,过去的传统管理方式缺点逐渐暴露,对过去的传统管理方式的缺点进行分析,采取计算机方式构建玩具销售系统。本文通过课题背景、课题目的及意义相关技术,提出了一种玩具信息、购买订单、退货申请、换货申请、反馈信息、生产信息等于一体的系统构建方案。
本文通过采用B/S架构,MySQL数据库以及java语言、springboot框架,结合国内线上管理现状,开发了一个基于springboot的玩具销售系统。系统分为多个功能模块:买家、厂商、玩具分类、玩具信息、购买订单、退货申请、换货申请、反馈信息、生产信息、批发订单等。通过系统测试,本系统实现了系统设计目标,相对于人工管理方式,本系统有效的减少了商家的经济投入,并且大幅度提升了玩具销售管理的效率。
二、开发环境
开发语言:Java
框架:springboot
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
三、系统功能设计
玩具销售系统主要有管理员和买家、厂商,三个功能模块:管理员模块、买家、厂商模块。以下将对这三个功能的作用进行详细的剖析[11]。
管理员模块:管理员在系统中的是核心用户,管理员登录后,可以对后台系统进行管理。主要功能有:系统首页、个人中心、买家管理、厂商管理、玩具分类管理、玩具信息管理、购买订单管理、退货申请管理、换货申请管理、反馈信息管理、生产信息管理、批发订单管理、系统管理等功能。
买家:买家进入系统可以对系统首页、个人中心、购买订单管理、退货申请管理、换货申请管理、反馈信息管理等进行操作。
厂商:厂商进入系统可以对系统首页、个人中心、玩具信息管理、购买订单管理、退货申请管理、换货申请管理、反馈信息管理、生产信息管理、批发订单管理等进行操作。
构图是系统的体系结构,体系结构是体系结构体系的一部分,体系结构体系是体系结构体系的重要组成部分。
四、系统数据库设计
在一个资料模式中,一个被称作“实例”的实体,与真实的“事件”或者“物体”相匹配,可以与其它物体区分开来。例如,公司中的每个员工,家里中的每个家具。
五、系统效果
六、核心代码
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 org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.http.HttpStatus;
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"));
// 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态
if (request.getMethod().equals(RequestMethod.OPTIONS.name())) {
response.setStatus(HttpStatus.OK.value());
return false;
}
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;
}
}
```java
package com.service;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.IService;
import com.utils.PageUtils;
import com.entity.GoumaidingdanEntity;
import java.util.List;
import java.util.Map;
import com.entity.vo.GoumaidingdanVO;
import org.apache.ibatis.annotations.Param;
import com.entity.view.GoumaidingdanView;
/**
* 购买订单
*
* @author
* @email
* @date 2023-02-18 15:49:16
*/
public interface GoumaidingdanService extends IService<GoumaidingdanEntity> {
PageUtils queryPage(Map<String, Object> params);
List<GoumaidingdanVO> selectListVO(Wrapper<GoumaidingdanEntity> wrapper);
GoumaidingdanVO selectVO(@Param("ew") Wrapper<GoumaidingdanEntity> wrapper);
List<GoumaidingdanView> selectListView(Wrapper<GoumaidingdanEntity> wrapper);
GoumaidingdanView selectView(@Param("ew") Wrapper<GoumaidingdanEntity> wrapper);
PageUtils queryPage(Map<String, Object> params,Wrapper<GoumaidingdanEntity> wrapper);
}