bihuisong 1 år sedan
förälder
incheckning
f95e4af43f

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/authority/ProjectAuthorityController.java

@@ -29,7 +29,7 @@ public class ProjectAuthorityController {
      * 项目授权认证
      *
      * @param json
-     * @return
+     * @return map
      * @throws ParseException
      */
     @PostMapping("/authority")

+ 6 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysSecretProjectController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.system;
 
+import cn.hutool.json.JSONObject;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -81,7 +82,11 @@ public class SysSecretProjectController extends BaseController {
         // 获取当前日期前七天的日期
         LocalDate previousDate = currentDate.minusDays(7);
         long milliseconds = Duration.between(LocalDateTime.now(), sysSecretProjectDTO.getOverdueDate().atStartOfDay()).toMillis();
-        String jwt = JWTExample.createJWT(sysSecretProjectDTO.getProjectName(), milliseconds);
+        JSONObject json = new JSONObject();
+        json.set("projectId",sysSecretProjectDTO.getProjectId());
+        json.set("projectName",sysSecretProjectDTO.getProjectName());
+        json.set("overdueDate",sysSecretProjectDTO.getOverdueDate());
+        String jwt = JWTExample.createJWT(json.toString(), milliseconds);
         sysSecretProjectDTO.setSecretKey(jwt);
         int comparisonResult = sysSecretProjectDTO.getOverdueDate().compareTo(currentDate);
         if (comparisonResult > 0) {

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/utils/JWTExample.java

@@ -8,7 +8,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
 import java.util.Date;
 
 public class JWTExample {
-    private static final String SECRET_KEY = "yourSecretKey";
+    private static final String SECRET_KEY = "C97E76AF40CSH12N128SN23B2DB9D476";
     private static final long EXPIRATION_TIME = 86400000; // 24小时
 
     public static void main(String[] args) {

+ 6 - 6
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysProjectServiceImpl.java

@@ -1,14 +1,14 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.List;
-
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.SysProject;
+import com.ruoyi.system.mapper.SysProjectMapper;
 import com.ruoyi.system.mapper.SysSecretProjectMapper;
+import com.ruoyi.system.service.ISysProjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.system.mapper.SysProjectMapper;
-import com.ruoyi.system.domain.SysProject;
-import com.ruoyi.system.service.ISysProjectService;
+
+import java.util.List;
 
 /**
  * 【请填写功能名称】Service业务层处理
@@ -78,7 +78,7 @@ public class SysProjectServiceImpl implements ISysProjectService {
     public AjaxResult deleteSysProjectByIds(Long[] ids) {
         int i = sysSecretProjectMapper.selectCountByProjectId(ids);
         if (i > 0) {
-            return AjaxResult.error("此项目已经绑定,请勿删除!");
+            return AjaxResult.error("此项目已经授权,请勿删除!");
         } else {
             return AjaxResult.success(sysProjectMapper.deleteSysProjectByIds(ids));
         }

+ 1 - 0
ruoyi-ui/src/views/authority/secret/index.vue

@@ -295,6 +295,7 @@ export default {
     },
     onChange(e) {
       this.form.projectId = e
+      this.form.projectName = this.options.find(item => item.id == e).projectName
     },
     /** 提交按钮 */
     submitForm() {