Project introduction

The project is divided into three roles: players, merchants and administrators, including store management, event management, registration management and users and other core modules. There are three roles: ordinary players, merchants and administrators:

1. Player Roles:

Enter the small program, screen to view the activities suitable for participation, select the activity registration, the system according to the registration user’s “reputation” automatically judge the success of registration, after the end of the game can participate in the same game players for evaluation, evaluation is good or bad to determine the player’s reputation.

2. Merchant role:

Create game activities and submit them for review. After passing the review, wait for players to sign up and launch the game.

3. Administrator role:

Review game activities submitted by merchants and manage merchant accounts

Development environment:

  1. jdk 8
  2. intellij idea
  3. Tomcat 8.5.40
  4. Mysql 5.7
  5. Wechat developer tools

Backend technology:

  1. springboot2.1
  2. quartz
  3. thymeleaf
  4. Alibaba, a connection pool
  5. swagger
  6. mybatis

The difficulty thinking

  1. Different menus are displayed for different roles

You can customize the bottom navigation bar to display different tabbars for different identities. After login, different navigation bars are displayed based on the role type

  1. Activity status is associated with registration status

Add a scheduled task and change the activity status according to the set activity time. At the same time, query the registration records bound to the activity and modify the corresponding status

  1. Credit value filtering

Set the initial reputation value, modify the reputation value according to the evaluation, the number of registrants exceeds the number of activities, screen players with high reputation value to start the game, players with low reputation value automatically out

Project screenshots

  • Home page

  • Player-activity list

  • Player – My activity

  • Players – Event details

  • Player – Rating

  • Player – Personal center

  • Shopkeepers – Create activities

  • Shopkeepers – Event management

  • Shop owner – Personal center

  • Administrator – Activity audit

  • Administrator – Account management

  • Administrator – Create shop

  • Swagger interface

Database Configuration

spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver druid: url: jdbc:mysql://localhost:3306/board_game? useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: root123Copy the code

The template configuration

spring:
  thymeleaf:
    mode: HTML
    encoding: utf-8
 
Copy the code

Core business code

  1. Activity module
@APIOperation (value = "New activity ",response = ajaxresult.class) @postMapping ("/add") public AjaxResult addSave(ActivityAddReq) activityReq) { Store store=storeService.selectStoreByUserId(activityReq.getBoosId()); If (store==null){return ajaxresult. error(" store does not exist "); } Activity activity=new Activity(); BeanUtils.copyProperties(activityReq,activity); activity.setStatus(-1); Activity.setcityid (store.getCityId())); Activity.setaddress (store.getAddress())); SetBoosId (activityreq.getBoosid ())); return toAjax(activityService.insertActivity(activity)); } @apiOperation (value = "audit activity ",response = ajaxresult.class) @postMapping ("/audit") public AjaxResult audit(ActivityAuditReq req) { Activity activity=new Activity(); activity.setId(req.getId()); activity.setStatus(req.getStatus()); / / set the audit state return toAjax (activityService updateActivity (activity)); }Copy the code
  1. Activity Registration Module
@apiOperation (value = "activity registration ",response = ajaxresult.class) @postMapping ("/sign") public AjaxResult sign(SignUpReq signUpReq) { Activity activity= activityService.selectActivityById(signUpReq.getActivityId()); If (activity==null){return ajaxresult. error(" Activity does not exist "); }else if(! Activity.getstatus ().equals(0)){return ajaxResult.error (" Activity is abnormal "); } SignUp search=new SignUp(); search.setUserId(signUpReq.getUserId()); search.setActivityId(signUpReq.getActivityId()); List<SignUp> list=signUpService.selectSignUpList(search); If (list.size()>0){return ajaxresult.error); } SignUp signUp=new SignUp(); BeanUtils.copyProperties(signUpReq,signUp); signUp.setAddTime(DateUtils.getTime()); signUp.setStatus(0); signUpService.insertSignUp(signUp); activity.setsNum(activity.getsNum()+1); return toAjax(activityService.updateActivity(activity)); } @apiOperation (value = "cancel registration ",response = ajaxresult.class) @postMapping ("/cancelSign") public AjaxResult cancelSign(SignUpReq signUpReq) { Activity activity= activityService.selectActivityById(signUpReq.getActivityId()); If (activity==null){return ajaxresult. error(" Activity does not exist "); } SignUp search=new SignUp(); search.setUserId(signUpReq.getUserId()); search.setActivityId(signUpReq.getActivityId()); List<SignUp> list=signUpService.selectSignUpList(search); If (list.size()==0){return ajaxresult.error (" you did not register this activity, cancel this activity "); } SignUp signUp=list.get(0); signUp.setStatus(3); signUpService.updateSignUpByAId(signUp); activity.setsNum(activity.getsNum()-1); return toAjax(activityService.updateActivity(activity)); }Copy the code
  1. The user’s credit value is calculated after the activity
