Browse Source

添加滑动开关,关闭授权等功能

bihuisong 1 year ago
parent
commit
364c14e399

+ 12 - 1
ruoyi-admin/pom.xml

@@ -76,7 +76,18 @@
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>3.4.3.1</version>
         </dependency>
-
+        <!-- JSON 解析器和生成器 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+        </dependency>
+        <!-- 引入 Mybatis-plus -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.3.1</version>
+        </dependency>
     </dependencies>
 
     <build>

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

@@ -27,6 +27,7 @@ public class ProjectAuthorityController {
 
     /**
      * 项目授权认证
+     *
      * @param json
      * @return
      * @throws ParseException
@@ -36,9 +37,7 @@ public class ProjectAuthorityController {
         SM4Utils sm4 = new SM4Utils();
         Map map = new HashMap<>();
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        // 验证和解析JWT
         String secretKey = sm4.decryptData_CBC(json.get("secretKey").toString());
-//        if (JWTExample.validateJWT(secretKey)) {
         SysSecretProject sysSecretProject = sysSecretProjectMapper.selectBaseBySecretKey(secretKey);
         Date now = new Date();
         Date date = dateFormat.parse(sysSecretProject.getOverdueDate().toString());
@@ -46,10 +45,11 @@ public class ProjectAuthorityController {
         if (seconds > 0) {
             map.put("overdueDate", seconds);
             map.put("isOverdue", true);
+            map.put("isSwitch", sysSecretProject.getIsSwitch());
         } else {
             map.put("isOverdue", false);
+            map.put("isSwitch", sysSecretProject.getIsSwitch());
         }
-//        }
         return R.ok(map);
     }
 

+ 35 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysSecretProjectController.java

@@ -11,6 +11,7 @@ import com.ruoyi.system.mapper.SysSecretProjectMapper;
 import com.ruoyi.system.service.ISysSecretProjectService;
 import com.ruoyi.web.utils.ClipboardUtil;
 import com.ruoyi.web.utils.JWTExample;
+import com.ruoyi.web.utils.RestUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -85,9 +86,11 @@ public class SysSecretProjectController extends BaseController {
         int comparisonResult = sysSecretProjectDTO.getOverdueDate().compareTo(currentDate);
         if (comparisonResult > 0) {
             sysSecretProjectDTO.setStatus(1L);
+            sysSecretProjectDTO.setIsSwitch(1L);
         } else if (comparisonResult < 0) {
             sysSecretProjectDTO.setStatus(2L);
         } else if (sysSecretProjectDTO.getOverdueDate().isAfter(previousDate) && sysSecretProjectDTO.getOverdueDate().isBefore(currentDate)) {
+            sysSecretProjectDTO.setIsSwitch(1L);
             sysSecretProjectDTO.setStatus(3L);
         }
         return toAjax(sysSecretProjectService.insertSysSecretProject(sysSecretProjectDTO));
@@ -106,14 +109,37 @@ public class SysSecretProjectController extends BaseController {
         int comparisonResult = sysSecretProjectDTO.getOverdueDate().compareTo(currentDate);
         if (comparisonResult > 0) {
             sysSecretProjectDTO.setStatus(1L);
+            sysSecretProjectDTO.setIsSwitch(1L);
         } else if (comparisonResult < 0) {
             sysSecretProjectDTO.setStatus(2L);
         } else if (sysSecretProjectDTO.getOverdueDate().isAfter(previousDate) && sysSecretProjectDTO.getOverdueDate().isBefore(currentDate)) {
+            sysSecretProjectDTO.setIsSwitch(1L);
             sysSecretProjectDTO.setStatus(3L);
         }
         return toAjax(sysSecretProjectService.updateSysSecretProject(sysSecretProjectDTO));
     }
 
+
+    /**
+     * 关闭项目授权管理
+     */
+    @Log(title = "关闭项目授权管理", businessType = BusinessType.UPDATE)
+    @PutMapping("/closeAuthority")
+    public AjaxResult closeAuthority(@RequestBody SysSecretProjectDTO sysSecretProjectDTO) {
+        // 获取当前日期
+        LocalDate currentDate = LocalDate.now();
+        // 获取当前日期前七天的日期
+        LocalDate previousDate = currentDate.minusDays(7);
+        sysSecretProjectDTO.setOverdueDate(previousDate);
+        sysSecretProjectDTO.setStatus(2L);
+        sysSecretProjectDTO.setIsSwitch(1L);
+        // TODO: 2023/11/25 清空redis中的授权key
+        if (sysSecretProjectDTO.getProjectName().equals("项目")) {
+            RestUtil.get("http://localhost:10004/authority/clearKey");
+        }
+        return toAjax(sysSecretProjectService.updateSysSecretProject(sysSecretProjectDTO));
+    }
+
     /**
      * 删除项目授权管理
      */
@@ -134,4 +160,13 @@ public class SysSecretProjectController extends BaseController {
     }
 
 
+    /**
+     * 修改是否校验状态
+     */
+    @Log(title = "修改是否校验状态", businessType = BusinessType.UPDATE)
+    @PutMapping("/updateIsSwitch")
+    public AjaxResult updateIsSwitch(@RequestBody SysSecretProjectDTO sysSecretProjectDTO) {
+        return toAjax(sysSecretProjectService.updateIsSwitch(sysSecretProjectDTO));
+    }
+
 }

