feat(token): 添加备注功能和相关接口
All checks were successful
构建Docker镜像 / build-and-deploy (push) Successful in 1m41s
All checks were successful
构建Docker镜像 / build-and-deploy (push) Successful in 1m41s
This commit is contained in:
@@ -18,6 +18,7 @@ func CreateTokenHandler(c *gin.Context) {
|
|||||||
Token string `form:"token" binding:"required"`
|
Token string `form:"token" binding:"required"`
|
||||||
DedupObject string `form:"dedup_object" binding:"required"`
|
DedupObject string `form:"dedup_object" binding:"required"`
|
||||||
DataFormat string `form:"data_format" binding:"required"`
|
DataFormat string `form:"data_format" binding:"required"`
|
||||||
|
Notes string `form:"notes" binding:"required"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindQuery(&input); err != nil {
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
@@ -25,7 +26,7 @@ func CreateTokenHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创建Token
|
//创建Token
|
||||||
err := db.CreateToken(input.Token, input.DedupObject, input.DataFormat)
|
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
|
||||||
@@ -40,13 +41,14 @@ func UpdateTokenHandler(c *gin.Context) {
|
|||||||
Token string `form:"token" binding:"required"`
|
Token string `form:"token" binding:"required"`
|
||||||
DedupObject string `form:"dedup_object" binding:"required"`
|
DedupObject string `form:"dedup_object" binding:"required"`
|
||||||
DataFormat string `form:"data_format" binding:"required"`
|
DataFormat string `form:"data_format" binding:"required"`
|
||||||
|
Notes string `form:"notes" binding:"required"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindQuery(&input); err != nil {
|
if err := c.ShouldBindQuery(&input); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.UpdateToken(input.Token, input.DedupObject, input.DataFormat)
|
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
|
||||||
|
@@ -13,6 +13,7 @@ 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"`
|
DataFormat string `json:"data_format"`
|
||||||
|
Notes string `json:"notes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitLocalDB() {
|
func InitLocalDB() {
|
||||||
@@ -36,7 +37,7 @@ func ListToken() []Token {
|
|||||||
return localDB
|
return localDB
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateToken(token string, dedupObject string, dataFormat 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 {
|
||||||
@@ -44,7 +45,7 @@ func CreateToken(token string, dedupObject string, dataFormat string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a := append(localDB, Token{token, dedupObject, dataFormat})
|
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
|
||||||
@@ -56,13 +57,14 @@ func CreateToken(token string, dedupObject string, dataFormat string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateToken(token string, dedupObject string, dataFormat 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].DataFormat = dataFormat
|
||||||
|
localDB[i].Notes = Notes
|
||||||
|
|
||||||
marshal, err := json.Marshal(localDB)
|
marshal, err := json.Marshal(localDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -45,7 +45,8 @@ const addToken = () => {
|
|||||||
params: {
|
params: {
|
||||||
token: input.value,
|
token: input.value,
|
||||||
dedup_object: value.value,
|
dedup_object: value.value,
|
||||||
data_format: dataFormat.value
|
data_format: dataFormat.value,
|
||||||
|
notes: inputNotes.value,
|
||||||
}
|
}
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.data.result == "ok") {
|
if (response.data.result == "ok") {
|
||||||
@@ -84,7 +85,8 @@ const updateDedupObject = () => {
|
|||||||
params: {
|
params: {
|
||||||
token: rowOut.token,
|
token: rowOut.token,
|
||||||
dedup_object: value.value,
|
dedup_object: value.value,
|
||||||
data_format: rowOut.data_format
|
data_format: rowOut.data_format,
|
||||||
|
notes: rowOut.notes,
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.result == "ok") {
|
if (res.data.result == "ok") {
|
||||||
@@ -112,7 +114,38 @@ const updateDataFormat = () => {
|
|||||||
params: {
|
params: {
|
||||||
token: rowOut.token,
|
token: rowOut.token,
|
||||||
dedup_object: rowOut.dedup_object,
|
dedup_object: rowOut.dedup_object,
|
||||||
data_format: dataFormat.value
|
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 inputNotes = ref("")
|
||||||
|
const NotesVisible = ref(false)
|
||||||
|
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 => {
|
}).then(res => {
|
||||||
if (res.data.result == "ok") {
|
if (res.data.result == "ok") {
|
||||||
@@ -191,6 +224,7 @@ const checkPassword = () => {
|
|||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</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列表-->
|
||||||
@@ -198,11 +232,13 @@ const checkPassword = () => {
|
|||||||
<el-table-column prop="token" label="Token" width="150"/>
|
<el-table-column prop="token" label="Token" width="150"/>
|
||||||
<el-table-column prop="dedup_object" label="去重对象" width="150"/>
|
<el-table-column prop="dedup_object" label="去重对象" width="150"/>
|
||||||
<el-table-column prop="data_format" label="上传数据格式" width="280"/>
|
<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="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吗"
|
||||||
@@ -248,6 +284,15 @@ const checkPassword = () => {
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</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