瀏覽代碼

1.添加后台关卡设置,未完成

slambb 4 年之前
父節點
當前提交
2186a6457c

+ 0 - 0
log/error.2021-09-28.log


+ 11 - 0
pom.xml

@@ -24,6 +24,13 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
+        <!--   热更新   -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <optional>true</optional>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-mail</artifactId>
@@ -194,6 +201,10 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <!--  启动修改之后实时生效   -->
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
             </plugin>
         </plugins>
     </build>

+ 85 - 0
src/main/java/com/YuyeTech/TPlat/controller/BackstageLevelController.java

@@ -0,0 +1,85 @@
+package com.YuyeTech.TPlat.controller;
+
+import com.YuyeTech.TPlat.VO.ResultVO;
+import com.YuyeTech.TPlat.dataobject.*;
+import com.YuyeTech.TPlat.dto.LevelConditionDTO;
+import com.YuyeTech.TPlat.dto.LevelHonorDTO;
+import com.YuyeTech.TPlat.enums.ResultEnum;
+import com.YuyeTech.TPlat.exception.UserException;
+import com.YuyeTech.TPlat.service.*;
+import com.YuyeTech.TPlat.utils.RSAUtils;
+import com.YuyeTech.TPlat.utils.ResultVOUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Sort;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+/**
+ * @author:slambb
+ * @date:2021/8/4
+ */
+@RestController
+@RequestMapping("/backstage_level")
+@Slf4j
+public class BackstageLevelController {
+
+    @Autowired
+    private LevelJumpService levelJumpService;
+
+
+
+
+    @Value("${RSA.friendId.publicKey}")
+    private String friendIdPublicKey;
+    @Value("${RSA.friendId.privateKey}")
+    private String friendIdPrivateKey;
+
+    /**
+     * 获取levelJump关卡列表
+     *
+     * @return
+     */
+    @GetMapping("/getLevelJumpList")
+    public ModelAndView getLevelJumpList(
+            @RequestParam(value = "numberType",defaultValue = "1") Integer numberType,
+            Map<String, Object> map) {
+        map.put("list",levelJumpService.findLevelJumpDTOsByNumberType(numberType, Sort.Direction.ASC));
+        return new ModelAndView("/app/level", map);
+    }
+
+    /**
+     * 添加新关卡
+     * @param map
+     * @return
+     */
+    @GetMapping("/add")
+    public ModelAndView addLevel(Map<String, Object> map) {
+
+        LevelJump levelJump = new LevelJump();
+        map.put("levelJump", levelJump);
+
+        //通过关卡条件
+        List<LevelCondition> levelCondition = levelJumpService.findAllLevelCondition();
+        //解锁条件
+        map.put("levelCondition",levelCondition);
+        //通过关卡获得荣誉
+        List<LevelHonor> levelHonor = levelJumpService.findAllLevelHonor();
+        map.put("levelHonor",levelHonor);
+        return new ModelAndView("/app/level-detail", map);
+    }
+
+
+}

+ 6 - 4
src/main/java/com/YuyeTech/TPlat/controller/UserInfoController.java