@apiOperation (value = "end of activity - player comment ",response = activityvo.class) @postmapping ("/playComment") public AjaxResult playComment(CommentReq req) { try{ GameUser gameUser=gameUserService.selectGameUserById(req.getUserId()); If (gameUser==null){return ajaxresult. error(" comment failed, comment does not exist "); } gameUser=gameUserService.selectGameUserById(req.getCommentId()); If (gameUser==null){return ajaxresult. error(" comment failed, comment did not exist "); } ActivityComment activityComment=new ActivityComment(); activityComment.setUserId(req.getUserId()); activityComment.setActivityId(req.getActivityId()); activityComment.setCommentId(req.getCommentId()); List<ActivityComment> list=activityCommentService.selectActivityCommentList(activityComment); If (list.size()>0){return ajaxresult. error(" error "); } BeanUtils.copyProperties(req,activityComment); activityComment.setCalculate(1); / / set to not calculated activityCommentService. InsertActivityComment (activityComment); // Add comment record // deduct points rule: A player who is negatively evaluated by >=1 player in a game will lose points, 5 points for being late, 10 points for missing, Int reputationValue= gameuser.getreputation (); int reputationValue= gameUser.getreputation (); If (req.getBelate()==1){reputationValue=reputationValue-5; }else{ reputationValue=reputationValue+5; If (req.getabsent ()==1){reputationValue=reputationValue-10; }else{ reputationValue=reputationValue+10; If (req.getabSent ()==1){reputationValue=reputationValue-2; }else{ reputationValue=reputationValue+2; If (req.getabsent ()==1){reputationValue=reputationValue-1; }else{ reputationValue=reputationValue+1; } gameUser.setReputation(reputationValue); / / final update by critics XinYuZhi gameUserService. UpdateGameUser (gameUser); Return ajaxresult. success(" evaluate success "); }catch (Exception e){ e.printStackTrace(); Return ajaxresult. error(" evaluation failed, system exception "); }}Copy the code
  1. At the same time, users with high credit value are screened into the office activities
public void activityTask() { List<Activity> list = activityService.getListByNoEnd(); if (list.size() > 0) { for (Activity activity : list) { String startTime = activity.getStartTime(); // Start time String endTime = activity.getendTime (); If (activity.getStatus() == 0) {// Unstarted activity if (dateutils.isgreater (startTime) &&! Dateutils.isgreater (endTime)) {if(activity.getsnum ()>=activity.getpNum()){activity.setStatus(1); / / set has begun activityService. UpdateActivity (activity); / / screen XinYuZhi higher players List < SignUp > signUps. = signUpService getSignUpListByAId (activity. The getId ()); for(int i=0; i<signUps.size(); i++){ SignUp signUp=signUps.get(i); if(i<activity.getpNum()){ signUp.setStatus(1); SignUp. SetRemark (" registration is successful "); }else{ signUp.setStatus(3); Signup.setremark (" credit value lower than other registered players, out "); / / todo can send a message to push} signUpService. UpdateSignUp (signUp); } }else{ activity.setStatus(2); // Set 2 to end activity.setRemark(" Automatically end the activity if the number of participants does not meet the number of participants "); activityService.updateActivity(activity); SignUp =new SignUp(); SignUp =new SignUp(); signUp.setActivityId(activity.getId()); signUp.setStatus(3); SignUp. SetRemark (" If the number of participants does not meet the requirements of the number of participants, the activity will be automatically terminated "); signUpService.updateSignUpByAId(signUp); }} else if (activity.getStatus() == 1) {// Start the activity if (dateutils.isgreater (endTime)) {activity.setStatus(2); / / set is over activityService. UpdateActivity (activity); SignUp signUp=new SignUp(); signUp.setActivityId(activity.getId()); signUp.setStatus(2); SignUp. SetRemark (" Activity time has expired, activity is ended "); signUpService.updateStatusByAcIng(signUp); } } } } }Copy the code

Project follow-up

Other SSH, SSM version of subsequent iterations update, continue to pay attention to