+ 234 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/utils/RestUtil.java

@@ -0,0 +1,234 @@
+package com.ruoyi.web.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.*;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * 调用 Restful 接口 Util
+ *
+ * @author bihs
+ */
+@Slf4j
+public class RestUtil {
+
+
+    /**
+     * RestAPI 调用器
+     */
+    private final static RestTemplate RT;
+
+    static {
+        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
+        requestFactory.setConnectTimeout(300000);
+        requestFactory.setReadTimeout(300000);
+        RT = new RestTemplate(requestFactory);
+        // 解决乱码问题
+        RT.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+    }
+
+    public static RestTemplate getRestTemplate() {
+        return RT;
+    }
+
+    /**
+     * 发送 get 请求
+     */
+    public static JSONObject get(String url) {
+        return getNative(url, null, null).getBody();
+    }
+
+    /**
+     * 发送 get 请求
+     */
+    public static JSONObject get(String url, JSONObject variables) {
+        return getNative(url, variables, null).getBody();
+    }
+
+    /**
+     * 发送 get 请求
+     */
+    public static JSONObject get(String url, JSONObject variables, JSONObject params) {
+        return getNative(url, variables, params).getBody();
+    }
+
+    /**
+     * 发送 get 请求,返回原生 ResponseEntity 对象
+     */
+    public static ResponseEntity<JSONObject> getNative(String url, JSONObject variables, JSONObject params) {
+        return request(url, HttpMethod.GET, variables, params);
+    }
+
+    /**
+     * 发送 Post 请求
+     */
+    public static JSONObject post(String url) {
+        return postNative(url, null, null).getBody();
+    }
+
+    /**
+     * 发送 Post 请求
+     */
+    public static JSONObject post(String url, JSONObject params) {
+        return postNative(url, null, params).getBody();
+    }
+
+    /**
+     * 发送 Post 请求
+     */
+    public static JSONObject post(String url, JSONObject variables, JSONObject params) {
+        return postNative(url, variables, params).getBody();
+    }
+
+    /**
+     * 发送 POST 请求,返回原生 ResponseEntity 对象
+     */
+    public static ResponseEntity<JSONObject> postNative(String url, JSONObject variables, JSONObject params) {
+        return request(url, HttpMethod.POST, variables, params);
+    }
+
+    /**
+     * 发送 put 请求
+     */
+    public static JSONObject put(String url) {
+        return putNative(url, null, null).getBody();
+    }
+
+    /**
+     * 发送 put 请求
+     */
+    public static JSONObject put(String url, JSONObject params) {
+        return putNative(url, null, params).getBody();
+    }
+
+    /**
+     * 发送 put 请求
+     */
+    public static JSONObject put(String url, JSONObject variables, JSONObject params) {
+        return putNative(url, variables, params).getBody();
+    }
+
+    /**
+     * 发送 put 请求,返回原生 ResponseEntity 对象
+     */
+    public static ResponseEntity<JSONObject> putNative(String url, JSONObject variables, JSONObject params) {
+        return request(url, HttpMethod.PUT, variables, params);
+    }
+
+    /**
+     * 发送 delete 请求
+     */
+    public static JSONObject delete(String url) {
+        return deleteNative(url, null, null).getBody();
+    }
+
+    /**
+     * 发送 delete 请求
+     */
+    public static JSONObject delete(String url, JSONObject variables, JSONObject params) {
+        return deleteNative(url, variables, params).getBody();
+    }
+
+    /**
+     * 发送 delete 请求,返回原生 ResponseEntity 对象
+     */
+    public static ResponseEntity<JSONObject> deleteNative(String url, JSONObject variables, JSONObject params) {
+        return request(url, HttpMethod.DELETE, null, variables, params, JSONObject.class);
+    }
+
+    /**
+     * 发送请求
+     */
+    public static ResponseEntity<JSONObject> request(String url, HttpMethod method, JSONObject variables, JSONObject params) {
+        return request(url, method, getHeaderApplicationJson(), variables, params, JSONObject.class);
+    }
+
+    /**
+     * 发送请求
+     *
+     * @param url          请求地址
+     * @param method       请求方式
+     * @param headers      请求头  可空
+     * @param variables    请求url参数 可空
+     * @param params       请求body参数 可空
+     * @param responseType 返回类型
+     * @return ResponseEntity<responseType>
+     */
+    public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {
+        log.info(" RestUtil  --- request ---  url = "+ url);
+        if (StringUtils.isEmpty(url)) {
+            throw new RuntimeException("url 不能为空");
+        }
+        if (method == null) {
+            throw new RuntimeException("method 不能为空");
+        }
+        if (headers == null) {
+            headers = new HttpHeaders();
+        }
+        // 请求体
+        String body = "";
+        if (params != null) {
+            if (params instanceof JSONObject) {
+                body = ((JSONObject) params).toJSONString();
+
+            } else {
+                body = params.toString();
+            }
+        }
+        // 拼接 url 参数
+        if (variables != null) {
+            url += ("?" + asUrlVariables(variables));
+        }
+        // 发送请求
+        HttpEntity<String> request = new HttpEntity<>(body, headers);
+        return RT.exchange(url, method, request, responseType);
+    }
+
+    /**
+     * 获取JSON请求头
+     */
+    public static HttpHeaders getHeaderApplicationJson() {
+        return getHeader(MediaType.APPLICATION_JSON_UTF8_VALUE);
+    }
+
+    /**
+     * 获取请求头
+     */
+    public static HttpHeaders getHeader(String mediaType) {
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType(mediaType));
+        headers.add("Accept", mediaType);
+        return headers;
+    }
+
+    /**
+     * 将 JSONObject 转为 a=1&b=2&c=3...&n=n 的形式
+     */
+    public static String asUrlVariables(JSONObject variables) {
+        Map<String, Object> source = variables.getInnerMap();
+        Iterator<String> it = source.keySet().iterator();
+        StringBuilder urlVariables = new StringBuilder();
+        while (it.hasNext()) {
+            String key = it.next();
+            String value = "";
+            Object object = source.get(key);
+            if (object != null) {
+                if (!StringUtils.isEmpty(object.toString())) {
+                    value = object.toString();
+                }
+            }
+            urlVariables.append("&").append(key).append("=").append(value);
+        }
+        // 去掉第一个&
+        return urlVariables.substring(1);
+    }
+
+}

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysSecretProject.java