@@ -650,7 +650,7 @@ public class UserInfoController {
         if (null != signIn) {
             Integer continueDays = signIn.getContinueDays();
             // 判断最后签到日期与当前日期是否超过一天
-            LocalDate signInTime = signIn.getUpdateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate signInTime = signIn.getSettingTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
             LocalDate currTime = LocalDate.now();
             long daysDiff = ChronoUnit.DAYS.between(signInTime, currTime);
             if (daysDiff > 1) {
@@ -660,8 +660,8 @@ public class UserInfoController {
                 signIn.setUpdateTime(new Date());
                 signInService.addSignIn(signIn);
             } else {
-                //如果小于或者等于0,判断为当天为签到
-                if(daysDiff <=0){
+                //如果小于或者等于0,判断为当天为签到. 连续签到时间不为0
+                if(daysDiff <=0 && !signIn.getContinueDays().equals(0)){
                     isSignIn = true;
                 }
 
@@ -727,11 +727,12 @@ public class UserInfoController {
             signIn = new SignIn();
             signIn.setUserId(userId);
             signIn.setContinueDays(1);
+            signIn.setSettingTime(new Date());
             signIn.setUpdateTime(new Date());
             signInService.addSignIn(signIn);
         } else {/*签过到*/
             // 判断最后签到日期与当前日期是否超过一天
-            LocalDate signInTime = signIn.getUpdateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate signInTime = signIn.getSettingTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
             LocalDate currTime = LocalDate.now();
             long daysDiff = ChronoUnit.DAYS.between(signInTime, currTime);
             if (daysDiff <= 0) {
@@ -744,6 +745,7 @@ public class UserInfoController {
                 // 2, 没有超过一天, 把连续签到的天数+1
                 signIn.setContinueDays(signIn.getContinueDays() + 1);
             }
+            signIn.setSettingTime(new Date());
             signIn.setUpdateTime(new Date());
             signInService.addSignIn(signIn);
 

+ 2 - 0
src/main/java/com/YuyeTech/TPlat/dataobject/SignIn.java

@@ -24,5 +24,7 @@ public class SignIn {
 
     private Integer continueDays;
 
+    private Date settingTime;
+
     private Date updateTime;
 }

+ 1 - 0
src/main/java/com/YuyeTech/TPlat/repository/LevelConditionRepository.java

@@ -16,4 +16,5 @@ public interface LevelConditionRepository extends JpaRepository<LevelCondition,I
 
     List<LevelConditionDTO> findByTypeAndLimitTypeIn(Integer type,List<Integer> limitTypes);
 
+
 }

+ 11 - 1
src/main/java/com/YuyeTech/TPlat/service/LevelJumpService.java

@@ -1,7 +1,12 @@
 package com.YuyeTech.TPlat.service;
 
+import com.YuyeTech.TPlat.dataobject.LevelCondition;
+import com.YuyeTech.TPlat.dataobject.LevelHonor;
 import com.YuyeTech.TPlat.dataobject.LevelJump;
+import com.YuyeTech.TPlat.dto.LevelConditionDTO;
+import com.YuyeTech.TPlat.dto.LevelHonorDTO;
 import com.YuyeTech.TPlat.dto.LevelJumpDTO;
+import org.springframework.data.domain.Sort;
 
 import java.util.List;
 import java.util.Map;
@@ -14,9 +19,14 @@ public interface LevelJumpService {
 
     List<LevelJump> findLevelJumpsByNumberType(Integer numberType);
 
-    List<LevelJumpDTO> findLevelJumpDTOsByNumberType(Integer numberType);
+    List<LevelJumpDTO> findLevelJumpDTOsByNumberType(Integer numberType, Sort.Direction direction);
 
     Map  findLevelJumpsAll(String userId);
 
     LevelJump findById(Integer id);
+
+    //查询全部条件,包括解锁和通关
+    List<LevelCondition> findAllLevelCondition();
+    //查询全部荣誉
+    List<LevelHonor> findAllLevelHonor();
 }

+ 18 - 5
src/main/java/com/YuyeTech/TPlat/service/impl/LevelJumpServiceImpl.java

@@ -1,8 +1,8 @@
 package com.YuyeTech.TPlat.service.impl;
 
-import com.YuyeTech.TPlat.dataobject.GameTag;
-import com.YuyeTech.TPlat.dataobject.LevelJump;
-import com.YuyeTech.TPlat.dataobject.UserLevel;
+import com.YuyeTech.TPlat.dataobject.*;
+import com.YuyeTech.TPlat.dto.LevelConditionDTO;
+import com.YuyeTech.TPlat.dto.LevelHonorDTO;
 import com.YuyeTech.TPlat.dto.LevelJumpDTO;
 import com.YuyeTech.TPlat.repository.*;
 import com.YuyeTech.TPlat.service.GameTagService;
@@ -39,9 +39,9 @@ public class LevelJumpServiceImpl implements LevelJumpService {
     }
 
     @Override
-    public List<LevelJumpDTO> findLevelJumpDTOsByNumberType(Integer numberType) {
+    public List<LevelJumpDTO> findLevelJumpDTOsByNumberType(Integer numberType,Sort.Direction direction) {
 
-        List<LevelJump> levelJumpList = levelJumpRepository.findAllByNumberType(numberType, Sort.by(Sort.Direction.DESC,"sort"));
+        List<LevelJump> levelJumpList = levelJumpRepository.findAllByNumberType(numberType, Sort.by(direction,"sort"));
         List<LevelJumpDTO> levelJumpDTOList = levelJumpList.stream().map(
                 e -> new LevelJumpDTO(
                         e.getId(),
@@ -138,4 +138,17 @@ public class LevelJumpServiceImpl implements LevelJumpService {
     public LevelJump findById(Integer id) {
         return levelJumpRepository.findById(id).orElse(null);
     }
+
+
+    @Override
+    public List<LevelCondition> findAllLevelCondition() {
+
+        return levelConditionRepository.findAll();
+    }
+
+    @Override
+    public List<LevelHonor> findAllLevelHonor() {
+
+        return levelHonorRepository.findAll();
+    }
 }

+ 2 - 0
src/main/resources/application.yml

@@ -45,6 +45,8 @@ spring:
             enable: true
             required: true
     port: 465
+  thymeleaf:
+    cache: false
 
 #url 前缀
 server:

+ 169 - 0
src/main/resources/templates/app/level-detail.ftl

@@ -0,0 +1,169 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+
+    <#include "../common/header.ftl">
+    <!-- some CSS styling changes and overrides -->
+    <link rel="stylesheet" href="../main-plugins/bootstrap-multiselect/bootstrap-multiselect.css">
+    <link rel="stylesheet" href="../main-plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css"/>
+
+    <link href="../main-plugins/bootstrap-fileinput/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css">
+
+
+</head>
+
+<body class="font-opensans  sidebar_dark offcanvas-active">
+<!-- Page Loader -->
+<div class="page-loader-wrapper">
+    <div class="loader">
+    </div>
+</div>
+<!-- Start main html -->
+<div id="main_content">
+
+    <#--边栏sidebar-->
+    <#include "../common/iconMenu.ftl">
+    <#--主菜单-->
+    <#include "../common/startMainMenu.ftl">
+    <div class="page">
+
+        <#if levelJump.id??>
+            <#assign title = "修改关卡信息">
+        <#else >
+            <#assign title = "创建新的关卡">
+        </#if>
+
+        <#include "../common/pageTop.ftl">
+
+        <#--主要内容content-->
+        <div class="section-body">
+            <div class="container-fluid">
+                <div class="row clearfix">
+                    <div class="col-md-12">
+                        <div class="card">
+                            <div class="card-body">
+                                <form name="formBasic" id="formBasic" role="form" method="post"
+                                      enctype="multipart/form-data"
+                                      action="">
+                                    <div class="form-group">
+                                        <label>关卡名称</label>
+                                        <input name="levelName" type="text" placeholder="输入关卡名称" class="form-control"
+                                               value="${(levelJump.name)!''}"/>
+                                    </div>
+
+                                    <div class="form-group">
+                                        <label>通过关卡的条件</label>
+                                        <select name="conditionPassed" class="form-control">
+                                            <#list levelCondition as conditionPassed>
+                                                <#if  conditionPassed.type == 1>
+                                                    <option  value="${conditionPassed.id}"
+                                                            <#if (levelJump.conditionPassed)?? && levelJump.conditionPassed == conditionPassed.limitType>
+                                                                selected
+                                                            </#if>
+                                                    >${conditionPassed.explain}
+                                                    </option>
+                                                </#if>
+                                            </#list>
+                                        </select>
+                                    </div>
+                                    <div class="form-group">
+                                        <label>解锁关卡的条件</label>
+                                        <select name="conditionPassed" class="form-control">
+                                            <#list levelCondition as conditionPassed>
+                                                <#if  conditionPassed.type == 0>
+                                                    <option  value="${conditionPassed.id}"
+                                                            <#if (levelJump.conditionPassed)?? && levelJump.conditionPassed == conditionPassed.limitType>
+                                                                selected
+                                                            </#if>
+                                                    >${conditionPassed.explain}
+                                                    </option>
+                                                </#if>
+                                            </#list>
+                                        </select>
+                                    </div>
+                                    <div class="form-group">
+                                        <label>解锁条件(可多选)</label>
+                                        <br/>
+                                        <div class="form-group multiselect_div">
+                                            <select id="multiselect-color2" name="multiselectUnlock" class="multiselect multiselect-custom" multiple="multiple">
+                                                <#list levelHonor as honor>
+                                                    <option value="${honor.name}">${honor.name}
+                                                    </option>
+                                                </#list>
+
+                                            </select>
+                                        </div>
+                                    </div>
+
+                                    <div class="form-group">
+                                        <label>荣誉奖励</label>
+                                        <select name="conditionPassed" class="form-control">
+                                            <#list levelHonor as honor>
+                                                    <option  value="${honor.id}"
+                                                            <#if (levelJump.rewardHonor)?? && levelJump.rewardHonor == honor.type>
+                                                                selected
+                                                            </#if>
+                                                    >${honor.name}
+                                                    </option>
+                                            </#list>
+                                        </select>
+                                    </div>
+
+                                    <div class="form-group">
+                                        <label>关卡简介</label>
+                                        <input name="levelJumpDescribe" type="text" placeholder="输入关卡描述信息" class="form-control"
+                                               value="${(levelJump.describe)!''}"/>
+                                    </div>
+
+                                    <button type="submit" class="btn btn-block btn-primary">
+                                        <#if levelJump.id??>
+                                            提交修改
+                                        <#else >
+                                            创建游戏
+                                        </#if>
+                                    </button>
+
+                                </form>
+
+                            </div>
+
+
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+
+<!-- jQuery and bootstrtap js -->
+<script src="../main-bundles/lib.vendor.bundle.js"></script>
+<!-- start plugin js file  -->
+<script src="../main-plugins/bootstrap-multiselect/bootstrap-multiselect.js"></script>
+<script src="../main-plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
+<script src="../main-plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
+<script src="../main-plugins/multi-select/js/jquery.multi-select.js"></script>
+
+<#--<!-- 主要的 fileinput 插件库 5.1.2-->
+<script src="../main-plugins/bootstrap-fileinput/js/fileinput.min.js"></script>
+<script src="../main-plugins/bootstrap-fileinput/js/locales/zh.js"></script>
+
+<!-- Start core js and page js -->
+<script src="../js/core.js"></script>
+<script src="../js/main/form/form-game-detail.js"></script>
+
+
+<!-- the fileinput plugin initialization -->
+<script>
+    <#if levelJump.id??>
+    $("#formBasic").attr("action", "${req.contextPath}/backstage_level/modify");
+    <#else >
+    $("#formBasic").attr("action", "${req.contextPath}/backstage_level/upload");
+    </#if>
+</script>
+</body>
+</html>

+ 85 - 0
src/main/resources/templates/app/level.ftl

@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+<#include "../common/header.ftl">
+<#setting number_format="#">
+<body class="font-opensans  sidebar_dark offcanvas-active">
+<!-- Page Loader -->
+<div class="page-loader-wrapper">
+    <div class="loader">
+    </div>
+</div>
+<!-- Start main html -->
+<div id="main_content">
+    <#--边栏sidebar-->
+    <#include "../common/iconMenu.ftl">
+    <#--主菜单-->
+    <#include "../common/startMainMenu.ftl">
+    <div class="page">
+        <#assign title = "关卡列表">
+        <#-- 顶部栏-->
+        <#include "../common/pageTop.ftl">
+
+        <#--    主要内容content-->
+        <div class="section-body">
+            <div class="container-fluid">
+                <div class="row clearfix">
+                    <div class="col-md-12 ">
+                        <div class="card">
+                            <div class="card-body">
+                                <table class="table table-bordered table-hover">
+                                    <thead>
+                                    <tr>
+                                        <th>
+                                            关卡id
+                                        </th>
+                                        <th>
+                                            关卡名
+                                        </th>
+                                        <th>描述</th>
+                                        <th>详情</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+
+                                    <#list list as item>
+                                        <tr>
+                                            <td>
+                                                ${item.id}
+                                            </td>
+                                            <td>
+                                                ${item.name}
+                                            </td>
+                                            <td>
+                                                ${item.describe}
+                                            </td>
+                                            <td>
+                                                <a href=""
+                                                   class="btn  btn-primary"
+                                                >详情</a>
+                                            </td>
+                                        </tr>
+                                    </#list>
+
+
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+
+            </div>
+
+        </div>
+
+    </div>
+</div>
+
+<!-- jQuery and bootstrtap js -->
+<script src="../main-bundles/lib.vendor.bundle.js"></script>
+<!-- Start core js and page js -->
+<script src="../js/core.js"></script>
+</body>
+</html>

+ 2 - 2
src/main/resources/templates/common/nav.ftl

@@ -2,7 +2,7 @@
 
     <ul class="nav sidebar-nav">
 
-        <li class="sidebar-brand">
+<#--        <li class="sidebar-brand">-->
 <#--            <#if (req.contextPath)?contains('dev')>-->
 <#--                <a href="javascript:void(0)">-->
 <#--                    哔蹦测试后台-->
@@ -12,7 +12,7 @@
 <#--                    哔蹦线上后台-->
 <#--                </a>-->
 <#--            </#if>-->
-        </li>
+<#--        </li>-->
 
         <li>
             <a href="${req.contextPath}/backstage_user/list"><i class="fa fa-fw fa-users"></i> 用户列表</a>

+ 21 - 2
src/main/resources/templates/common/startMainMenu.ftl

@@ -11,10 +11,11 @@
         <li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#all-tab"><i
                         class="fa fa-list-ul"></i>
                 全部</a></li>
-        <#--            <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#app-tab">Elements</a></li>-->
+         <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#app-tab">APP</a></li>
         <#--            <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#setting-tab">Settings</a></li>-->
     </ul>
     <div class="tab-content">
+        <#--  主要功能   -->
         <div class="tab-pane fade active show" id="all-tab">
             <nav class="sidebar-nav">
                 <ul class="metismenu ci-effect-1">
@@ -92,6 +93,24 @@
                 </ul>
             </nav>
         </div>
-
+        <#--  首页相关功能   -->
+        <div class="tab-pane fade active show" id="app-tab">
+            <nav class="sidebar-nav">
+                <ul class="metismenu ci-effect-1">
+                    <li class="g_heading">功能列表</li>
+                    <li>
+                        <a href="javascript:void(0)" class="has-arrow arrow-b"><i
+                                    class="icon-game-controller"></i><span
+                                    data-hover="Game">关卡信息</span></a>
+                        <ul>
+                            <li><a href="${req.contextPath}/backstage_level/getLevelJumpList"><span
+                                            data-hover="List">列表</span></a></li>
+                            <li><a href="${req.contextPath}/backstage_level/add"><span
+                                            data-hover="NewLevel">新的关卡</span></a></li>
+                        </ul>
+                    </li>
+                </ul>
+            </nav>
+        </div>
     </div>
 </div>