Compare commits
3 Commits
0992b02880
...
a505f2ddc9
| Author | SHA1 | Date | |
|---|---|---|---|
| a505f2ddc9 | |||
| 42cfe0dc0f | |||
| 2c8e25bdf8 |
@@ -26,6 +26,11 @@ func CreateTokenHandler(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//检查Token是否存在
|
||||||
|
if db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "创建Token失败,Token已经存在"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//创建Token
|
//创建Token
|
||||||
err := db.CreateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
err := db.CreateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
||||||
@@ -49,6 +54,11 @@ func UpdateTokenHandler(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//检查Token是否存在
|
||||||
|
if !db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "更改失败,Token不存在"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err := db.UpdateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
err := db.UpdateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -67,6 +77,11 @@ func DeleteTokenHandler(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//检查Token是否存在
|
||||||
|
if !db.CheckToken(input.Token) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "删除Token失败,Token不存在"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err := db.DeleteToken(input.Token)
|
err := db.DeleteToken(input.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -85,6 +100,11 @@ 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 {
|
||||||
@@ -125,6 +145,11 @@ func DeleteTokenInfoHandler(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失败,Token不存在"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//检查token是否存在
|
//检查token是否存在
|
||||||
_, err := db.GetDedupObject(input.Token)
|
_, err := db.GetDedupObject(input.Token)
|
||||||
|
|||||||
10
db/local.go
10
db/local.go
@@ -32,6 +32,16 @@ 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
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<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>dypid</title>
|
<title>抖音数据去重</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user