diff --git a/internal/controller/dataController.go b/internal/controller/dataController.go index 2f75af2..831ea57 100644 --- a/internal/controller/dataController.go +++ b/internal/controller/dataController.go @@ -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()}) diff --git a/web/src/views/admin/TokenManageView.vue b/web/src/views/admin/TokenManageView.vue index 43a7a04..0c5d562 100644 --- a/web/src/views/admin/TokenManageView.vue +++ b/web/src/views/admin/TokenManageView.vue @@ -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(() => {