cyi-box: Memphis-style toolbox admin platform
Go(fun)+SQLite backend, Vue 3 frontend. Modules: dashboard, pay gateway (Epay-compatible + CDK stock), license/card system (per-app appid, domain binding), AI memory bank with built-in MCP server (/mcp, FTS5 search, signed read links), server SSH monitor + terminal + SFTP, proxy pool with protocol-level alive checks, DB manager (mysql/pg/sqlite + SQL autocomplete + import/export), disk share, vault (AES-GCM + TOTP), bookmarks, dev tools. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cyi-cc/cyi-box/backend/internal/db"
|
||||
)
|
||||
|
||||
type Bookmark struct {
|
||||
Id int64
|
||||
UserID int64
|
||||
Title string
|
||||
Url string
|
||||
Icon string
|
||||
Sort int64
|
||||
CreatedAt int64
|
||||
}
|
||||
|
||||
func bookmarkFromRow(b db.Bookmark) Bookmark {
|
||||
return Bookmark{
|
||||
Id: b.ID, UserID: b.UserID, Title: b.Title, Url: b.Url,
|
||||
Icon: b.Icon, Sort: b.Sort, CreatedAt: b.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Store) ListBookmarks(userID int64) ([]Bookmark, error) {
|
||||
rows, err := s.q.ListBookmarks(storeCtx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items := make([]Bookmark, 0, len(rows))
|
||||
for _, r := range rows {
|
||||
items = append(items, bookmarkFromRow(r))
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func (s *Store) SaveBookmark(b *Bookmark) error {
|
||||
if b.Id > 0 {
|
||||
n, err := s.q.UpdateBookmark(storeCtx, db.UpdateBookmarkParams{
|
||||
Title: b.Title, Url: b.Url, Icon: b.Icon, Sort: b.Sort,
|
||||
ID: b.Id, UserID: b.UserID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
return ErrNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
id, err := s.q.InsertBookmark(storeCtx, db.InsertBookmarkParams{
|
||||
UserID: b.UserID, Title: b.Title, Url: b.Url, Icon: b.Icon,
|
||||
Sort: b.Sort, CreatedAt: now,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.Id, b.CreatedAt = id, now
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Store) DeleteBookmark(userID, id int64) error {
|
||||
n, err := s.q.DeleteBookmark(storeCtx, db.DeleteBookmarkParams{UserID: userID, ID: id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
return ErrNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user