基于javaweb+mysql的ssm游戏装备系统(java+ssm+jsp+bootstrap+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM游戏装备系统(java+ssm+jsp+bootstrap+mysql)
项目介绍
本项目为前后台项目,前台为普通用户登录,后台为管理员登录; 管理员角色包含以下功能: 管理员登录,装备分类管理,装备管理、分类管理、属性管理,用户管理,订单管理等功能。
用户角色包含以下功能: 查看首页,查看装备详情,用户登录,查看购物车,提交订单,查看我的订单等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是; 6.数据库:MySql 5.7等版本均可;
技术栈
- 后端:Spring+springmvc+mybatis 2. 前端:JSP+CSS+JavaScript+jQuery+Bootstrap
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ssm_hzp_site/ 登录 注:Tomcat中配置项目路径必须为ssm_hzp_site 用户账号/密码: user/123456 管理员账号/密码:admin/admin
},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.判断手机号格式是否正确
* 2.查询手机号是否存在
* 3.判断验证码是否有效或正确
* 4.重置密码
* */
@ResponseBody
* 4.发送验证码
* */
@ResponseBody
@PostMapping("/user/sendresetpwd")
public ResultVo sendresetpwd(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!=1){
return new ResultVo(false,StatusCode.ACCESSERROR,"违规操作");
* 2.判断手机号格式是否正确
* 3.查询账号是否存在
* 4.发送验证码
* */
@ResponseBody
@PostMapping("/user/sendresetpwd")
public ResultVo sendresetpwd(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!=1){
if (i ==1 && j == 1){
/**发出封号的系统通知*/
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 (userstatus == 1){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setUserstatus(userstatus));
Integer j = userInfoService.UpdateUserInfo(new UserInfo().setUserid(userid).setUserstatus(userstatus));
if (i ==1 && j == 1){
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,"请输入正确格式的手机号");
//查询手机号是否存在
login.setMobilephone(mobilephone);
Login userIsExist = loginService.userLogin(login);
if (!StringUtils.isEmpty(userIsExist)){//若手机号已注册过
&& 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);
token = new UsernamePasswordToken(username, new Md5Hash(password,"Game-shops").toString());
// System.out.println("1password : "+new Md5Hash(password,"Game-shops").toString());
}else {
//输入的是手机号
String mobilephone = account;
login.setMobilephone(mobilephone);
//将封装的login中username变为null
login.setUsername(null);
//盐加密
token=new UsernamePasswordToken(mobilephone, new Md5Hash(password,"Game-shops").toString());
System.out.println("2password :"+ token);
* 3.判断更改的用户名是否已存在
* 4.修改个人信息
*/
@ResponseBody
@PostMapping("/user/updateinfo")
public ResultVo updateInfo(@RequestBody UserInfo userInfo, HttpSession session) {
String username = userInfo.getUsername();
String sessionname = (String) session.getAttribute("username");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
//如果传入用户名不为空
if (!StringUtils.isEmpty(username)){
login.setUsername(username);
//判断输入的账号是否手机号
if (!JustPhone.justPhone(account)) {
//输入的是用户名
String username = account;
//盐加密
token=new UsernamePasswordToken(username, new Md5Hash(password,"Game-shops").toString());
}else {
//输入的是手机号
String mobilephone = account;
login.setMobilephone(mobilephone);
//将封装的login中username变为null
login.setUsername(null);
登录管理控制层:
/**
* 登录注册 控制器
*/
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private UserRoleService userRoleService;
/**手机号和注册验证码map集合*/
private static Map<String, String> phonecodemap1 = new HashMap<>();
public ResultVo adminuserlist(@PathVariable("userid") String userid,@PathVariable("userstatus") Integer userstatus) {
if (userstatus == 0){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setUserstatus(userstatus));
Integer j = userInfoService.UpdateUserInfo(new UserInfo().setUserid(userid).setUserstatus(userstatus));
if (i ==1 && j == 1){
/**发出封号的系统通知*/
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 (userstatus == 1){
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);
*/
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,"验证码错误");
/**退出登陆*/
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";
/**
* 1.前端传入旧密码(oldpwd)、新密码(newpwd)
* 2.判断输入旧密码和系统旧密码是否相等
* 4.修改密码
*/
@ResponseBody
@PutMapping("/user/updatepwd")
public ResultVo updatepwd(HttpSession session, HttpServletRequest request) throws IOException {
JSONObject json = JsonReader.receivePost(request);
String oldpwd = json.getString("oldpwd");
String newpwd = json.getString("newpwd");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
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);
if (integer == 1 && integer1 == 1) {
return new ResultVo(true, StatusCode.OK, "更换手机号成功");
return new ResultVo(false, StatusCode.SERVERERROR, "系统错误,更换失败");
JSONObject jsonObject = JsonReader.receivePost(request);
final String mobilephone = jsonObject.getString("mobilephone");
Integer type = jsonObject.getInt("type");
Login login = new Login();
if(type!=0){
return new ResultVo(false,StatusCode.ACCESSERROR,"违规操作");
if (!JustPhone.justPhone(mobilephone)) {//判断输入的手机号格式是否正确
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
//查询手机号是否已经注册
login.setMobilephone(mobilephone);
Login userIsExist = loginService.userLogin(login);
if (!StringUtils.isEmpty(userIsExist)){//用户账号已经存在
* */
@ResponseBody
@PostMapping("/user/register")
public ResultVo userReg(@RequestBody UserInfo userInfo, HttpSession session) {
String username = userInfo.getUsername();
String password = userInfo.getPassword();
String mobilephone = userInfo.getMobilephone();
String vercode = userInfo.getVercode();
Login login = new Login().setMobilephone(mobilephone);
//查询账号是否已经注册
Login userIsExist = loginService.userLogin(login);
if (!StringUtils.isEmpty(userIsExist)){//用户账号已经存在
return new ResultVo(false, StatusCode.ERROR,"该用户已经注册过了");