feat(token): 添加备注功能和相关接口
All checks were successful
构建Docker镜像 / build-and-deploy (push) Successful in 1m41s

This commit is contained in:
2025-09-06 17:43:20 +08:00
parent 333882c9e0
commit b6ce840400
3 changed files with 57 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ type Token struct {
Token string `json:"token"`
DedupObject string `json:"dedup_object"`
DataFormat string `json:"data_format"`
Notes string `json:"notes"`
}
func InitLocalDB() {
@@ -36,7 +37,7 @@ func ListToken() []Token {
return localDB
}
func CreateToken(token string, dedupObject string, dataFormat string) error {
func CreateToken(token string, dedupObject string, dataFormat string, Notes string) error {
InitLocalDB()
for _, t := range localDB {
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)
if err != nil {
return err
@@ -56,13 +57,14 @@ func CreateToken(token string, dedupObject string, dataFormat string) error {
return nil
}
func UpdateToken(token string, dedupObject string, dataFormat string) error {
func UpdateToken(token string, dedupObject string, dataFormat string, Notes string) error {
InitLocalDB()
for i, t := range localDB {
if t.Token == token {
localDB[i].DedupObject = dedupObject
localDB[i].DataFormat = dataFormat
localDB[i].Notes = Notes
marshal, err := json.Marshal(localDB)
if err != nil {