浏览代码

新增会议纪要/讯飞语音实时转写签名

tjf 8 月之前
父节点
当前提交
fbbb6b6b55

+ 14 - 21
ruoyi-admin/src/main/java/com/ruoyi/web/controller/meeting/MeetingRecordsController.java

@@ -23,18 +23,16 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/system/records")
-public class MeetingRecordsController extends BaseController
-{
+public class MeetingRecordsController extends BaseController {
     @Autowired
     private IMeetingRecordsService meetingRecordsService;
 
-/**
- * 查询会议记录列表
- */
-@PreAuthorize("@ss.hasPermi('system:records:list')")
-@GetMapping("/list")
-    public TableDataInfo list(MeetingRecords meetingRecords)
-    {
+    /**
+     * 查询会议记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:records:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(MeetingRecords meetingRecords) {
         startPage();
         List<MeetingRecords> list = meetingRecordsService.selectMeetingRecordsList(meetingRecords);
         return getDataTable(list);
@@ -46,8 +44,7 @@ public class MeetingRecordsController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:records:export')")
     @Log(title = "会议记录", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, MeetingRecords meetingRecords)
-    {
+    public void export(HttpServletResponse response, MeetingRecords meetingRecords) {
         List<MeetingRecords> list = meetingRecordsService.selectMeetingRecordsList(meetingRecords);
         ExcelUtil<MeetingRecords> util = new ExcelUtil<MeetingRecords>(MeetingRecords.class);
         util.exportExcel(response, list, "会议记录数据");
@@ -58,30 +55,27 @@ public class MeetingRecordsController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:records:query')")
     @GetMapping(value = "/{recordId}")
-    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
-    {
+    public AjaxResult getInfo(@PathVariable("recordId") Long recordId) {
         return success(meetingRecordsService.selectMeetingRecordsByRecordId(recordId));
     }
 
     /**
      * 新增会议记录
      */
-    @PreAuthorize("@ss.hasPermi('system:records:add')")
+    //@PreAuthorize("@ss.hasPermi('system:records:add')")
     @Log(title = "会议记录", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody MeetingRecords meetingRecords)
-    {
+    public AjaxResult add(@RequestBody MeetingRecords meetingRecords) {
         return toAjax(meetingRecordsService.insertMeetingRecords(meetingRecords));
     }
 
     /**
      * 修改会议记录
      */
-    @PreAuthorize("@ss.hasPermi('system:records:edit')")
+    //@PreAuthorize("@ss.hasPermi('system:records:edit')")
     @Log(title = "会议记录", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody MeetingRecords meetingRecords)
-    {
+    public AjaxResult edit(@RequestBody MeetingRecords meetingRecords) {
         return toAjax(meetingRecordsService.updateMeetingRecords(meetingRecords));
     }
 
@@ -91,8 +85,7 @@ public class MeetingRecordsController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:records:remove')")
     @Log(title = "会议记录", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{recordIds}")
-    public AjaxResult remove(@PathVariable Long[] recordIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] recordIds) {
         return toAjax(meetingRecordsService.deleteMeetingRecordsByRecordIds(recordIds));
     }
 }

+ 43 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/meeting/RealTimeController.java

@@ -0,0 +1,43 @@
+package com.ruoyi.web.controller.meeting;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.EncryptUtil;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.net.URLEncoder;
+
+/**
+ * 讯飞语言实时转写
+ *
+ * @Author: tjf
+ * @Date: 2024/10/24 16:22
+ * @Describe:
+ */
+@RestController
+@RequestMapping("/real/time")
+public class RealTimeController extends BaseController {
+    // appid
+    private static final String APPID = "5f699289";
+
+    // appid对应的secret_key
+    private static final String SECRET_KEY = "3ad88f9bd7f03255e8c40f2a0c0ae4f2";
+
+    /**
+     * 讯飞签名获取
+     */
+    @PostMapping
+    public AjaxResult getSigna() {
+        String ts = System.currentTimeMillis()/1000 + "";
+        String signa = "";
+        try {
+            signa = EncryptUtil.HmacSHA1Encrypt(EncryptUtil.MD5(APPID + ts), SECRET_KEY);
+            return AjaxResult.success("签名",URLEncoder.encode(signa, "UTF-8"));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return AjaxResult.success();
+    }
+}

+ 65 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtil.java

@@ -0,0 +1,65 @@
+package com.ruoyi.common.utils;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidKeyException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SignatureException;
+
+public class EncryptUtil {
+
+    /**
+     * 加密数字签名(基于HMACSHA1算法)
+     * 
+     * @param encryptText
+     * @param encryptKey
+     * @return
+     * @throws SignatureException
+     */
+    public static String HmacSHA1Encrypt(String encryptText, String encryptKey) throws SignatureException {
+        byte[] rawHmac = null;
+        try {
+            byte[] data = encryptKey.getBytes("UTF-8");
+            SecretKeySpec secretKey = new SecretKeySpec(data, "HmacSHA1");
+            Mac mac = Mac.getInstance("HmacSHA1");
+            mac.init(secretKey);
+            byte[] text = encryptText.getBytes("UTF-8");
+            rawHmac = mac.doFinal(text);
+        } catch (InvalidKeyException e) {
+            throw new SignatureException("InvalidKeyException:" + e.getMessage());
+        } catch (NoSuchAlgorithmException e) {
+            throw new SignatureException("NoSuchAlgorithmException:" + e.getMessage());
+        } catch (UnsupportedEncodingException e) {
+            throw new SignatureException("UnsupportedEncodingException:" + e.getMessage());
+        }
+        String oauth = new String(Base64.encodeBase64(rawHmac));
+        
+        return oauth;
+    }
+
+    public final static String MD5(String pstr) {
+        char md5String[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+        try {
+            byte[] btInput = pstr.getBytes();
+            MessageDigest mdInst = MessageDigest.getInstance("MD5");
+            mdInst.update(btInput);
+            byte[] md = mdInst.digest();
+            int j = md.length;
+            char str[] = new char[j * 2];
+            int k = 0;
+            for (int i = 0; i < j; i++) { // i = 0
+                byte byte0 = md[i]; // 95
+                str[k++] = md5String[byte0 >>> 4 & 0xf]; // 5
+                str[k++] = md5String[byte0 & 0xf]; // F
+            }
+
+            return new String(str);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+}