Compare commits
37 Commits
315d43a16e
...
main
Author | SHA1 | Date | |
---|---|---|---|
a505f2ddc9 | |||
42cfe0dc0f | |||
2c8e25bdf8 | |||
0992b02880 | |||
1f8a5b8c37 | |||
795a9186a9 | |||
69d4c5d038 | |||
78d496ae72 | |||
4c19f4b16c | |||
1c56423ea4 | |||
5d304b6334 | |||
5e3c0762ab | |||
f883b0a7d8 | |||
861ac5d365 | |||
1e4c2d540e | |||
af3a297bb4 | |||
eb88f4b231 | |||
cf4287ddd9 | |||
88aee26105 | |||
b6ce840400 | |||
333882c9e0 | |||
640b1aa99e | |||
509b274c5c | |||
4c1e0d417d | |||
deb958b71b | |||
ad1f450b19 | |||
c675324d6d | |||
9a31fa96b5 | |||
fb4709e59a | |||
7e6f5e3a19 | |||
f2e7d7a5c4 | |||
7adcebee75 | |||
94e472a6c4 | |||
da7f40642e | |||
2d80cac3fd | |||
e20ff1a3b7 | |||
f2e9afc8aa |
37
.gitea/workflows/build_tool.yaml
Normal file
37
.gitea/workflows/build_tool.yaml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: 构建上传工具
|
||||||
|
on: [ push ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-tool:
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 安装Go(镜像)
|
||||||
|
run: |
|
||||||
|
# 使用国内镜像下载 Go
|
||||||
|
wget https://mirrors.aliyun.com/golang/go1.25.1.linux-amd64.tar.gz -O go.tar.gz
|
||||||
|
# 解压并设置环境变量
|
||||||
|
sudo rm -rf /usr/local/go
|
||||||
|
sudo tar -C /usr/local -xzf go.tar.gz
|
||||||
|
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
||||||
|
env:
|
||||||
|
GOROOT: /usr/local/go
|
||||||
|
|
||||||
|
- name: 构建上传工具
|
||||||
|
run: |
|
||||||
|
go env -w CGO_ENABLED=0 \
|
||||||
|
&& go env -w GOARCH=amd64 \
|
||||||
|
&& go env -w GOOS=windows \
|
||||||
|
&& go mod tidy \
|
||||||
|
&& cd ./tool \
|
||||||
|
&& go build -o 上传工具.exe
|
||||||
|
|
||||||
|
- name: 上传构建文件
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: 上传工具
|
||||||
|
path: tool/上传工具.exe
|
39
.gitea/workflows/deploy-dev.yaml
Normal file
39
.gitea/workflows/deploy-dev.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: 部署开发环境
|
||||||
|
on: [ push ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-dev:
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 构建Docker镜像
|
||||||
|
run: docker build -t dypid:latest .
|
||||||
|
|
||||||
|
- name: 导出镜像
|
||||||
|
run: mkdir release && docker save -o release/dypid.tar dypid:latest && docker rmi dypid:latest
|
||||||
|
|
||||||
|
- name: 安装sshpass工具
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt install -y sshpass
|
||||||
|
|
||||||
|
- name: 部署程序到测试服务器
|
||||||
|
env:
|
||||||
|
SSH_HOST: ${{ secrets.TEST_SSH_HOST }}
|
||||||
|
SSH_USER: ${{ secrets.TEST_SSH_USER }}
|
||||||
|
SSH_PASSWORD: ${{ secrets.TEST_SSH_PASSWORD }}
|
||||||
|
DEPLOY_DIR: "/data/dypid"
|
||||||
|
run: |
|
||||||
|
set -ex
|
||||||
|
# 上传新镜像
|
||||||
|
sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no release/dypid.tar $SSH_USER@$SSH_HOST:/tmp/dypid.tar
|
||||||
|
# 重启程序
|
||||||
|
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST \
|
||||||
|
"docker load -i /tmp/dypid.tar \
|
||||||
|
&& cd $DEPLOY_DIR \
|
||||||
|
&& docker compose up -d \
|
||||||
|
&& docker image prune -f"
|
40
.gitea/workflows/deploy-production.yaml
Normal file
40
.gitea/workflows/deploy-production.yaml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: 部署生产环境
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-production:
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 构建Docker镜像
|
||||||
|
run: docker build -t dypid:latest .
|
||||||
|
|
||||||
|
- name: 导出镜像
|
||||||
|
run: mkdir release && docker save -o release/dypid.tar dypid:latest && docker rmi dypid:latest
|
||||||
|
|
||||||
|
- name: 安装sshpass工具
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt install -y sshpass
|
||||||
|
|
||||||
|
- name: 部署程序到生产服务器
|
||||||
|
env:
|
||||||
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||||
|
SSH_USER: ${{ secrets.SSH_USER }}
|
||||||
|
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
|
||||||
|
DEPLOY_DIR: "/data/dypid"
|
||||||
|
run: |
|
||||||
|
set -ex
|
||||||
|
# 上传新镜像
|
||||||
|
sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no release/dypid.tar $SSH_USER@$SSH_HOST:/tmp/dypid.tar
|
||||||
|
# 重启程序
|
||||||
|
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST \
|
||||||
|
"docker load -i /tmp/dypid.tar \
|
||||||
|
&& cd $DEPLOY_DIR \
|
||||||
|
&& docker compose up -d \
|
||||||
|
&& docker image prune -f"
|
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
FROM node:lts AS webBuilder
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY web .
|
||||||
|
|
||||||
|
RUN npm install \
|
||||||
|
&& npm run build
|
||||||
|
|
||||||
|
FROM golang AS goBuilder
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
COPY --from=webBuilder /build/dist ./web/dist
|
||||||
|
|
||||||
|
RUN go env -w CGO_ENABLED=0 \
|
||||||
|
&& go mod tidy \
|
||||||
|
&& go build -o dypid
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
|
COPY --from=goBuilder /build/dypid /dypid
|
||||||
|
|
||||||
|
RUN apk update \
|
||||||
|
&& apk add --no-cache tzdata \
|
||||||
|
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||||
|
&& echo "Asia/Shanghai" > /etc/timezone \
|
||||||
|
&& apk del tzdata \
|
||||||
|
&& chmod +x /dypid
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/dypid" ]
|
@@ -3,55 +3,71 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"dypid/db"
|
"dypid/db"
|
||||||
"dypid/global"
|
"dypid/global"
|
||||||
"dypid/model"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ReadDataHandler(c *gin.Context) {
|
func ReadDataHandler(c *gin.Context) {
|
||||||
lLen := global.RDB.LLen(global.RCtx, fmt.Sprintf("list:%s", c.Query("token")))
|
//解析输入数据
|
||||||
if lLen.Val() == 0 {
|
input := struct {
|
||||||
c.JSON(200, gin.H{"result": "数据库没有数据"})
|
Token string `form:"token" binding:"required"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
retData := global.RDB.BLPop(global.RCtx, 0, fmt.Sprintf("list:%s", c.Query("token")))
|
|
||||||
newData := model.Data{}
|
retData := global.RDB.LPop(global.RCtx, fmt.Sprintf("list:%s", input.Token)).Val()
|
||||||
err := json.Unmarshal([]byte(retData.Val()[1]), &newData)
|
if retData == "null" {
|
||||||
if err != nil {
|
c.JSON(http.StatusOK, gin.H{"result": "数据库没有数据"})
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, gin.H{"result": newData})
|
|
||||||
|
c.String(http.StatusOK, retData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteDataHandler(c *gin.Context) {
|
func WriteDataHandler(c *gin.Context) {
|
||||||
data := model.Data{}
|
//解析输入数据
|
||||||
|
input := struct {
|
||||||
if err := c.BindQuery(&data); err != nil {
|
Token string `form:"token" binding:"required"`
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
Data string `form:"data" binding:"required"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dedupObject, err := db.GetDedupObject(data.Token)
|
|
||||||
|
//数据获取
|
||||||
|
dedupObject, err := db.GetDedupObject(input.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = createBF(fmt.Sprintf("dedup:%s:%s", data.Token, dedupObject), 0.01, 100000000)
|
dataIndex, err := getDataIndex(input.Token)
|
||||||
if err != nil && err.Error() != "ERR item exists" {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
dedupValue := strings.Split(input.Data, "----")[dataIndex[dedupObject]]
|
||||||
|
|
||||||
|
err = createCF(fmt.Sprintf("dedup:%s:%s", input.Token, dedupObject), 100_000_000)
|
||||||
|
if err != nil && err.Error() != "ERR item exists" {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
luaScript := `
|
luaScript := `
|
||||||
local dedupKey = KEYS[1] -- KEYS[1]: 去重键 (dedup:token:object)
|
local dedupKey = KEYS[1] -- KEYS[1]: 去重键 (dedup:token:object)
|
||||||
local listKey = KEYS[2] -- KEYS[2]: 列表键 (list:token)
|
local listKey = KEYS[2] -- KEYS[2]: 列表键 (list:token)
|
||||||
|
local deleteListKey = KEYS[3] -- KEYS[3]: 删除列表键 (delete-list:token)
|
||||||
local dedupValue = ARGV[1] -- ARGV[1]: 去重值
|
local dedupValue = ARGV[1] -- ARGV[1]: 去重值
|
||||||
local jsonData = ARGV[2] -- ARGV[2]: JSON序列化的数据
|
local rawData = ARGV[2] -- ARGV[2]: 原始数据
|
||||||
|
|
||||||
-- 检查布隆过滤器中是否已存在该值
|
-- 检查布隆过滤器中是否已存在该值
|
||||||
local exists = redis.call('BF.EXISTS', dedupKey, dedupValue)
|
local exists = redis.call('CF.EXISTS', dedupKey, dedupValue)
|
||||||
|
|
||||||
-- 如果已存在,返回已去重标记
|
-- 如果已存在,返回已去重标记
|
||||||
if exists == 1 then
|
if exists == 1 then
|
||||||
@@ -59,43 +75,54 @@ if exists == 1 then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 添加到布隆过滤器
|
-- 添加到布隆过滤器
|
||||||
redis.call('BF.ADD', dedupKey, dedupValue)
|
redis.call('CF.ADD', dedupKey, dedupValue)
|
||||||
-- 添加到列表
|
-- 添加到列表
|
||||||
redis.call('LPUSH', listKey, jsonData)
|
redis.call('LPUSH', listKey, rawData)
|
||||||
|
|
||||||
|
redis.call('LPUSH', deleteListKey, dedupValue)
|
||||||
|
|
||||||
-- 返回成功结果
|
-- 返回成功结果
|
||||||
return "ok"
|
return "ok"
|
||||||
`
|
`
|
||||||
k1 := fmt.Sprintf("dedup:%s:%s", data.Token, dedupObject)
|
|
||||||
k2 := fmt.Sprintf("list:%s", data.Token)
|
|
||||||
v1 := c.Query(dedupObject)
|
|
||||||
v2, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(500, gin.H{"error": "JSON序列化失败 " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := redis.NewScript(luaScript).Run(
|
result, err := redis.NewScript(luaScript).Run(
|
||||||
global.RCtx,
|
global.RCtx,
|
||||||
global.RDB,
|
global.RDB,
|
||||||
[]string{k1, k2},
|
[]string{
|
||||||
v1,
|
fmt.Sprintf("dedup:%s:%s", input.Token, dedupObject),
|
||||||
string(v2),
|
fmt.Sprintf("list:%s", input.Token),
|
||||||
|
fmt.Sprintf("delete-list:%s", input.Token),
|
||||||
|
},
|
||||||
|
dedupValue,
|
||||||
|
input.Data,
|
||||||
).Result()
|
).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{"error": "Redis操作失败 " + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Redis操作失败 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if resultMap, ok := result.(string); ok {
|
if resultMap, ok := result.(string); ok {
|
||||||
c.JSON(200, gin.H{"result": resultMap})
|
c.JSON(http.StatusOK, gin.H{"result": resultMap})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(500, gin.H{"error": "WriteDataHandler 错误"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "WriteDataHandler 错误"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createBF(bloomFilter string, errorRate float64, capacity int64) error {
|
func createCF(bloomFilter string, capacity int64) error {
|
||||||
_, err := global.RDB.BFReserve(global.RCtx, bloomFilter, errorRate, capacity).Result()
|
_, err := global.RDB.CFReserveBucketSize(global.RCtx, bloomFilter, capacity, 6).Result()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDataIndex(token string) (index map[string]int, err error) {
|
||||||
|
dataFormat, err := db.GetDataFormat(token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
f := strings.Split(dataFormat, "----")
|
||||||
|
index = make(map[string]int)
|
||||||
|
for i, s := range f {
|
||||||
|
index[s] = i
|
||||||
|
}
|
||||||
|
return index, nil
|
||||||
|
}
|
||||||
|
@@ -4,8 +4,10 @@ import (
|
|||||||
"dypid/db"
|
"dypid/db"
|
||||||
"dypid/global"
|
"dypid/global"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ListTokenHandler(c *gin.Context) {
|
func ListTokenHandler(c *gin.Context) {
|
||||||
@@ -13,50 +15,80 @@ func ListTokenHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreateTokenHandler(c *gin.Context) {
|
func CreateTokenHandler(c *gin.Context) {
|
||||||
if c.Query("token") == "" {
|
//解析输入数据
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "token不能为空"})
|
input := struct {
|
||||||
|
Token string `form:"token" binding:"required"`
|
||||||
|
DedupObject string `form:"dedup_object" binding:"required"`
|
||||||
|
DataFormat string `form:"data_format" binding:"required"`
|
||||||
|
Notes string `form:"notes"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
} else if c.Query("dedup_object") == "" {
|
}
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "dedup_object不能为空"})
|
//检查Token是否存在
|
||||||
|
if db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "创建Token失败,Token已经存在"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.CreateToken(c.Query("token"), c.Query("dedup_object"))
|
//创建Token
|
||||||
|
err := db.CreateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回
|
||||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateTokenHandler(c *gin.Context) {
|
func UpdateTokenHandler(c *gin.Context) {
|
||||||
if c.Query("token") == "" {
|
input := struct {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "token不能为空"})
|
Token string `form:"token" binding:"required"`
|
||||||
|
DedupObject string `form:"dedup_object" binding:"required"`
|
||||||
|
DataFormat string `form:"data_format" binding:"required"`
|
||||||
|
Notes string `form:"notes"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
} else if c.Query("dedup_object") == "" {
|
}
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "dedup_object不能为空"})
|
//检查Token是否存在
|
||||||
|
if !db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "更改失败,Token不存在"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.UpdateToken(c.Query("token"), c.Query("dedup_object"))
|
err := db.UpdateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteTokenHandler(c *gin.Context) {
|
func DeleteTokenHandler(c *gin.Context) {
|
||||||
if c.Query("token") == "" {
|
input := struct {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "token不能为空"})
|
Token string `form:"token" binding:"required"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//检查Token是否存在
|
||||||
|
if !db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "删除Token失败,Token不存在"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.DeleteToken(c.Query("token"))
|
err := db.DeleteToken(input.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,22 +100,34 @@ func GetTokenInfoHandler(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Token不能为空"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Token不能为空"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//检查Token是否存在
|
||||||
|
if !db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "获取信息失败,Token不存在"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dedupObject, err := db.GetDedupObject(input.Token)
|
dedupObject, err := db.GetDedupObject(input.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "获取去重对象失败 " + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "获取去重对象失败 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
dataFormat, err := db.GetDataFormat(input.Token)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "获取数据格式失败 " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
output := struct {
|
output := struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
DedupObject string `json:"dedup_object"`
|
DedupObject string `json:"dedup_object"`
|
||||||
|
DataFormat string `json:"data_format"`
|
||||||
DedupItemsNumber int64 `json:"dedup_items_number"`
|
DedupItemsNumber int64 `json:"dedup_items_number"`
|
||||||
CacheListNumber int64 `json:"cache_list_number"`
|
CacheListNumber int64 `json:"cache_list_number"`
|
||||||
}{}
|
}{}
|
||||||
output.Token = input.Token
|
output.Token = input.Token
|
||||||
output.DedupObject = dedupObject
|
output.DedupObject = dedupObject
|
||||||
output.DedupItemsNumber = global.RDB.BFCard(global.RCtx, "dedup:"+input.Token+":"+dedupObject).Val()
|
output.DataFormat = dataFormat
|
||||||
|
output.DedupItemsNumber = global.RDB.CFInfo(global.RCtx, "dedup:"+input.Token+":"+dedupObject).Val().NumItemsInserted
|
||||||
output.CacheListNumber = global.RDB.LLen(global.RCtx, "list:"+input.Token).Val()
|
output.CacheListNumber = global.RDB.LLen(global.RCtx, "list:"+input.Token).Val()
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"result": output})
|
c.JSON(http.StatusOK, gin.H{"result": output})
|
||||||
@@ -93,13 +137,19 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
|||||||
//解析输入数据
|
//解析输入数据
|
||||||
input := struct {
|
input := struct {
|
||||||
Token string `form:"token" binding:"required"`
|
Token string `form:"token" binding:"required"`
|
||||||
DedupBF bool `form:"dedup_bf"`
|
DedupBF string `form:"dedup_bf"`
|
||||||
CacheList bool `form:"cache_list"`
|
CacheList string `form:"cache_list"`
|
||||||
|
BothNumber string `form:"both_number"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindQuery(&input); err != nil {
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Token不能为空"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Token不能为空"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//检查Token是否存在
|
||||||
|
if !db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "删除Token失败,Token不存在"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//检查token是否存在
|
//检查token是否存在
|
||||||
_, err := db.GetDedupObject(input.Token)
|
_, err := db.GetDedupObject(input.Token)
|
||||||
@@ -107,14 +157,77 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Token不存在" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Token不存在" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
dedupObject, err := db.GetDedupObject(input.Token)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//删除去重对象
|
//删除去重对象
|
||||||
if input.DedupBF {
|
switch input.DedupBF {
|
||||||
|
case "":
|
||||||
|
case "all":
|
||||||
keys := global.RDB.Keys(global.RCtx, "dedup:"+input.Token+":*").Val()
|
keys := global.RDB.Keys(global.RCtx, "dedup:"+input.Token+":*").Val()
|
||||||
global.RDB.Del(global.RCtx, keys...)
|
global.RDB.Del(global.RCtx, keys...)
|
||||||
|
global.RDB.Del(global.RCtx, "delete-list:"+input.Token)
|
||||||
|
default:
|
||||||
|
i, err := strconv.Atoi(input.DedupBF)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "dedup_bf设置错误 " + err.Error()})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if input.CacheList {
|
result := global.RDB.LRange(global.RCtx, "delete-list:"+input.Token, int64(-i), -1).Val()
|
||||||
|
_, err = global.RDB.TxPipelined(global.RCtx, func(pipe redis.Pipeliner) error {
|
||||||
|
for _, s := range result {
|
||||||
|
pipe.CFDel(global.RCtx, "dedup:"+input.Token+":"+dedupObject, s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
global.RDB.LTrim(global.RCtx, "delete-list:"+input.Token, 0, int64(-i-1))
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除原始数据
|
||||||
|
switch input.CacheList {
|
||||||
|
case "":
|
||||||
|
case "all":
|
||||||
global.RDB.Del(global.RCtx, "list:"+input.Token)
|
global.RDB.Del(global.RCtx, "list:"+input.Token)
|
||||||
|
default:
|
||||||
|
i, err := strconv.Atoi(input.CacheList)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "cache_list设置错误 " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
global.RDB.LTrim(global.RCtx, "list:"+input.Token, 0, int64(-i-1))
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除去重参考值和原始数据
|
||||||
|
switch input.BothNumber {
|
||||||
|
case "":
|
||||||
|
default:
|
||||||
|
i, err := strconv.Atoi(input.BothNumber)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "both_number设置错误 " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result := global.RDB.LRange(global.RCtx, "delete-list:"+input.Token, int64(-i), -1).Val()
|
||||||
|
_, err = global.RDB.TxPipelined(global.RCtx, func(pipe redis.Pipeliner) error {
|
||||||
|
for _, s := range result {
|
||||||
|
pipe.CFDel(global.RCtx, "dedup:"+input.Token+":"+dedupObject, s)
|
||||||
|
}
|
||||||
|
pipe.LTrim(global.RCtx, "delete-list:"+input.Token, 0, int64(-i-1))
|
||||||
|
pipe.LTrim(global.RCtx, "list:"+input.Token, 0, int64(-i-1))
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//输出信息
|
//输出信息
|
||||||
|
31
db/local.go
31
db/local.go
@@ -12,6 +12,8 @@ var localDB []Token
|
|||||||
type Token struct {
|
type Token struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
DedupObject string `json:"dedup_object"`
|
DedupObject string `json:"dedup_object"`
|
||||||
|
DataFormat string `json:"data_format"`
|
||||||
|
Notes string `json:"notes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitLocalDB() {
|
func InitLocalDB() {
|
||||||
@@ -30,12 +32,22 @@ start:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CheckToken(token string) bool {
|
||||||
|
InitLocalDB()
|
||||||
|
for _, t := range localDB {
|
||||||
|
if t.Token == token {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func ListToken() []Token {
|
func ListToken() []Token {
|
||||||
InitLocalDB()
|
InitLocalDB()
|
||||||
return localDB
|
return localDB
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateToken(token string, dedupObject string) error {
|
func CreateToken(token string, dedupObject string, dataFormat string, Notes string) error {
|
||||||
InitLocalDB()
|
InitLocalDB()
|
||||||
for _, t := range localDB {
|
for _, t := range localDB {
|
||||||
if t.Token == token {
|
if t.Token == token {
|
||||||
@@ -43,7 +55,7 @@ func CreateToken(token string, dedupObject string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a := append(localDB, Token{token, dedupObject})
|
a := append(localDB, Token{token, dedupObject, dataFormat, Notes})
|
||||||
marshal, err := json.Marshal(a)
|
marshal, err := json.Marshal(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -55,12 +67,14 @@ func CreateToken(token string, dedupObject string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateToken(token string, dedupObject string) error {
|
func UpdateToken(token string, dedupObject string, dataFormat string, Notes string) error {
|
||||||
InitLocalDB()
|
InitLocalDB()
|
||||||
|
|
||||||
for i, t := range localDB {
|
for i, t := range localDB {
|
||||||
if t.Token == token {
|
if t.Token == token {
|
||||||
localDB[i].DedupObject = dedupObject
|
localDB[i].DedupObject = dedupObject
|
||||||
|
localDB[i].DataFormat = dataFormat
|
||||||
|
localDB[i].Notes = Notes
|
||||||
|
|
||||||
marshal, err := json.Marshal(localDB)
|
marshal, err := json.Marshal(localDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -72,6 +86,7 @@ func UpdateToken(token string, dedupObject string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InitLocalDB()
|
InitLocalDB()
|
||||||
return errors.New("token not found")
|
return errors.New("token not found")
|
||||||
}
|
}
|
||||||
@@ -93,6 +108,7 @@ func DeleteToken(token string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InitLocalDB()
|
InitLocalDB()
|
||||||
return errors.New("token not found")
|
return errors.New("token not found")
|
||||||
}
|
}
|
||||||
@@ -105,3 +121,12 @@ func GetDedupObject(token string) (dedupObject string, err error) {
|
|||||||
}
|
}
|
||||||
return "", errors.New("未找到Token")
|
return "", errors.New("未找到Token")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetDataFormat(token string) (dataFormat string, err error) {
|
||||||
|
for i, t := range localDB {
|
||||||
|
if t.Token == token {
|
||||||
|
return localDB[i].DataFormat, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", errors.New("未找到Token")
|
||||||
|
}
|
||||||
|
@@ -16,19 +16,6 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UploadData struct {
|
|
||||||
Dyid string // dyid
|
|
||||||
Uid string // uid
|
|
||||||
Secid string // secid
|
|
||||||
Pid string // pid
|
|
||||||
CommentId string // comment_id
|
|
||||||
Id1 string // id1
|
|
||||||
Id2 string // id2
|
|
||||||
Id3 string // id3
|
|
||||||
Id4 string // id4
|
|
||||||
Id5 string // id5
|
|
||||||
}
|
|
||||||
|
|
||||||
var httpClient = &http.Client{
|
var httpClient = &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
MaxIdleConns: 200,
|
MaxIdleConns: 200,
|
||||||
@@ -39,14 +26,45 @@ var httpClient = &http.Client{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
initConfig()
|
||||||
|
|
||||||
|
//检测./upload
|
||||||
|
fmt.Println("程序启动成功,正在检测txt文件")
|
||||||
|
for {
|
||||||
|
files, err := getTxtFiles("./")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if files != nil {
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
for _, filePath := range files {
|
||||||
|
fmt.Println("正在上传文件:", filePath)
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
processFile(filePath)
|
||||||
|
err := os.Truncate(filePath, 0)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("清空文件失败:", err)
|
||||||
|
}
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
fmt.Printf("上传完成,耗时:%s\n", time.Since(start))
|
||||||
|
}
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func initConfig() {
|
||||||
//程序配置
|
//程序配置
|
||||||
viper.SetDefault("url", "http://localhost:8080")
|
viper.SetDefault("url", "http://localhost:8080")
|
||||||
viper.SetDefault("token", "")
|
viper.SetDefault("token", "")
|
||||||
viper.SetDefault("thread-count", 10)
|
viper.SetDefault("thread-count", 10)
|
||||||
viper.SetDefault("index.uid", 0)
|
|
||||||
viper.SetDefault("index.secid", 1)
|
|
||||||
viper.SetDefault("index.pid", 2)
|
|
||||||
viper.SetDefault("index.comment-id", 3)
|
|
||||||
//设置配置文件名和路径 ./config.toml
|
//设置配置文件名和路径 ./config.toml
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
@@ -62,46 +80,12 @@ func main() {
|
|||||||
fmt.Errorf("无法读取配置文件: %w", err)
|
fmt.Errorf("无法读取配置文件: %w", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
//检测./upload
|
|
||||||
fmt.Println("程序启动成功,正在检测txt文件")
|
|
||||||
//os.Mkdir("./upload", os.ModePerm)
|
|
||||||
for {
|
|
||||||
files, err := getTxtFiles("./")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if files != nil {
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
for _, filePath := range files {
|
|
||||||
fmt.Println("正在上传文件:", filePath)
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
processFile(filePath)
|
|
||||||
os.Remove(filePath)
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
}
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
func uploadDataToServer(data UploadData) error {
|
|
||||||
|
func uploadDataToServer(data string) error {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("token", viper.GetString("token"))
|
params.Set("token", viper.GetString("token"))
|
||||||
params.Add("dyid", data.Dyid)
|
params.Set("data", data)
|
||||||
params.Add("uid", data.Uid)
|
|
||||||
params.Add("secid", data.Secid)
|
|
||||||
params.Add("pid", data.Pid)
|
|
||||||
params.Add("comment_id", data.CommentId)
|
|
||||||
params.Add("id1", data.Id1)
|
|
||||||
params.Add("id2", data.Id2)
|
|
||||||
params.Add("id3", data.Id3)
|
|
||||||
params.Add("id4", data.Id4)
|
|
||||||
params.Add("id5", data.Id5)
|
|
||||||
|
|
||||||
resp, err := httpClient.Post(viper.GetString("url")+"/api/data?"+params.Encode(), "application/x-www-form-urlencoded", strings.NewReader(""))
|
resp, err := httpClient.Post(viper.GetString("url")+"/api/data?"+params.Encode(), "application/x-www-form-urlencoded", strings.NewReader(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,10 +98,8 @@ func uploadDataToServer(data UploadData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取目录中的所有txt文件
|
// 获取目录中的所有txt文件
|
||||||
func getTxtFiles(dir string) ([]string, error) {
|
func getTxtFiles(dir string) (txtFiles []string, err error) {
|
||||||
var txtFiles []string
|
err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||||
|
|
||||||
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -177,6 +159,7 @@ func processFile(filePath string) {
|
|||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
fmt.Printf("读取文件 %s 错误: %v\n", filePath, err)
|
fmt.Printf("读取文件 %s 错误: %v\n", filePath, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("文件【%s】处理完成,共处理 %d 行数据\n", filePath, lineCount)
|
fmt.Printf("文件【%s】处理完成,共处理 %d 行数据\n", filePath, lineCount)
|
||||||
@@ -188,35 +171,8 @@ func processLines(lines <-chan string, workerID int, filePath string) {
|
|||||||
if strings.TrimSpace(line) == "" {
|
if strings.TrimSpace(line) == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用----分割行数据
|
|
||||||
parts := strings.Split(line, "----")
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
parts = append(parts, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 确保有足够的字段
|
|
||||||
if len(parts) < 3 {
|
|
||||||
fmt.Printf("Worker %d (文件 %s): 行数据字段不足,跳过: %s\n", workerID, filePath, line)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建上传数据结构
|
|
||||||
uploadData := UploadData{
|
|
||||||
Uid: parts[viper.GetInt("index.uid")],
|
|
||||||
Secid: parts[viper.GetInt("index.secid")],
|
|
||||||
Pid: parts[viper.GetInt("index.pid")],
|
|
||||||
CommentId: parts[viper.GetInt("index.comment-id")],
|
|
||||||
Dyid: parts[4],
|
|
||||||
Id1: parts[5],
|
|
||||||
Id2: parts[6],
|
|
||||||
Id3: parts[7],
|
|
||||||
Id4: parts[8],
|
|
||||||
Id5: parts[9],
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上传数据
|
// 上传数据
|
||||||
if err := uploadDataToServer(uploadData); err != nil {
|
if err := uploadDataToServer(line); err != nil {
|
||||||
fmt.Printf("Worker %d (文件 %s): 上传失败: %v\n", workerID, filePath, err)
|
fmt.Printf("Worker %d (文件 %s): 上传失败: %v\n", workerID, filePath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="">
|
<html lang="">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Vite App</title>
|
<title>抖音数据去重</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -1,64 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, watch} from 'vue'
|
|
||||||
import {useRoute, useRouter} from "vue-router";
|
|
||||||
import {useCounterStore} from "@/stores/counter.ts";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
const activeIndex = ref(route.name?.toString() || "TokenList")
|
|
||||||
|
|
||||||
watch(route, (newRoute) => {
|
|
||||||
activeIndex.value = newRoute.name?.toString() || "TokenList"
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleSelect = (key: string) => {
|
|
||||||
router.push({
|
|
||||||
name: key
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-container>
|
|
||||||
<el-header>
|
|
||||||
<el-menu
|
|
||||||
:default-active="activeIndex"
|
|
||||||
class="el-menu-demo"
|
|
||||||
mode="horizontal"
|
|
||||||
@select="handleSelect"
|
|
||||||
>
|
|
||||||
<el-menu-item index="TokenDetail">Token详细信息</el-menu-item>
|
|
||||||
<el-menu-item index="TokenManage">管理Token</el-menu-item>
|
|
||||||
<el-menu-item v-if="useCounterStore().isAdmin">
|
|
||||||
<el-button type="danger" plain @click="useCounterStore().isAdmin=false">退出管理员</el-button>
|
|
||||||
</el-menu-item>
|
|
||||||
</el-menu>
|
|
||||||
|
|
||||||
</el-header>
|
|
||||||
|
|
||||||
<el-container>
|
|
||||||
<el-main>
|
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</el-main>
|
|
||||||
</el-container>
|
|
||||||
</el-container>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
<style>
|
|
||||||
html, body, #app {
|
html, body, #app {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-container {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-menu-demo {
|
|
||||||
line-height: 60px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -2,10 +2,33 @@ import {createRouter, createWebHistory} from 'vue-router'
|
|||||||
|
|
||||||
import TokenManageView from '@/views/TokenManageView.vue'
|
import TokenManageView from '@/views/TokenManageView.vue'
|
||||||
import TokenDetailView from '@/views/TokenDetailView.vue'
|
import TokenDetailView from '@/views/TokenDetailView.vue'
|
||||||
|
import AdminView from '@/views/AdminView.vue'
|
||||||
|
import HomeView from '@/views/HomeView.vue'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{path: '/manage', name: "TokenManage", component: TokenManageView},
|
{
|
||||||
{path: '/', name: "TokenDetail", component: TokenDetailView},
|
path: '/',
|
||||||
|
name: "Home",
|
||||||
|
component: HomeView,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/haha',
|
||||||
|
name: "Admin",
|
||||||
|
component: AdminView,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
name: "TokenManage",
|
||||||
|
component: TokenManageView
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'token',
|
||||||
|
name: "TokenDetail",
|
||||||
|
component: TokenDetailView
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
@@ -2,6 +2,8 @@ import {ref, computed} from 'vue'
|
|||||||
import {defineStore} from 'pinia'
|
import {defineStore} from 'pinia'
|
||||||
|
|
||||||
export const useCounterStore = defineStore('counter', () => {
|
export const useCounterStore = defineStore('counter', () => {
|
||||||
|
const homeToken = ref("")
|
||||||
|
|
||||||
const token = ref("")
|
const token = ref("")
|
||||||
|
|
||||||
const isAdmin = ref(false)
|
const isAdmin = ref(false)
|
||||||
|
50
web/src/views/AdminView.vue
Normal file
50
web/src/views/AdminView.vue
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {ref, watch} from 'vue'
|
||||||
|
import {useRoute, useRouter} from "vue-router";
|
||||||
|
import {useCounterStore} from "@/stores/counter.ts";
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const activeIndex = ref(route.name?.toString() || "TokenList")
|
||||||
|
|
||||||
|
watch(route, (newRoute) => {
|
||||||
|
activeIndex.value = newRoute.name?.toString() || "TokenList"
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleSelect = (key: string) => {
|
||||||
|
router.push({
|
||||||
|
name: key
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<el-menu
|
||||||
|
:default-active="activeIndex"
|
||||||
|
class="el-menu-demo"
|
||||||
|
mode="horizontal"
|
||||||
|
@select="handleSelect"
|
||||||
|
>
|
||||||
|
<el-menu-item index="TokenManage">管理Token</el-menu-item>
|
||||||
|
<el-menu-item index="TokenDetail">Token详细信息</el-menu-item>
|
||||||
|
<el-menu-item v-if="useCounterStore().isAdmin">
|
||||||
|
<el-button type="danger" plain @click="useCounterStore().isAdmin=false">退出管理员</el-button>
|
||||||
|
</el-menu-item>
|
||||||
|
</el-menu>
|
||||||
|
|
||||||
|
</el-header>
|
||||||
|
|
||||||
|
<el-container>
|
||||||
|
<el-main>
|
||||||
|
<router-view></router-view>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</el-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
77
web/src/views/HomeView.vue
Normal file
77
web/src/views/HomeView.vue
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {ref} from 'vue'
|
||||||
|
import axios from "@/axios.ts";
|
||||||
|
import {useRoute} from "vue-router"
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
|
const token = ref(useRoute().query.token)
|
||||||
|
const input = ref(useRoute().query.token)
|
||||||
|
const result = ref()
|
||||||
|
|
||||||
|
const inputChange = () => {
|
||||||
|
if (input.value != null && input.value != '') {
|
||||||
|
axios.get('/api/token/info', {
|
||||||
|
params: {
|
||||||
|
token: input.value
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
result.value = res.data.result
|
||||||
|
token.value = input.value
|
||||||
|
ElMessage({
|
||||||
|
message: '更改成功',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
}).catch(error => {
|
||||||
|
ElMessage({
|
||||||
|
message: 'Token输入错误',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getInfo = () => {
|
||||||
|
if (token.value != null && token.value != '') {
|
||||||
|
axios.get('/api/token/info', {
|
||||||
|
params: {
|
||||||
|
token: token.value
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
result.value = res.data.result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getInfo()
|
||||||
|
setInterval(getInfo, 5000)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<b>当前Token:</b>
|
||||||
|
<el-input
|
||||||
|
v-model="input"
|
||||||
|
style="width: 240px"
|
||||||
|
placeholder="输入Token"
|
||||||
|
clearable
|
||||||
|
@change="inputChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<el-divider/>
|
||||||
|
<b>Token信息(每5秒刷新)</b>
|
||||||
|
<el-button type="primary" plain @click="getInfo">手动刷新</el-button>
|
||||||
|
<el-descriptions
|
||||||
|
direction="vertical"
|
||||||
|
:column="4"
|
||||||
|
border
|
||||||
|
>
|
||||||
|
<el-descriptions-item label="去重对象">{{ result?.dedup_object }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="上传数据格式">{{ result?.data_format }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="去重记录值">{{ result?.dedup_items_number }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="Redis中数据条数">{{ result?.cache_list_number }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@@ -3,8 +3,25 @@ import {useCounterStore} from "@/stores/counter.ts";
|
|||||||
import {ref, watch} from 'vue'
|
import {ref, watch} from 'vue'
|
||||||
import axios from "@/axios.ts";
|
import axios from "@/axios.ts";
|
||||||
|
|
||||||
|
|
||||||
|
// 创建响应式引用,用于存储API请求结果
|
||||||
const result = ref()
|
const result = ref()
|
||||||
|
|
||||||
|
// 创建响应式引用,用于存储当前选中的token值
|
||||||
const value = ref('')
|
const value = ref('')
|
||||||
|
value.value = useCounterStore().token
|
||||||
|
|
||||||
|
// 创建响应式引用,用于存储下拉选项列表
|
||||||
|
const options = ref([] as string[])
|
||||||
|
|
||||||
|
// 控制删除指定Redis键的确认对话框的显示状态
|
||||||
|
const deleteSpecifyDataVisible = ref(false)
|
||||||
|
const inputSpecifyData = ref('')
|
||||||
|
|
||||||
|
const deleteSpecifyDedupVisible = ref(false)
|
||||||
|
const inputSpecifyDedup = ref('')
|
||||||
|
const deleteSpecifyRawVisible = ref(false)
|
||||||
|
const inputSpecifyRaw = ref('')
|
||||||
|
|
||||||
const getInfo = () => {
|
const getInfo = () => {
|
||||||
if (value.value != '') {
|
if (value.value != '') {
|
||||||
@@ -24,17 +41,18 @@ const deleteDedup = () => {
|
|||||||
axios.delete('/api/token/info', {
|
axios.delete('/api/token/info', {
|
||||||
params: {
|
params: {
|
||||||
token: value.value,
|
token: value.value,
|
||||||
dedup_bf: true
|
dedup_bf: "all"
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
getInfo()
|
getInfo()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteRedis = () => {
|
const deleteRedis = () => {
|
||||||
axios.delete('/api/token/info', {
|
axios.delete('/api/token/info', {
|
||||||
params: {
|
params: {
|
||||||
token: value.value,
|
token: value.value,
|
||||||
cache_list: true
|
cache_list: "all",
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
getInfo()
|
getInfo()
|
||||||
@@ -45,38 +63,73 @@ getInfo()
|
|||||||
setInterval(getInfo, 5000)
|
setInterval(getInfo, 5000)
|
||||||
|
|
||||||
watch(value, (newValue) => {
|
watch(value, (newValue) => {
|
||||||
|
useCounterStore().token = value.value
|
||||||
getInfo()
|
getInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
interface optionsType {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = ref([] as optionsType[])
|
|
||||||
value.value = useCounterStore().token
|
|
||||||
|
|
||||||
axios.get('/api/token').then(res => {
|
axios.get('/api/token').then(res => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
res.data.result.forEach((item: any) => {
|
res.data.result.forEach((item: any) => {
|
||||||
options.value.push({"value": item.token})
|
options.value.push(item.token)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const deleteSpecifyData = () => {
|
||||||
|
axios.delete('/api/token/info', {
|
||||||
|
params: {
|
||||||
|
token: value.value,
|
||||||
|
both_number: inputSpecifyData.value,
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
getInfo()
|
||||||
|
deleteSpecifyDataVisible.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const deleteSpecifyDedup = () => {
|
||||||
|
axios.delete('/api/token/info', {
|
||||||
|
params: {
|
||||||
|
token: value.value,
|
||||||
|
dedup_bf: inputSpecifyDedup.value,
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
getInfo()
|
||||||
|
deleteSpecifyDedupVisible.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const deleteSpecifyRaw = () => {
|
||||||
|
axios.delete('/api/token/info', {
|
||||||
|
params: {
|
||||||
|
token: value.value,
|
||||||
|
cache_list: inputSpecifyRaw.value,
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
getInfo()
|
||||||
|
deleteSpecifyRawVisible.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<div v-if="!useCounterStore().isAdmin">
|
||||||
|
<el-alert title="您没有权限访问此页面" type="error" center show-icon/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div v-if="useCounterStore().isAdmin">
|
||||||
<b>当前Token:</b>
|
<b>当前Token:</b>
|
||||||
<el-select v-model="value" placeholder="选择Token" style="width: 240px">
|
<el-select v-model="value" placeholder="选择Token" style="width: 240px">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
:key="item.value"
|
:key="item"
|
||||||
:value="item.value"
|
:value="item"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
|
|
||||||
<el-divider/>
|
<el-divider/>
|
||||||
|
|
||||||
<b>Token信息(每5秒刷新)</b>
|
<b>Token信息(每5秒刷新)</b>
|
||||||
<el-button type="primary" plain @click="getInfo">手动刷新</el-button>
|
<el-button type="primary" plain @click="getInfo">手动刷新</el-button>
|
||||||
<el-descriptions
|
<el-descriptions
|
||||||
@@ -84,16 +137,59 @@ axios.get('/api/token').then(res => {
|
|||||||
:column="4"
|
:column="4"
|
||||||
border
|
border
|
||||||
>
|
>
|
||||||
<el-descriptions-item label="去重对象">{{ result?.dedup_object }}</el-descriptions-item>
|
<el-descriptions-item label="去重对象" label-width="150px">
|
||||||
<el-descriptions-item label="去重记录值">{{ result?.dedup_items_number }}</el-descriptions-item>
|
<el-tag>{{ result?.dedup_object }}</el-tag>
|
||||||
<el-descriptions-item label="Redis中数据条数">{{ result?.cache_list_number }}</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="上传数据格式" label-width="150px">
|
||||||
|
{{ result?.data_format }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="去重参考值数量" label-width="150px">
|
||||||
|
{{ result?.dedup_items_number }} 条
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="原始数据数量" label-width="150px">
|
||||||
|
{{ result?.cache_list_number }} 条
|
||||||
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
|
|
||||||
<div v-if="useCounterStore().isAdmin">
|
|
||||||
<p><b>管理</b></p>
|
<p><b>管理</b></p>
|
||||||
|
<el-button type="danger" @click="deleteDedup">删除全部去重参考值</el-button>
|
||||||
|
<el-button type="danger" @click="deleteRedis">删除全部原始数据</el-button>
|
||||||
|
<div style="margin-top: 10px">
|
||||||
|
<el-button type="danger" @click="deleteSpecifyDedupVisible=true">删除指定数量去重参考值</el-button>
|
||||||
|
<el-button type="danger" @click="deleteSpecifyRawVisible=true">删除指定数量原始数据</el-button>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top: 10px">
|
||||||
|
<el-button type="danger" @click="deleteSpecifyDataVisible=true">
|
||||||
|
删除指定数量的数据(去重参考值+原始数据)
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-button type="danger" @click="deleteDedup">删除去重记录值</el-button>
|
|
||||||
<el-button type="danger" @click="deleteRedis">删除Redis数据</el-button>
|
<!--弹窗输入-->
|
||||||
|
<el-dialog v-model="deleteSpecifyDedupVisible" title="删除指定数量去重参考值" width="400">
|
||||||
|
<el-input v-model="inputSpecifyDedup" style="width: 200px" placeholder="请输入删除数量"/>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="deleteSpecifyDedup">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog v-model="deleteSpecifyRawVisible" title="删除指定数量原始数据" width="400">
|
||||||
|
<el-input v-model="inputSpecifyRaw" style="width: 200px" placeholder="请输入删除数量"/>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="deleteSpecifyRaw">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog v-model="deleteSpecifyDataVisible" title="删除指定数量的数据" width="400">
|
||||||
|
<el-input v-model="inputSpecifyData" style="width: 200px" placeholder="请输入删除数量"/>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="deleteSpecifyData">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@@ -2,43 +2,60 @@
|
|||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import axios from "@/axios.ts";
|
import axios from "@/axios.ts";
|
||||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||||
|
import {useCounterStore} from "@/stores/counter.ts";
|
||||||
|
import {useRouter} from "vue-router";
|
||||||
|
|
||||||
const tableData = ref([])
|
const tableData = ref([])
|
||||||
|
const input = ref('')
|
||||||
|
const value = ref('')
|
||||||
|
const dataFormat = ref('')
|
||||||
|
const inputPassWord = ref('')
|
||||||
|
const router = useRouter()
|
||||||
|
var rowOut: any
|
||||||
|
const dedupObjectVisible = ref(false)
|
||||||
|
const dataFormatVisible = ref(false)
|
||||||
|
const inputNotes = ref("")
|
||||||
|
const NotesVisible = ref(false)
|
||||||
|
const options = [
|
||||||
|
{
|
||||||
|
value: 'uid',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'secid',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'pid',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'comment_id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'dyid',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const dataFormatOptions = [
|
||||||
|
{
|
||||||
|
value: 'uid----secid----pid----comment_id',
|
||||||
|
}, {
|
||||||
|
value: 'uid----secid',
|
||||||
|
}, {
|
||||||
|
value: 'dyid',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
axios.get("/api/token").then(res => {
|
axios.get("/api/token").then(res => {
|
||||||
tableData.value = res.data.result
|
tableData.value = res.data.result
|
||||||
})
|
})
|
||||||
|
|
||||||
const input = ref('')
|
|
||||||
const value = ref('')
|
|
||||||
const options = [
|
|
||||||
{
|
|
||||||
value: 'uid',
|
|
||||||
label: 'uid',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'pid',
|
|
||||||
label: 'pid',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'secid',
|
|
||||||
label: 'secid',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'dyid',
|
|
||||||
label: 'dyid',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'comment_id',
|
|
||||||
label: 'comment_id',
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const addToken = () => {
|
const addToken = () => {
|
||||||
axios.post('/api/token', {}, {
|
axios.post('/api/token', {}, {
|
||||||
params: {
|
params: {
|
||||||
token: input.value,
|
token: input.value,
|
||||||
dedup_object: value.value
|
dedup_object: value.value,
|
||||||
|
data_format: dataFormat.value,
|
||||||
|
notes: inputNotes.value,
|
||||||
}
|
}
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.data.result == "ok") {
|
if (response.data.result == "ok") {
|
||||||
@@ -55,29 +72,26 @@ const addToken = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
import {useCounterStore} from "@/stores/counter.ts";
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const viewDetails = (row: any) => {
|
const viewDetails = (row: any) => {
|
||||||
useCounterStore().token = row.token
|
useCounterStore().token = row.token
|
||||||
router.push({
|
router.push({
|
||||||
name: "TokenDetail"
|
name: "TokenDetail",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var rowOut: any
|
|
||||||
const dedupObjectVisible = ref(false)
|
|
||||||
const dialogDedupObjectVisible = (row: any) => {
|
const dialogDedupObjectVisible = (row: any) => {
|
||||||
rowOut = row
|
rowOut = row
|
||||||
dedupObjectVisible.value = true
|
dedupObjectVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateDedupObject = () => {
|
const updateDedupObject = () => {
|
||||||
dedupObjectVisible.value = false
|
dedupObjectVisible.value = false
|
||||||
axios.put('/api/token', {}, {
|
axios.put('/api/token', {}, {
|
||||||
params: {
|
params: {
|
||||||
token: rowOut.token,
|
token: rowOut.token,
|
||||||
dedup_object: value.value
|
dedup_object: value.value,
|
||||||
|
data_format: rowOut.data_format,
|
||||||
|
notes: rowOut.notes,
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.result == "ok") {
|
if (res.data.result == "ok") {
|
||||||
@@ -92,7 +106,64 @@ const updateDedupObject = () => {
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
ElMessage.error(error.response?.data?.error)
|
ElMessage.error(error.response?.data?.error)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogDataFormatVisible = (row: any) => {
|
||||||
|
rowOut = row
|
||||||
|
dataFormatVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateDataFormat = () => {
|
||||||
|
dataFormatVisible.value = false
|
||||||
|
axios.put('/api/token', {}, {
|
||||||
|
params: {
|
||||||
|
token: rowOut.token,
|
||||||
|
dedup_object: rowOut.dedup_object,
|
||||||
|
data_format: dataFormat.value,
|
||||||
|
notes: rowOut.notes,
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
if (res.data.result == "ok") {
|
||||||
|
ElMessage({
|
||||||
|
message: '更改成功',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
axios.get('/api/token').then(res => {
|
||||||
|
tableData.value = res.data.result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
ElMessage.error(error.response?.data?.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogNotesVisible = (row: any) => {
|
||||||
|
rowOut = row
|
||||||
|
NotesVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateNotes = () => {
|
||||||
|
NotesVisible.value = false
|
||||||
|
axios.put('/api/token', {}, {
|
||||||
|
params: {
|
||||||
|
token: rowOut.token,
|
||||||
|
dedup_object: rowOut.dedup_object,
|
||||||
|
data_format: rowOut.data_format,
|
||||||
|
notes: inputNotes.value
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
if (res.data.result == "ok") {
|
||||||
|
ElMessage({
|
||||||
|
message: '更改成功',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
axios.get('/api/token').then(res => {
|
||||||
|
tableData.value = res.data.result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
ElMessage.error(error.response?.data?.error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteToken = (row: any) => {
|
const deleteToken = (row: any) => {
|
||||||
@@ -115,9 +186,8 @@ const deleteToken = (row: any) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputPassWord = ref('')
|
|
||||||
const checkPassword = () => {
|
const checkPassword = () => {
|
||||||
if (inputPassWord.value == "admin") {
|
if (inputPassWord.value == "haha") {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '密码正确',
|
message: '密码正确',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@@ -127,7 +197,6 @@ const checkPassword = () => {
|
|||||||
ElMessage.error('密码错误')
|
ElMessage.error('密码错误')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -135,7 +204,7 @@ const checkPassword = () => {
|
|||||||
<div v-if="!useCounterStore().isAdmin" style="margin: auto auto; max-width: 400px">
|
<div v-if="!useCounterStore().isAdmin" style="margin: auto auto; max-width: 400px">
|
||||||
<el-alert title="您没有权限访问此页面,输入管理员密码" type="error" :closable="false" show-icon/>
|
<el-alert title="您没有权限访问此页面,输入管理员密码" type="error" :closable="false" show-icon/>
|
||||||
<p></p>
|
<p></p>
|
||||||
<el-input v-model="inputPassWord" style="width: 400px" placeholder="请输入管理员密码"/>
|
<el-input v-model="inputPassWord" style="width: 400px" placeholder="请输入管理员密码" @change="checkPassword"/>
|
||||||
<p></p>
|
<p></p>
|
||||||
<el-button type="primary" @click="checkPassword">确认</el-button>
|
<el-button type="primary" @click="checkPassword">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -143,25 +212,36 @@ const checkPassword = () => {
|
|||||||
<!--管理员-->
|
<!--管理员-->
|
||||||
<div v-if="useCounterStore().isAdmin">
|
<div v-if="useCounterStore().isAdmin">
|
||||||
<!--添加Token-->
|
<!--添加Token-->
|
||||||
<el-input v-model="input" style="width: 200px" placeholder="请输入Token名称"/>
|
<el-input v-model="input" style="width: 150px" placeholder="请输入Token名称"/>
|
||||||
<el-select v-model="value" placeholder="选择去重对象" style="width: 200px">
|
<el-select v-model="value" placeholder="选择去重对象" style="width: 150px">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<el-select v-model="dataFormat" placeholder="选择数据格式" style="width: 280px">
|
||||||
|
<el-option
|
||||||
|
v-for="item in dataFormatOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<el-input v-model="inputNotes" style="width: 200px" placeholder="请输入备注"/>
|
||||||
<el-button type="primary" @click="addToken">添加Token</el-button>
|
<el-button type="primary" @click="addToken">添加Token</el-button>
|
||||||
|
|
||||||
<!--Token列表-->
|
<!--Token列表-->
|
||||||
<el-table :data="tableData" style="width: 100%">
|
<el-table :data="tableData" stripe style="width: 100%">
|
||||||
<el-table-column prop="token" label="Token" width="180"/>
|
<el-table-column prop="token" label="Token" width="150"/>
|
||||||
<el-table-column prop="dedup_object" label="去重对象" width="180"/>
|
<el-table-column prop="dedup_object" label="去重对象" width="150"/>
|
||||||
|
<el-table-column prop="data_format" label="上传数据格式" width="280"/>
|
||||||
|
<el-table-column prop="notes" label="备注" width="200"/>
|
||||||
<el-table-column label="操作">
|
<el-table-column label="操作">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button @click="viewDetails(scope.row)">查看详细</el-button>
|
<el-button @click="viewDetails(scope.row)">查看详细</el-button>
|
||||||
<el-button @click="dialogDedupObjectVisible(scope.row)" type="primary">更改去重对象</el-button>
|
<el-button @click="dialogDedupObjectVisible(scope.row)" type="primary">更改去重对象</el-button>
|
||||||
|
<el-button @click="dialogDataFormatVisible(scope.row)" type="primary">更改数据格式</el-button>
|
||||||
|
<el-button @click="dialogNotesVisible(scope.row)" type="primary">更改备注</el-button>
|
||||||
<el-popconfirm
|
<el-popconfirm
|
||||||
width="180"
|
width="180"
|
||||||
title="确认删除此Token吗"
|
title="确认删除此Token吗"
|
||||||
@@ -183,7 +263,6 @@ const checkPassword = () => {
|
|||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
@@ -193,6 +272,30 @@ const checkPassword = () => {
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog v-model="dataFormatVisible" title="更改数据格式" width="400">
|
||||||
|
<el-select v-model="dataFormat" placeholder="选择数据格式" style="width: 280px">
|
||||||
|
<el-option
|
||||||
|
v-for="item in dataFormatOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="updateDataFormat">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog v-model="NotesVisible" title="更改备注" width="400">
|
||||||
|
<el-input v-model="inputNotes" style="width: 200px" placeholder="请输入备注"/>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="updateNotes">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user