基于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配置文件中的数据库配置改为自己的配置;
//盐加密
String passwords = new Md5Hash(password, "Game-shops").toString();
String userid = KeyUtil.genUniqueKey();
login.setId(KeyUtil.genUniqueKey()).setUserid(userid).setMobilephone(mobilephone).setPassword(passwords);
Integer integer = loginService.loginAdd(login);
//新注册用户存入默认头像、存入默认签名
userInfo.setUserid(userid).setPassword(passwords).setUimage("/pic/d1d66c3ea71044a9b938b00859ca94df.jpg").
setSign("如此清秋何吝酒,这般明月不须钱").setStatus("offline");
Integer integer1 = userInfoService.userReg(userInfo);
if (integer==1 && integer1==1){
/**注册成功后存入session*/
session.setAttribute("userid",userid);
* 个人中心 控制器
* </p>
*/
@Controller
public class UserController {
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
/**手机号和更换手机号验证码map集合*/
private static Map<String, String> phonecodemap = new HashMap<>();
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid2).setTpname("购买")
.setWhys("您的商品 <a href=/product-detail/"+commid+" style=\"color:#08bf91\" target=\"_blank\" >"+commodity.getCommname()+"</a> 被购买了,快去看看吧。");
noticesService.insertNotices(notices);
return new ResultVo(true,StatusCode.OK,"操作成功");
return new ResultVo(false,StatusCode.ERROR,"操作失败");
登录管理控制层:
/**
* <p>
* 登录注册 控制器
* </p>
Collections.sort(commodityList, new Comparator<Commodity>() {//此处创建了一个匿名内部类
int i;
@Override
public int compare(Commodity o1, Commodity o2) {
if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) > -1) {
System.out.println("===o1大于等于o2===");
i = -1;
} else if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) < 1) {
System.out.println("===o1小于等于o2===");
i = 1;
return i;
});
/**降序*/
Collections.sort(commodityList, new Comparator<Commodity>() {//此处创建了一个匿名内部类
int i;
@Override
public int compare(Commodity o1, Commodity o2) {
if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) > -1) {
System.out.println("===o1大于等于o2===");
i = -1;
} else if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) < 1) {
System.out.println("===o1小于等于o2===");
i = 1;
@ResponseBody
@PostMapping("/user/sendupdatephone")
public ResultVo sendupdatephone(HttpServletRequest request) throws IOException {
JSONObject json = JsonReader.receivePost(request);
final String mobilephone = json.getString("mobilephone");
Integer type = json.getInt("type");
Login login = new Login();
if(type!=2){
return new ResultVo(false,StatusCode.ACCESSERROR,"违规操作");
if (!JustPhone.justPhone(mobilephone)) {//判断输入的手机号格式是否正确
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
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);
res.put("data", resUrl);
String uimgUrl = "/pic/" + filenames;
String userid=(String) session.getAttribute("userid");
/**
* 查询最新发布的8条商品
* */
@ResponseBody
@GetMapping("/product/latest")
public ResultVo latestCommodity() {
String category = "全部";
List<Commodity> commodityList = commodityService.queryCommodityByCategory(category);
for (Commodity commodity : commodityList) {
/**查询商品对应的其它图片*/
List<String> imagesList = commimagesService.LookGoodImages(commodity.getCommid());
commodity.setOtherimg(imagesList);
@Autowired
private UserInfoService userInfoService;
@Autowired
private CommodityService commodityService;
@Autowired
private NoticesService noticesService;
/**
* 管理员跳转登录
*/
@GetMapping("/admin")
public String admintologin() {
return "admin/login/login";
List<String> imagesList = commimagesService.LookGoodImages(commodity.getCommid());
commodity.setOtherimg(imagesList);
/**自定义排序*/
if (price != 0){
if (price == 1){
/**升序*/
Collections.sort(commodityList, new Comparator<Commodity>() {//此处创建了一个匿名内部类
int i;
@Override
public int compare(Commodity o1, Commodity o2) {
if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) > -1) {
System.out.println("===o1大于等于o2===");
/**
* 取消新通知标志
* 用户点击查看最新通知后会将所有通知设置为非最新通知
* */
@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,"设置成功");
@PutMapping("/user/updatephone/{mobilephone}/{vercode}")
public ResultVo updatephone(@PathVariable("mobilephone")String mobilephone,@PathVariable("vercode")String vercode,HttpSession session) {
String userid = (String) session.getAttribute("userid");
String rel = phonecodemap.get(mobilephone);
if (StringUtils.isEmpty(rel)) {//验证码到期 或者 没发送短信验证码
return new ResultVo(false,StatusCode.ERROR,"请重新获取验证码");
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);
}, 5 * 60 * 1000);
*/
//执行定时任务
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,"验证码发送成功");
}else if(result == 2){
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
//盐加密
String passwords = new Md5Hash(password, "Game-shops").toString();
login1.setPassword(passwords).setId(userIsExist.getId()).setMobilephone(null);
userInfo.setMobilephone(mobilephone).setPassword(passwords).setUserid(userIsExist.getUserid());
Integer integer = loginService.updateLogin(login1);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
if (integer==1 && integer1==1){
return new ResultVo(true,StatusCode.OK,"重置密码成功");
return new ResultVo(false,StatusCode.ERROR,"重置密码失败");
return new ResultVo(false,StatusCode.ERROR,"验证码错误");
/**退出登陆*/
public String perfectInfo(HttpSession session, ModelMap modelMap) {
String userid = (String) session.getAttribute("userid");
UserInfo userInfo = userInfoService.LookUserinfo(userid);
modelMap.put("perfectInfo",userInfo);
return "/user/perfectinfo";
/**
* 修改个人信息
* 1.前端传入用户昵称(username)、用户邮箱(email)、性别(sex)、游戏(server
* 2.前端传入变更后的字段,未变更的不传入后台
* 3.判断更改的用户名是否已存在
for (Commodity commodity : commodityList) {
/**查询商品对应的其它图片*/
List<String> imagesList = commimagesService.LookGoodImages(commodity.getCommid());
commodity.setOtherimg(imagesList);
return new ResultVo(true,StatusCode.OK,"查询成功",commodityList);
/**
* 产品清单分页数据
* 前端传入商品类别(category)、区域(area)
* 最低价(minmoney)、最高价(maxmoney)
* 后端根据session查出个人本校信息(server)
* */
@GetMapping("/list-number/{category}/{area}/{minmoney}/{maxmoney}")
商品信息管理控制层:
/**
* <p>
* 前端控制器
* </p>
*/
@Controller
public class CommodityController {
@Autowired
private CommodityService commodityService;
@Autowired
public JSONObject updateuimg(@RequestParam(value = "file", required = false) MultipartFile file, HttpSession session) 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);
res.put("data", resUrl);