作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、多年校企合作经验,被多个学校常年聘为校外企业导师,指导学生毕业设计并参与学生毕业答辩指导,有较为丰富的相关经验。期待与各位高校教师、企业讲师以及同行交流合作
主要内容:Java项目、Python项目、前端项目、PHP、ASP.NET、人工智能与大数据、单片机开发、物联网设计与开发设计、简历模板、学习资料、面试题库、技术互助、就业指导等
业务范围:免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写、论文编写和辅导、论文降重、长期答辩答疑辅导、腾讯会议一对一专业讲解辅导答辩、模拟答辩演练、和理解代码逻辑思路等。
收藏点赞不迷路 关注作者有好处
文末获取源码
项目编号:BS-XX-317
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
开发技术:SpringBoot+Vue
二,项目简介
随着互联网趋势的到来,在不少95后00后的眼里,“剧本杀”已经成为“Z世代”们交友聚会的新潮流。当前,年轻人休闲娱乐较为依赖线上的形式,而剧本杀也打开了线上社交市场,加上用户付费意愿较高,市场发展前景可期。因此在现实运用中,应用软件的工作规则和开发步骤,采用Java技术建设剧本杀服务平台。
本设计主要实现集人性化、高效率、便捷等优点于一身的剧本杀服务平台,完成公告消息管理、剧本资讯、、系统用户、优质店铺、剧本信息、购买信息、剧本拼团、玩家拼团、剧本拼团信息、玩家拼团信息等功能模块。系统通过浏览器与服务器进行通信,实现数据的交互与变更。只需通过一台电脑,动动手指就可以操作系统,实现数据通信管理。整个系统的设计过程都充分考虑了数据的安全、稳定及可靠等问题,而且操作过程简单。本系统通过科学的管理方式、便捷的服务提高了工作效率,减少了数据存储上的错误和遗漏。
剧本杀服务平台使用Java语言,采用基于B/S架构的SpringBoot技术进行开发,使用 MyEclipse编译器编写,数据方面主要采用的是MySQL关系型数据库来作为数据存储媒介,配合MyBatis、Redis等技术完成系统的开发。
三,系统展示
四,核心代码展示
package com.project.demo.controller;import com.alibaba.fastjson.JSONObject;
import com.project.demo.entity.AccessToken;
import com.project.demo.entity.User;
import com.project.demo.entity.UserGroup;
import com.project.demo.service.AccessTokenService;
import com.project.demo.service.UserGroupService;
import com.project.demo.service.UserService;import com.project.demo.controller.base.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;import javax.persistence.Query;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*;/*** 用户账户:用于保存用户登录信息(User)表控制层*/
@Slf4j
@RestController
@RequestMapping("user")
public class UserController extends BaseController<User, UserService> {/*** 服务对象*/@Autowiredpublic UserController(UserService service) {setService(service);}/*** Token服务*/@Autowiredprivate AccessTokenService tokenService;@Autowiredprivate UserGroupService userGroupService;/*** 注册* @param user* @return*/@PostMapping("register")public Map<String, Object> signUp(@RequestBody User user) {// 查询用户Map<String, String> query = new HashMap<>();query.put("username",user.getUsername());List list = service.select(query, new HashMap<>()).getResultList();if (list.size()>0){return error(30000, "用户已存在");}user.setUserId(null);user.setPassword(service.encryption(user.getPassword()));service.save(user);return success(1);}/*** 找回密码* @param form* @return*/@PostMapping("forget_password")public Map<String, Object> forgetPassword(@RequestBody User form,HttpServletRequest request) {JSONObject ret = new JSONObject();String username = form.getUsername();String code = form.getCode();String password = form.getPassword();// 判断条件if(code == null || code.length() == 0){return error(30000, "验证码不能为空");}if(username == null || username.length() == 0){return error(30000, "用户名不能为空");}if(password == null || password.length() == 0){return error(30000, "密码不能为空");}// 查询用户Map<String, String> query = new HashMap<>();query.put("username",username);Query select = service.select(query, service.readConfig(request));List list = select.getResultList();if (list.size() > 0) {User o = (User) list.get(0);JSONObject query2 = new JSONObject();JSONObject form2 = new JSONObject();// 修改用户密码query2.put("user_id",o.getUserId());form2.put("password",service.encryption(password));service.update(query, service.readConfig(request), form2);return success(1);}return error(70000,"用户不存在");}/*** 登录* @param data* @param httpServletRequest* @return*/@PostMapping("login")public Map<String, Object> login(@RequestBody Map<String, String> data, HttpServletRequest httpServletRequest) {log.info("[执行登录接口]");String username = data.get("username");String email = data.get("email");String phone = data.get("phone");String password = data.get("password");List resultList = null;Map<String, String> map = new HashMap<>();if(username != null && "".equals(username) == false){map.put("username", username);resultList = service.select(map, new HashMap<>()).getResultList();}else if(email != null && "".equals(email) == false){map.put("email", email);resultList = service.select(map, new HashMap<>()).getResultList();}else if(phone != null && "".equals(phone) == false){map.put("phone", phone);resultList = service.select(map, new HashMap<>()).getResultList();}else{return error(30000, "账号或密码不能为空");}if (resultList == null || password == null) {return error(30000, "账号或密码不能为空");}//判断是否有这个用户if (resultList.size()<=0){return error(30000,"用户不存在");}User byUsername = (User) resultList.get(0);Map<String, String> groupMap = new HashMap<>();groupMap.put("name",byUsername.getUserGroup());List groupList = userGroupService.select(groupMap, new HashMap<>()).getResultList();if (groupList.size()<1){return error(30000,"用户组不存在");}UserGroup userGroup = (UserGroup) groupList.get(0);//查询用户审核状态if (!StringUtils.isEmpty(userGroup.getSourceTable())){String sql = "select examine_state from "+ userGroup.getSourceTable() +" WHERE user_id = " + byUsername.getUserId();String res = String.valueOf(service.runCountSql(sql).getSingleResult());if (res==null){return error(30000,"用户不存在");}if (!res.equals("已通过")){return error(30000,"该用户审核未通过");}}//查询用户状态if (byUsername.getState()!=1){return error(30000,"用户非可用状态,不能登录");}String md5password = service.encryption(password);if (byUsername.getPassword().equals(md5password)) {// 存储Token到数据库AccessToken accessToken = new AccessToken();accessToken.setToken(UUID.randomUUID().toString().replaceAll("-", ""));accessToken.setUser_id(byUsername.getUserId());tokenService.save(accessToken);// 返回用户信息JSONObject user = JSONObject.parseObject(JSONObject.toJSONString(byUsername));user.put("token", accessToken.getToken());JSONObject ret = new JSONObject();ret.put("obj",user);return success(ret);} else {return error(30000, "账号或密码不正确");}}/*** 修改密码* @param data* @param request* @return*/@PostMapping("change_password")public Map<String, Object> change_password(@RequestBody Map<String, String> data, HttpServletRequest request){// 根据Token获取UserIdString token = request.getHeader("x-auth-token");Integer userId = tokenGetUserId(token);// 根据UserId和旧密码获取用户Map<String, String> query = new HashMap<>();String o_password = data.get("o_password");query.put("user_id" ,String.valueOf(userId));query.put("password" ,service.encryption(o_password));Query ret = service.count(query, service.readConfig(request));List list = ret.getResultList();Object s = list.get(0);int count = Integer.parseInt(list.get(0).toString());if(count > 0){// 修改密码Map<String,Object> form = new HashMap<>();form.put("password",service.encryption(data.get("password")));service.update(query,service.readConfig(request),form);return success(1);}return error(10000,"密码修改失败!");}/*** 登录态* @param request* @return*/@GetMapping("state")public Map<String, Object> state(HttpServletRequest request) {JSONObject ret = new JSONObject();// 获取状态String token = request.getHeader("x-auth-token");// 根据登录态获取用户IDInteger userId = tokenGetUserId(token);log.info("[返回userId] {}",userId);if(userId == null || userId == 0){return error(10000,"用户未登录!");}// 根据用户ID获取用户Map<String,String> query = new HashMap<>();query.put("user_id" ,String.valueOf(userId));// 根据用户ID获取Query select = service.select(query,service.readConfig(request));List resultList = select.getResultList();if (resultList.size() > 0) {JSONObject user = JSONObject.parseObject(JSONObject.toJSONString(resultList.get(0)));user.put("token",token);ret.put("obj",user);return success(ret);} else {return error(10000,"用户未登录!");}}/*** 登录态* @param request* @return*/@GetMapping("quit")public Map<String, Object> quit(HttpServletRequest request) {String token = request.getHeader("x-auth-token");JSONObject ret = new JSONObject();Map<String, String> query = new HashMap<>(16);query.put("token", token);try{tokenService.delete(query,service.readConfig(request));}catch (Exception e){e.printStackTrace();}return success("退出登录成功!");}/*** 获取登录用户ID* @param token* @return*/public Integer tokenGetUserId(String token) {log.info("[获取的token] {}",token);// 根据登录态获取用户IDif(token == null || "".equals(token)){return 0;}Map<String, String> query = new HashMap<>(16);query.put("token", token);AccessToken byToken = tokenService.findOne(query);if(byToken == null){return 0;}return byToken.getUser_id();}/*** 重写add* @return*/@PostMapping("/add")@Transactionalpublic Map<String, Object> add(HttpServletRequest request) throws IOException {Map<String,Object> map = service.readBody(request.getReader());map.put("password",service.encryption(String.valueOf(map.get("password"))));service.insert(map);return success(1);}}
五,相关作品展示
基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目
基于Nodejs、Vue等前端技术开发的前端实战项目
基于微信小程序和安卓APP应用开发的相关作品
基于51单片机等嵌入式物联网开发应用
基于各类算法实现的AI智能应用
基于大数据实现的各类数据管理和推荐系统