- 在数据控制器中引入去重对象逻辑 - 根据去重对象配置决定是否执行去重操作 - 当去重对象为 false 时不进行去重直接写入数据库 - 在管理界面令牌管理页面添加不去重选项 - 表格中显示去重对象时将 false 显示为不去重中文描述
This commit is contained in:
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"dypid/internal/db"
|
||||
"dypid/internal/global"
|
||||
"dypid/internal/model"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -41,12 +42,26 @@ func WriteDataHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
//数据获取
|
||||
//获取去重对象
|
||||
dedupObject, err := db.GetDedupObject(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
//判断数据是否需要去重
|
||||
//如果数据不需要去重则直接写入数据库
|
||||
if dedupObject == "false" {
|
||||
global.RDB.LPush(global.RCtx, fmt.Sprintf("list:%s", input.Token), input.Data)
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "数据写入成功",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//数据要去重,下面函数会执行
|
||||
//获取数据索引
|
||||
dataIndex, err := getDataIndex(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
|
||||
@@ -43,6 +43,7 @@ const clear = () => {
|
||||
}
|
||||
|
||||
const options = [
|
||||
{value: 'false', label: '不用去重'},
|
||||
{value: 'uid', label: 'uid'},
|
||||
{value: 'secid', label: 'secid'},
|
||||
{value: 'pid', label: 'pid'},
|
||||
@@ -234,7 +235,9 @@ onMounted(() => {
|
||||
|
||||
<el-table-column prop="dedup_object" label="去重对象" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag type="primary" effect="plain">{{ row.dedup_object }}</el-tag>
|
||||
<el-tag type="primary" effect="plain">
|
||||
{{ row.dedup_object == "false" ? "不去重" : row.dedup_object }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user