@@ -47,6 +47,11 @@ public class SysSecretProject extends BaseEntity {
     @Excel(name = "标识码")
     private String secretKey;
 
+    /**
+     * 是否校验授权(1:是;2:否)
+     */
+    private Long isSwitch;
+
     public void setId(Long id) {
         this.id = id;
     }
@@ -87,6 +92,13 @@ public class SysSecretProject extends BaseEntity {
         return secretKey;
     }
 
+    public void setIsSwitch(Long isSwitch) {
+        this.isSwitch = isSwitch;
+    }
+
+    public Long getIsSwitch() {
+        return isSwitch;
+    }
 
 
     @Override
@@ -97,6 +109,7 @@ public class SysSecretProject extends BaseEntity {
                 .append("overdueDate", getOverdueDate())
                 .append("status", getStatus())
                 .append("secretKey", getSecretKey())
+                .append("isSwitch", getIsSwitch())
                 .toString();
     }
 }

+ 24 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/SysSecretProjectDTO.java

@@ -1,6 +1,5 @@
 package com.ruoyi.system.domain.dto;
 
-import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
@@ -44,6 +43,12 @@ public class SysSecretProjectDTO extends BaseEntity {
     private String statusText;
 
     /**
+     * 是否校验授权(1:是;2:否)
+     */
+    private Long isSwitch;
+
+    private Boolean value;
+    /**
      * 标识码
      */
     private String secretKey;
@@ -72,6 +77,14 @@ public class SysSecretProjectDTO extends BaseEntity {
         return statusText;
     }
 
+    public void setIsSwitch(Long isSwitch) {
+        this.isSwitch = isSwitch;
+    }
+
+    public Long getIsSwitch() {
+        return isSwitch;
+    }
+
     public void setOverdueDate(LocalDate overdueDate) {
         this.overdueDate = overdueDate;
     }
@@ -104,6 +117,14 @@ public class SysSecretProjectDTO extends BaseEntity {
         return secretKey;
     }
 
+    public void setValue(Boolean value) {
+        this.value = value;
+    }
+
+    public Boolean getValue() {
+        return value;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -114,6 +135,8 @@ public class SysSecretProjectDTO extends BaseEntity {
                 .append("status", getStatus())
                 .append("statusText", getStatusText())
                 .append("secretKey", getSecretKey())
+                .append("isSwitch", getIsSwitch())
+                .append("value", getValue())
                 .toString();
     }
 }

+ 4 - 2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysSecretProjectMapper.java

@@ -1,11 +1,11 @@
 package com.ruoyi.system.mapper;
 
-import java.util.List;
-
 import com.ruoyi.system.domain.SysSecretProject;
 import com.ruoyi.system.domain.dto.SysSecretProjectDTO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 【请填写功能名称】Mapper接口
  *
@@ -66,4 +66,6 @@ public interface SysSecretProjectMapper {
     SysSecretProject selectBaseBySecretKey(@Param("secretKey") String secretKey);
 
     List<SysSecretProjectDTO> getAllList();
+
+    int updateIsSwitch(SysSecretProjectDTO sysSecretProjectDTO);
 }

+ 4 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysSecretProjectService.java

@@ -1,9 +1,9 @@
 package com.ruoyi.system.service;
 
-import java.util.List;
-import com.ruoyi.system.domain.SysSecretProject;
 import com.ruoyi.system.domain.dto.SysSecretProjectDTO;
 
+import java.util.List;
+
 /**
  * 【请填写功能名称】Service接口
  * 
@@ -59,4 +59,6 @@ public interface ISysSecretProjectService
      * @return 结果
      */
     public int deleteSysSecretProjectById(Long id);
+
+    int updateIsSwitch(SysSecretProjectDTO sysSecretProjectDTO);
 }

