• Java项目:ssm赛事打分系统


    作者主页:源码空间站2022

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    赛事评分系统,SSM框架。该项目分管理员、裁判、选手三个用户角色。

    管理员主要功能:
    首页、选手管理、裁判管理、赛事管理
    裁判主要功能:
    首页、评分;
    选手主要功能:
    首页、报名赛事、查看成绩;

    环境需要

    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项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 
    6.数据库:MySql 5.7版本;
    7.lombok插件 注:必须安装,否则会报错

    技术栈

    1. 后端:Spring SpringMVC MyBatis
    2. 前端:Layui

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 将项目中database.properties配置文件中的数据库配置改为自己的配置;
    3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
    4. 运行项目,输入localhost:8080/xxx 登录

    运行截图

    相关代码 

    JudgeController

    1. package com.thunder.controller;
    2. import com.alibaba.fastjson.JSONObject;
    3. import com.thunder.pojo.Judge;
    4. import com.thunder.pojo.Mark;
    5. import com.thunder.pojo.Match;
    6. import com.thunder.pojo.User;
    7. import com.thunder.service.impl.JudgeServiceImpl;
    8. import com.thunder.service.impl.LoginServiceImpl;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import org.springframework.web.bind.annotation.RequestParam;
    13. import org.springframework.web.bind.annotation.ResponseBody;
    14. import java.util.Date;
    15. import java.util.Map;
    16. @Controller
    17. @RequestMapping("/judge")
    18. public class JudgeController {
    19. @Autowired
    20. JudgeServiceImpl judgeService;
    21. @Autowired
    22. LoginServiceImpl loginService;
    23. /**
    24. * 跳转 裁判页面
    25. */
    26. @RequestMapping("/toJudgePage")
    27. public String toJudgePage() {
    28. return "/pages/judge";
    29. }
    30. /**
    31. * 跳转 评分
    32. */
    33. @RequestMapping("/toMark")
    34. public String toMark() {
    35. return "/pages/judgeMarkPlayer";
    36. }
    37. /**
    38. * 获取所有裁判
    39. */
    40. @RequestMapping(value = "/getAllJudge", produces = "application/json;charset=UTF-8")
    41. @ResponseBody
    42. public String getAllJudge() {
    43. //阿里巴巴的json数据格式交互
    44. JSONObject object = new JSONObject();
    45. object.put("code", 200);//原来是 code : 0
    46. object.put("msg", "");
    47. object.put("data", judgeService.getAllJudge());
    48. object.put("count", judgeService.getAllJudge().size());
    49. System.out.println("数据库数据:" + judgeService.getAllJudge().toString());
    50. return object.toJSONString();
    51. }
    52. /**
    53. * 根异步请求 删除裁判
    54. */
    55. @RequestMapping("/deleteJudgeById")
    56. @ResponseBody
    57. public String deleteJudgeById(@RequestParam Map map) {
    58. String currentJudge = (String) map.get("index");
    59. int result = judgeService.deleteJudgeById(currentJudge);
    60. if (result > 0) {
    61. return "1";
    62. } else {
    63. return "error";
    64. }
    65. }
    66. //添加 裁判
    67. @RequestMapping("/addJudgeAjax")
    68. @ResponseBody
    69. public String addJudgeAjax(@RequestParam Map map) {
    70. System.out.println(map);
    71. String jid = (String) map.get("jid");
    72. String jname = (String) map.get("jname");
    73. String jage = (String) map.get("jage");
    74. String jsex = (String) map.get("jsex");
    75. System.out.println(jid + " " + jname + " " + jage + " " + jsex);
    76. //判断裁判、选手 写入 user表
    77. if (jid.contains("P")) {
    78. System.out.println("注册选手");
    79. int registerPlayer = loginService.addUser(new User(jid, password));
    80. if (registerPlayer > 0) {
    81. System.out.println("注册选手成功!");
    82. }
    83. } else if (jid.contains("J")) {
    84. System.out.println("注册裁判");
    85. int registerPlayer = loginService.addUser(new User(jid, password));
    86. if (registerPlayer > 0) {
    87. System.out.println("注册裁判成功!");
    88. }
    89. } else if (jid.equals("admin")) {
    90. System.out.println("管理员");
    91. } else {
    92. }
    93. //添加 裁判
    94. int result = judgeService.addJudgeAjax(new Judge(jid, jname, jage, jsex));
    95. if (result > 0) {
    96. return "1";
    97. } else {
    98. return "error";
    99. }
    100. }
    101. //裁判打分
    102. @RequestMapping("/mark")
    103. @ResponseBody
    104. public String mark(@RequestParam Map map) {
    105. System.out.println("进入 后台 ==== 打分");
    106. String pid = (String) map.get("pid");
    107. String item = (String) map.get("mid");
    108. String jid = (String) map.get("jid");
    109. String score = (String) map.get("score");
    110. System.out.println("分数是:" + score + item + jid + pid);
    111. int result = judgeService.mark(new Mark(score, item, jid, pid));
    112. if (result > 0) {
    113. return "1";
    114. } else {
    115. return "error";
    116. }
    117. }
    118. }

    LoginController

    1. package com.thunder.controller;
    2. import com.thunder.pojo.User;
    3. import com.thunder.service.impl.JudgeServiceImpl;
    4. import com.thunder.service.impl.LoginServiceImpl;
    5. import com.thunder.service.impl.PlayServiceImpl;
    6. import com.thunder.util.CurrentUser;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.RequestParam;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import javax.servlet.http.HttpServlet;
    13. import javax.servlet.http.HttpSession;
    14. import java.util.Map;
    15. @Controller
    16. public class LoginController {
    17. @Autowired
    18. LoginServiceImpl loginService;
    19. @Autowired
    20. JudgeServiceImpl judgeService;
    21. @Autowired
    22. PlayServiceImpl playService;
    23. /**
    24. * 登录验证
    25. */
    26. @RequestMapping(value = "/login", produces = "application/json;charset=UTF-8")
    27. @ResponseBody
    28. public String Login(@RequestParam Map user, HttpSession session) {
    29. String account = (String) user.get("account");
    30. String password = (String) user.get("password");
    31. if (account.contains("P")) {
    32. System.out.println("选手登录");
    33. if (LoginRoute(account, password, session).equals("1")) {
    34. return "选手登录";
    35. } else {
    36. return "error";
    37. }
    38. } else if (account.contains("J")) {
    39. System.out.println("裁判登录");
    40. if (LoginRoute(account, password, session).equals("1")) {
    41. return "裁判登录";
    42. } else {
    43. return "error";
    44. }
    45. } else if (account.equals("admin")) {
    46. System.out.println("管理员登录");
    47. if (LoginRoute(account, password, session).equals("1")) {
    48. return "admin";
    49. } else {
    50. return "error";
    51. }
    52. } else {
    53. return "error";
    54. }
    55. }
    56. //判断用户
    57. public String LoginRoute(String account, String password, HttpSession session) {
    58. User loginUser = loginService.getUser(account);
    59. if (loginUser != null) {
    60. if (!loginUser.getPwd().equals(password)) {
    61. return "error";
    62. } else {
    63. session.setAttribute(CurrentUser.CURRENT_USER, loginUser);
    64. System.out.println("session放入" + loginUser.getAccount());
    65. return "1";
    66. }
    67. } else {
    68. return "error";
    69. }
    70. }
    71. /**
    72. * 注册用户
    73. */
    74. @RequestMapping("/register")
    75. @ResponseBody
    76. public String Register(@RequestParam Map user) {
    77. String loginuser = (String) user.get("user");
    78. String password = (String) user.get("pwd");
    79. System.out.println(user.get("user"));
    80. System.out.println(user.get("pwd"));
    81. User newUser = new User((String) user.get("user"), (String) user.get("pwd"));
    82. int result = loginService.addUser(newUser);
    83. //添加成功 返回 大于0
    84. if (result > 0) {
    85. return "1";
    86. } else {
    87. return "error";
    88. }
    89. }
    90. /**
    91. * 判断 注册用户 是否存在数据库中 ajax
    92. */
    93. @RequestMapping("/registerAccount")
    94. @ResponseBody
    95. public String registerAccount(@RequestParam Map user) {
    96. System.out.println("当前新增用户:" + user.get("user"));
    97. String newUser = (String) user.get("user");
    98. User userNewUser = loginService.getUser(newUser);
    99. if (userNewUser != null) {
    100. return "error";
    101. } else {
    102. return "1";
    103. }
    104. }
    105. /**
    106. * 去往主页面
    107. */
    108. @RequestMapping("/toMain")
    109. public String toMain() {
    110. return "pages/main";
    111. }
    112. /**
    113. * 退出登录
    114. */
    115. @RequestMapping("/exitLogin")
    116. public String exitLogin(HttpSession session) {
    117. session.removeAttribute(CurrentUser.CURRENT_USER);
    118. //session.invalidate();
    119. if (session == null) {
    120. System.out.println("当前用户:" + session.getAttribute(CurrentUser.CURRENT_USER));
    121. return "redirect:/login.jsp";
    122. } else {
    123. System.out.println("当前用户:" + session.getAttribute(CurrentUser.CURRENT_USER));
    124. return "redirect:/login.jsp";
    125. }
    126. }
    127. }

    MatchController

    1. package com.thunder.controller;
    2. import cn.hutool.core.date.DateTime;
    3. import cn.hutool.core.date.DateUtil;
    4. import com.alibaba.fastjson.JSON;
    5. import com.alibaba.fastjson.JSONArray;
    6. import com.alibaba.fastjson.JSONObject;
    7. import com.thunder.pojo.Match;
    8. import com.thunder.pojo.SignUp;
    9. import com.thunder.service.impl.MatchServiceImpl;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Controller;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.RequestParam;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import java.util.List;
    16. import java.util.Map;
    17. @Controller
    18. @RequestMapping("/match")
    19. public class MatchController {
    20. @Autowired
    21. MatchServiceImpl matchService;
    22. /**
    23. * 跳转到 赛事界面
    24. */
    25. @RequestMapping("/toMatchPage")
    26. public String toMatchPage() {
    27. return "/pages/match";
    28. }
    29. /**
    30. * 获取所有赛事 admin页面展示
    31. */
    32. @RequestMapping(value = "/getAllMatch", produces = "application/json;charset=UTF-8")
    33. @ResponseBody
    34. public String getAllMatch() {
    35. //阿里巴巴的json数据格式交互
    36. JSONObject object = new JSONObject();
    37. object.put("code", 200);//原来是 code : 0
    38. object.put("msg", "");
    39. object.put("data", matchService.getAllMatch());
    40. object.put("count", matchService.getAllMatch().size());
    41. System.out.println("数据库数据:" + matchService.getAllMatch().toString());
    42. return object.toJSONString();
    43. }
    44. /**
    45. * 获取赛事 ajax 下拉列表
    46. */
    47. @RequestMapping(value = "/getAllMatchAjax", produces = "application/json;charset=UTF-8")
    48. @ResponseBody
    49. public String getAllMatchAjax() {
    50. List allMatch = matchService.getAllMatch();
    51. JSONArray array = JSONArray.parseArray(JSON.toJSONString(allMatch));
    52. System.out.println(array.toJSONString());
    53. return array.toJSONString();
    54. }
    55. /**
    56. * 删除操作 异步请求
    57. */
    58. @RequestMapping("/deleteMatchById")
    59. @ResponseBody
    60. public String deleteMatchById(@RequestParam Map map) {
    61. int currentMatchId = Integer.parseInt((String) map.get("index"));
    62. int result = matchService.deleteMatchById(currentMatchId);
    63. if (result > 0) {
    64. return "1";
    65. } else {
    66. return "error";
    67. }
    68. }
    69. /**
    70. * 添加赛事
    71. */
    72. @RequestMapping(value = "/addMatchAjax", produces = "application/json;charset=UTF-8")
    73. @ResponseBody
    74. public String addMatchAjax(@RequestParam Map map) {
    75. //System.out.println(map);
    76. String mid = (String) map.get("mid");
    77. String mname = (String) map.get("mname");
    78. String mtime = (String) map.get("mtime");
    79. DateTime parseDate = DateUtil.parse(mtime, "yyyy-MM-dd");
    80. java.sql.Date mtimeDate = new java.sql.Date(parseDate.getTime());
    81. System.out.println("类型" + mtimeDate.getClass().getName());
    82. System.out.println("mid=" + mid + "mname=" + mname + "mtime=" + mtimeDate);
    83. int result = matchService.addMatchAjax(new Match(mid, mname, mtimeDate));
    84. if (result > 0) {
    85. return "1";
    86. } else {
    87. return "error";
    88. }
    89. }
    90. //选手报名赛事
    91. @RequestMapping(value = "/signInMatch", produces = "application/json;charset=UTF-8")
    92. @ResponseBody
    93. public String signInMatch(@RequestParam Map map) {
    94. System.out.println(map);
    95. String pid = (String) map.get("pid");
    96. String saishi = (String) map.get("saishi");
    97. String properties = (String) map.get("properties");
    98. System.out.println("pid " + pid + " saishi:" + saishi + "性质:" + properties);
    99. int result = matchService.signInMatch(new SignUp(pid, saishi, properties));
    100. if (result > 0) {
    101. return "1";
    102. } else {
    103. return "error";
    104. }
    105. }
    106. /***
    107. *查看已报名
    108. */
    109. @RequestMapping(value = "/alreadySignIn", produces = "application/json;charset=UTF-8")
    110. @ResponseBody
    111. public String alreadySignIn(@RequestParam Map map) {
    112. JSONObject object = new JSONObject();
    113. String pid = (String) map.get("pid");
    114. System.out.println("选手:" + pid + "选择的赛事");
    115. List signUpList = matchService.alreadySignIn(pid);
    116. object.put("code", 200);//原来是 code : 0
    117. object.put("msg", "");
    118. object.put("data", signUpList);
    119. object.put("count", signUpList.size());
    120. System.out.println("已报名:" + signUpList);
    121. return object.toJSONString();
    122. }
    123. }

    如果也想学习本系统,下面领取。关注并回复:034ssm 

  • 相关阅读:
    【C++编程能力提升】
    将string类对象中的内容格式化到字符串Buffer中时遇到的异常崩溃分析
    算法----组合总和(Kotlin)-面试真题
    【机器学习】特征工程:特征选择、数据降维、PCA
    安全运营和应急响应详解
    【VUE】process.env,require,vite.config.js等问题的解决
    Nginx之负载均衡upstream模块简介和使用
    Android 13 新特性及适配指南
    基于 QUIC 协议的 HTTP/3 正式发布!
    关于<? extends Class>和<T extends Class>的区别
  • 原文地址:https://blog.csdn.net/m0_74967853/article/details/128156291