基于javaweb+mysql的springboot游戏虚拟交易系统(java+springboot+mybatis+jquery+html+jsp+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot游戏虚拟交易系统(java+springboot+mybatis+jquery+html+jsp+mysql)
项目介绍
基于SpringBoot 网络游戏虚拟交易系统 有前台和后台
用户:
登录、注册、首页、公告信息、游戏资讯、商品信息、交流论坛、商品信息、购物车、立即购买、星级好评,文字评论
管理员:
登录、验证,轮播图管理、公告信息管理、资源管理、商城管理(分类管理、商品信息管理、订单管理)、系统用户、模块管理
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 4.数据库:MySql 5.7/8.0版本均可; 5.是否Maven项目:是;
技术栈
后端:SpringBoot(Spring+SpringMVC+Mybatis)
前端: JSP+HTML+Layui+thymeleaf+CSS+Javascript+JQUERY
使用说明
项目运行: 1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
*前端传入页码、分页数量
*前端传入商品信息状态码(commstatus)-->全部:100,违规:0,已审核:1,待审核:3 已完成:4
* 因为是管理员查询,将userid设置为空
*/
@GetMapping("/admin/commodity/{commstatus}")
@ResponseBody
public LayuiPageVo userCommodity(@PathVariable("commstatus") Integer commstatus, int limit, int page) {
if(commstatus==100){
List<Commodity> commodityList = commodityService.queryAllCommodity((page - 1) * limit, limit, null, null);
Integer dataNumber = commodityService.queryCommodityCount(null, null);
return new LayuiPageVo("",0,dataNumber,commodityList);
*/
//执行定时任务
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
phonecodemap1.remove(mobilephone);
((ScheduledThreadPoolExecutor) executorService).remove(this::run);
},1 * 10 * 1000,1 * 10 * 1000, TimeUnit.HOURS);
return new ResultVo(true,StatusCode.SMS,"验证码发送成功");
if(result == 1) {//发送成功
phonecodemap.put(mobilephone, code);//放入map集合进行对比
/*
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
phonecodemap2.remove(phoneNum);
timer.cancel();
}, 5 * 60 * 1000);
*/
//执行定时任务
* 4.重置密码
* */
@ResponseBody
@PostMapping("/user/resetpwd")
public ResultVo resetpwd(@RequestBody Login login) {
String mobilephone=login.getMobilephone();
String password=login.getPassword();
String vercode=login.getVercode();
Login login1 = new Login();
UserInfo userInfo = new UserInfo();
if (!JustPhone.justPhone(mobilephone)) {//判断输入的手机号格式是否正确
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
public class CommodityController {
@Autowired
private CommodityService commodityService;
@Autowired
private CommimagesService commimagesService;
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private SoldrecordService soldrecordService;
@Autowired
private CollectService collectService;
@Override
public void run() {
phonecodemap2.remove(mobilephone);
((ScheduledThreadPoolExecutor) executorService).remove(this::run);
},5 * 60 * 1000,5 * 60 * 1000, TimeUnit.HOURS);
return new ResultVo(true,StatusCode.SMS,"验证码发送成功");
}else if(result == 2){
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
return new ResultVo(false,StatusCode.REMOTEERROR,"验证码发送失败");
/**重置密码
* 1.判断手机号格式是否正确
@PostMapping("/relgoods/video")
@ResponseBody
public JSONObject relgoodsvideo(@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
JSONObject res = new JSONObject();
JSONObject resUrl = new JSONObject();
String filename = UUID.randomUUID().toString().replaceAll("-", "");
String ext = FilenameUtils.getExtension(file.getOriginalFilename());
String filenames = filename + "." + ext;
String pathname = "D:/file/" + filenames;
file.transferTo(new File(pathname));
resUrl.put("src", "/pic/"+filenames);
res.put("msg", "");
res.put("code", 0);
if (!StringUtils.isEmpty(username)){
login.setUsername(username);
Login login1 = loginService.userLogin(login);
//如果用户名未修改
if (sessionname.equals(username)){
UserInfo userInfo2 = userInfoService.LookUserinfo(login1.getUserid());
if (userInfo.getUsername().equals(userInfo2.getUsername())
&& userInfo.getEmail().equals(userInfo2.getEmail())
&& userInfo.getSex().equals(userInfo2.getSex())
&& userInfo.getServer().equals(userInfo2.getServer())
){
return new ResultVo(false, StatusCode.ERROR, "1.尚未修改信息");
} else {
if (integer==1 && integer1==1){
return new ResultVo(true,StatusCode.OK,"重置密码成功");
return new ResultVo(false,StatusCode.ERROR,"重置密码失败");
return new ResultVo(false,StatusCode.ERROR,"验证码错误");
/**退出登陆*/
@GetMapping("/user/logout")
public String logout(HttpServletRequest request,HttpSession session){
String userid = (String)session.getAttribute("userid");
String username = (String)session.getAttribute("username");
if(StringUtils.isEmpty(userid) && StringUtils.isEmpty(username)){
return "redirect:/";
request.getSession().removeAttribute("userid");
request.getSession().removeAttribute("username");
&& userInfo.getSex().equals(userInfo2.getSex())
&& userInfo.getServer().equals(userInfo2.getServer())
){
return new ResultVo(false, StatusCode.ERROR, "1.尚未修改信息");
} else {
//如果用户名已存在
if (!StringUtils.isEmpty(login1)) {
return new ResultVo(false, StatusCode.ERROR, "2.用户名已存在");
login.setUserid(userid);
//修改登录表中用户名
loginService.updateLogin(login);
userInfo.setUserid(userid);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "解封成功");
return new ResultVo(true, StatusCode.ERROR, "解封失败");
return new ResultVo(false,StatusCode.ACCESSERROR,"违规操作");
/**
* 管理员商品列表
* */
@GetMapping("/admin/product")
public String adminproduct(){
return "/admin/product/productlist";
/**
/**发出设置为管理员的系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("系统通知")
.setWhys("恭喜您已被设置为网站管理员,努力维护网站的良好氛围。");
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "设置管理员成功");
return new ResultVo(true, StatusCode.ERROR, "设置管理员失败");
}else if (roleid == 1){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setRoleid(roleid));
if (i == 1){
userRoleService.UpdateUserRole(new UserRole().setUserid(userid).setRoleid(1).setIdentity("网站用户"));
/**发出设置为网站用户的系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("系统通知")
String userid = (String) session.getAttribute("userid");
//如果未登录,给一个假id
if(StringUtils.isEmpty(userid)){
userid = "123456";
List<Commodity> commodityList=null;
Integer dataNumber;
if(commstatus==100){
commodityList = commodityService.queryAllCommodity((page - 1) * limit, limit, userid,null);
dataNumber = commodityService.queryCommodityCount(userid,null);
}else{
commodityList = commodityService.queryAllCommodity((page - 1) * limit, limit, userid,commstatus);
if (rel.equalsIgnoreCase(vercode)) {//验证码正确
Login login = new Login().setUserid(userid).setMobilephone(mobilephone);
UserInfo userInfo = new UserInfo().setUserid(userid).setMobilephone(mobilephone);
Integer integer = loginService.updateLogin(login);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
if (integer == 1 && integer1 == 1) {
return new ResultVo(true, StatusCode.OK, "更换手机号成功");
return new ResultVo(false, StatusCode.SERVERERROR, "系统错误,更换失败");
return new ResultVo(false,StatusCode.ERROR,"验证码错误");
管理员管理控制层:
/**
* @Description: 管理员控制器
*/
@Controller
Login userIsExist = loginService.userLogin(login);
if (StringUtils.isEmpty(userIsExist)){//用户账号不存在
return new ResultVo(false, StatusCode.LOGINERROR,"该用户不存在");
String code = GetCode.phonecode();
Integer result = new SmsUtil().SendMsg(mobilephone, code, type);//发送验证码
if(result == 1) {//发送成功
phonecodemap2.put(mobilephone, code);//放入map集合进行对比
//执行定时任务
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
executorService.scheduleAtFixedRate(new Runnable() {
@Override
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
phonecodemap.remove(mobilephone);
((ScheduledThreadPoolExecutor) executorService).remove(this::run);
},5 * 60 * 1000,5 * 60 * 1000, TimeUnit.HOURS);
return new ResultVo(true,StatusCode.SMS,"验证码发送成功");
}else if(result == 2){
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
return new ResultVo(false,StatusCode.REMOTEERROR,"验证码发送失败");
@ResponseBody
@GetMapping("/notices/cancelLatest")
public ResultVo CancelLatest (HttpSession session){
String userid = (String) session.getAttribute("userid");
Integer i = noticesService.CancelLatest(userid);
if (i == 1){
return new ResultVo(true,StatusCode.OK,"设置成功");
return new ResultVo(true,StatusCode.ERROR,"设置失败");
/**
* 分类分页查询用户所有通知消息
* 1.前端传入消息通知类型(tpname)
* 2.session中获取用户id(userid)
* 3.返回分页数据