+ 14 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysSecretProjectServiceImpl.java

@@ -1,13 +1,12 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.List;
-
 import com.ruoyi.system.domain.dto.SysSecretProjectDTO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.SysSecretProjectMapper;
-import com.ruoyi.system.domain.SysSecretProject;
 import com.ruoyi.system.service.ISysSecretProjectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * 【请填写功能名称】Service业务层处理
@@ -85,4 +84,14 @@ public class SysSecretProjectServiceImpl implements ISysSecretProjectService {
     public int deleteSysSecretProjectById(Long id) {
         return sysSecretProjectMapper.deleteSysSecretProjectById(id);
     }
+
+    @Override
+    public int updateIsSwitch(SysSecretProjectDTO sysSecretProjectDTO) {
+        if (sysSecretProjectDTO.getIsSwitch().equals(1L)) {
+            sysSecretProjectDTO.setIsSwitch(2L);
+        } else {
+            sysSecretProjectDTO.setIsSwitch(1L);
+        }
+        return sysSecretProjectMapper.updateIsSwitch(sysSecretProjectDTO);
+    }
 }

+ 16 - 1
ruoyi-system/src/main/resources/mapper/system/SysSecretProjectMapper.xml

@@ -10,6 +10,7 @@
         <result property="overdueDate" column="overdue_date"/>
         <result property="status" column="status"/>
         <result property="secretKey" column="secret_key"/>
+        <result property="isSwitch" column="is_switch"/>
     </resultMap>
 
     <resultMap type="SysSecretProjectDTO" id="getSysSecretProjectList">
@@ -20,10 +21,11 @@
         <result property="status" column="status"/>
         <result property="secretKey" column="secret_key"/>
         <result property="statusText" column="statusText"/>
+        <result property="isSwitch" column="is_switch"/>
     </resultMap>
 
     <sql id="selectSysSecretProjectVo">
-        select id, project_id, overdue_date, status, secret_key
+        select id, project_id, overdue_date, status, secret_key,is_switch
         from sys_secret_project
     </sql>
 
@@ -37,6 +39,7 @@
         when ssp.STATUS = 3 then '临期'
         end statusText,
         ssp.status,
+        ssp.is_switch,
         secret_key
         from sys_secret_project ssp
         left join sys_project sp on ssp.project_id = sp.id
@@ -57,6 +60,7 @@
                    when ssp.STATUS = 3 then '临期'
                    end statusText,
                ssp.status,
+               ssp.is_switch,
                secret_key
         from sys_secret_project ssp
                  left join sys_project sp on ssp.project_id = sp.id
@@ -70,12 +74,14 @@
             <if test="secretKey != null">secret_key,</if>
             <if test="status != null">status,</if>
             <if test="overdueDate != null">overdue_date,</if>
+            <if test="isSwitch != null">is_switch,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="projectId != null">#{projectId},</if>
             <if test="secretKey != null">#{secretKey},</if>
             <if test="status != null">#{status},</if>
             <if test="overdueDate != null">#{overdueDate},</if>
+            <if test="isSwitch != null">#{isSwitch},</if>
         </trim>
     </insert>
 
@@ -86,6 +92,7 @@
             <if test="secretKey != null">secret_key = #{secretKey},</if>
             <if test="status != null">status = #{status},</if>
             <if test="overdueDate != null">overdue_date = #{overdueDate},</if>
+            <if test="isSwitch != null">is_switch = #{isSwitch},</if>
         </trim>
         where id = #{id}
     </update>
@@ -118,4 +125,12 @@
     <select id="getAllList" resultMap="getSysSecretProjectList">
         <include refid="selectSysSecretProjectVo"/>
     </select>
+
+    <update id="updateIsSwitch" parameterType="SysSecretProject">
+        update sys_secret_project
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="isSwitch != null">is_switch = #{isSwitch},</if>
+        </trim>
+        where id = #{id}
+    </update>
 </mapper>

+ 18 - 0
ruoyi-ui/src/api/system/secret.js

@@ -35,6 +35,24 @@ export function updateSecret(data) {
   })
 }
 
+// 修改【请填写功能名称】
+export function closeAuthority(data) {
+  return request({
+    url: '/system/secret/closeAuthority',
+    method: 'put',
+    data: data
+  })
+}
+
+// 修改【请填写功能名称】
+export function updateIsSwitch(data) {
+  return request({
+    url: '/system/secret/updateIsSwitch',
+    method: 'put',
+    data: data
+  })
+}
+
 // 删除【请填写功能名称】
 export function delSecret(id) {
   return request({

+ 62 - 35
ruoyi-ui/src/views/authority/secret/index.vue

@@ -1,16 +1,6 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
-<!--      <el-form-item label="项目id" prop="projectId">-->
-<!--        <el-select v-model="value" filterable placeholder="请选择" @change="onChange">-->
-<!--          <el-option-->
-<!--            v-for="item in options"-->
-<!--            :key="item.id"-->
-<!--            :label="item.projectName"-->
-<!--            :value="item.id">-->
-<!--          </el-option>-->
-<!--        </el-select>-->
-<!--      </el-form-item>-->
       <el-form-item label="标识码" prop="secretKey">
         <el-input
           v-model="queryParams.secretKey"
@@ -46,13 +36,16 @@
       <el-table-column label="状态" align="center" prop="statusText"/>
       <el-table-column label="过期时间" align="center" property="date" prop="overdueDate"/>
       <el-table-column label="标识码" align="center" prop="secretKey"/>
-<!--      <el-table-column label="状态" align="center" prop="type">-->
-<!--        <el-switch-->
-<!--          v-model="form.type"-->
-<!--          active-color="#13ce66"-->
-<!--          inactive-color="#ff4949">-->
-<!--        </el-switch>-->
-<!--      </el-table-column>-->
+      <el-table-column label="是否校验授权" align="center" prop="value">
+        <template slot-scope="scope">
+          <el-switch
+            @change="switchChange(scope.row.isSwitch,scope.row.id)"
+            v-model="form.isSwitch"
+            active-color="#13ce66"
+            inactive-color="#ff4949">
+          </el-switch>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -66,6 +59,13 @@
             size="mini"
             type="text"
             icon="el-icon-edit"
+            @click="handleClose(scope.row)"
+          >关闭授权
+          </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
             @click="handleCopy(scope.row)"
           >复制
           </el-button>
@@ -117,8 +117,8 @@
     </el-dialog>
     <!-- 删除项目授权管理对话框 -->
     <el-dialog title="系统提示" :visible.sync="openDel" width="500px" append-to-body>
-      <h>此项目已经和标识码成功绑定,如想要删除,请在下方输入框中输入确认删除!</h>
-      <el-form ref="form" :model="formDel" :rules="rulesDel" label-width="120px">
+      <h>此项目已经和标识码成功绑定,如想要删除,请在下方输入框中输入"确认删除"!</h>
+      <el-form ref="form" :model="formDel" label-width="120px">
         <!--        <el-form-item label="请输入确认删除" prop="inputConfirm">-->
         <el-input style="margin-top: 8px;" v-model="formDel.inputConfirm" placeholder="确认删除"/>
         <!--        </el-form-item>-->
@@ -132,8 +132,16 @@
 </template>
 
 <script>
-import {listSecret, getSecret, delSecret, addSecret, updateSecret, copySecret} from "@/api/system/secret";
-import {listAllProject} from "@/api/system/project";
+import {
+  listSecret,
+  getSecret,
+  delSecret,
+  addSecret,
+  updateSecret,
+  updateIsSwitch,
+  closeAuthority
+} from "@/api/system/secret";
+import {delProject, listAllProject} from "@/api/system/project";
 
 export default {
   name: "secret",
@@ -167,23 +175,13 @@ export default {
       },
       options: [],
       // 表单参数
-      form: {
-        type:true
-      },
+      form: {},
       formDel: {
         inputConfirm: ''
       },
+      value: true,
       // 表单校验
-      rules: {
-        // overdueDate: [
-        //   {required: true, message: '请选择过期时间', trigger: 'change'}
-        // ],
-      },
-      rulesDel: {
-        inputConfirm: [
-          {required: true, message: '请输入名称', trigger: 'input'}
-        ],
-      },
+      rules: {},
     };
   },
   created() {
@@ -191,11 +189,40 @@ export default {
     this.getProjectList()
   },
   methods: {
+    handleClose(row) {
+      let params = {
+        id: row.id,
+        projectName: row.projectName
+      }
+      this.$modal.confirm('是否确认关闭项目名称为"' + row.projectName + '"的授权?').then(function () {
+        return closeAuthority(params);
+      }).then((res) => {
+        this.$modal.msgSuccess("关闭成功");
+        this.getList();
+        this.getProjectList();
+      }).catch(() => {
+      });
+    },
+    switchChange(val, id) {
+      console.log(val, id);
+      let params = {
+        id: id,
+        isSwitch: val
+      }
+      updateIsSwitch(params).then(response => {
+        this.$modal.msgSuccess("操作成功");
+        this.getList();
+        this.getProjectList();
+      });
+    },
     /** 查询项目授权管理列表 */
     getList() {
       this.loading = true;
       listSecret(this.queryParams).then(response => {
         this.secretList = response.rows;
+        this.secretList.forEach(item => {
+          this.form.isSwitch = item.isSwitch == 1 ? true : false
+        })
         this.total = response.total;
         this.loading = false;
       });
@@ -309,7 +336,7 @@ export default {
         }).catch(() => {
         });
       } else {
-        this.$message.warning("您输入的内容不正确,请重新输入!")
+        this.$message.error("您输入的内容不正确,请重新输入!")
       }
     },
     cancelDel() {

File diff suppressed because it is too large
+ 104 - 7
sql/authority.sql