mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-16 04:13:12 +00:00
chore: add shortcut.description
field
This commit is contained in:
parent
48fb6018c0
commit
4c099e7699
@ -31,9 +31,10 @@ type Shortcut struct {
|
||||
RowStatus RowStatus `json:"rowStatus"`
|
||||
|
||||
// Domain specific fields
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Visibility Visibility `json:"visibility"`
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Description string `json:"description"`
|
||||
Visibility Visibility `json:"visibility"`
|
||||
}
|
||||
|
||||
type ShortcutCreate struct {
|
||||
@ -42,9 +43,10 @@ type ShortcutCreate struct {
|
||||
WorkspaceID int `json:"workspaceId"`
|
||||
|
||||
// Domain specific fields
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Visibility Visibility `json:"visibility"`
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Description string `json:"description"`
|
||||
Visibility Visibility `json:"visibility"`
|
||||
}
|
||||
|
||||
type ShortcutPatch struct {
|
||||
@ -54,9 +56,10 @@ type ShortcutPatch struct {
|
||||
RowStatus *RowStatus `json:"rowStatus"`
|
||||
|
||||
// Domain specific fields
|
||||
Name *string `json:"name"`
|
||||
Link *string `json:"link"`
|
||||
Visibility *Visibility `json:"visibility"`
|
||||
Name *string `json:"name"`
|
||||
Link *string `json:"link"`
|
||||
Description *string `json:"description"`
|
||||
Visibility *Visibility `json:"visibility"`
|
||||
}
|
||||
|
||||
type ShortcutFind struct {
|
||||
@ -67,9 +70,10 @@ type ShortcutFind struct {
|
||||
WorkspaceID *int `json:"workspaceId"`
|
||||
|
||||
// Domain specific fields
|
||||
Name *string `json:"name"`
|
||||
Link *string `json:"link"`
|
||||
Visibility *Visibility `json:"visibility"`
|
||||
Name *string `json:"name"`
|
||||
Link *string `json:"link"`
|
||||
Description *string `json:"description"`
|
||||
Visibility *Visibility `json:"visibility"`
|
||||
}
|
||||
|
||||
type ShortcutDelete struct {
|
||||
|
@ -115,6 +115,7 @@ CREATE TABLE shortcut (
|
||||
workspace_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
link TEXT NOT NULL DEFAULT '',
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
visibility TEXT NOT NULL CHECK (visibility IN ('PRIVATE', 'WORKSPACE')) DEFAULT 'PRIVATE',
|
||||
FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(workspace_id) REFERENCES workspace(id) ON DELETE CASCADE
|
||||
|
@ -55,7 +55,8 @@ CREATE TABLE user (
|
||||
row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL',
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
name TEXT NOT NULL,
|
||||
password_hash TEXT NOT NULL
|
||||
password_hash TEXT NOT NULL,
|
||||
open_id TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
INSERT INTO
|
||||
@ -75,6 +76,12 @@ WHERE
|
||||
rowid = old.rowid;
|
||||
END;
|
||||
|
||||
CREATE INDEX user_id_index ON user(id);
|
||||
|
||||
CREATE UNIQUE INDEX user_email_index ON user(email);
|
||||
|
||||
CREATE UNIQUE INDEX user_open_id_index ON user(open_id);
|
||||
|
||||
-- user_setting
|
||||
CREATE TABLE user_setting (
|
||||
user_id INTEGER NOT NULL,
|
||||
@ -108,6 +115,7 @@ CREATE TABLE shortcut (
|
||||
workspace_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
link TEXT NOT NULL DEFAULT '',
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
visibility TEXT NOT NULL CHECK (visibility IN ('PRIVATE', 'WORKSPACE')) DEFAULT 'PRIVATE',
|
||||
FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(workspace_id) REFERENCES workspace(id) ON DELETE CASCADE
|
||||
|
@ -4,6 +4,7 @@ INSERT INTO
|
||||
`workspace_id`,
|
||||
`name`,
|
||||
`link`,
|
||||
`description`,
|
||||
`visibility`
|
||||
)
|
||||
VALUES
|
||||
@ -12,5 +13,6 @@ VALUES
|
||||
11,
|
||||
'baidu',
|
||||
'https://baidu.com',
|
||||
'百度搜索',
|
||||
'WORKSPACE'
|
||||
);
|
||||
|
@ -23,9 +23,10 @@ type shortcutRaw struct {
|
||||
RowStatus api.RowStatus
|
||||
|
||||
// Domain specific fields
|
||||
Name string
|
||||
Link string
|
||||
Visibility api.Visibility
|
||||
Name string
|
||||
Link string
|
||||
Description string
|
||||
Visibility api.Visibility
|
||||
}
|
||||
|
||||
func (raw *shortcutRaw) toShortcut() *api.Shortcut {
|
||||
@ -38,9 +39,10 @@ func (raw *shortcutRaw) toShortcut() *api.Shortcut {
|
||||
WorkspaceID: raw.WorkspaceID,
|
||||
RowStatus: raw.RowStatus,
|
||||
|
||||
Name: raw.Name,
|
||||
Link: raw.Link,
|
||||
Visibility: raw.Visibility,
|
||||
Name: raw.Name,
|
||||
Link: raw.Link,
|
||||
Description: raw.Description,
|
||||
Visibility: raw.Visibility,
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,13 +180,14 @@ func createShortcut(ctx context.Context, tx *sql.Tx, create *api.ShortcutCreate)
|
||||
workspace_id,
|
||||
name,
|
||||
link,
|
||||
description,
|
||||
visibility
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
RETURNING id, creator_id, created_ts, updated_ts, workspace_id, row_status, name, link, visibility
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
RETURNING id, creator_id, created_ts, updated_ts, workspace_id, row_status, name, link, description, visibility
|
||||
`
|
||||
var shortcutRaw shortcutRaw
|
||||
if err := tx.QueryRowContext(ctx, query, create.CreatorID, create.WorkspaceID, create.Name, create.Link, create.Visibility).Scan(
|
||||
if err := tx.QueryRowContext(ctx, query, create.CreatorID, create.WorkspaceID, create.Name, create.Link, create.Description, create.Visibility).Scan(
|
||||
&shortcutRaw.ID,
|
||||
&shortcutRaw.CreatorID,
|
||||
&shortcutRaw.CreatedTs,
|
||||
@ -193,6 +196,7 @@ func createShortcut(ctx context.Context, tx *sql.Tx, create *api.ShortcutCreate)
|
||||
&shortcutRaw.RowStatus,
|
||||
&shortcutRaw.Name,
|
||||
&shortcutRaw.Link,
|
||||
&shortcutRaw.Description,
|
||||
&shortcutRaw.Visibility,
|
||||
); err != nil {
|
||||
return nil, FormatError(err)
|
||||
@ -210,6 +214,9 @@ func patchShortcut(ctx context.Context, tx *sql.Tx, patch *api.ShortcutPatch) (*
|
||||
if v := patch.Link; v != nil {
|
||||
set, args = append(set, "link = ?"), append(args, *v)
|
||||
}
|
||||
if v := patch.Description; v != nil {
|
||||
set, args = append(set, "description = ?"), append(args, *v)
|
||||
}
|
||||
if v := patch.Visibility; v != nil {
|
||||
set, args = append(set, "visibility = ?"), append(args, *v)
|
||||
}
|
||||
@ -220,7 +227,7 @@ func patchShortcut(ctx context.Context, tx *sql.Tx, patch *api.ShortcutPatch) (*
|
||||
UPDATE shortcut
|
||||
SET ` + strings.Join(set, ", ") + `
|
||||
WHERE id = ?
|
||||
RETURNING id, creator_id, created_ts, updated_ts, workspace_id, row_status, name, link, visibility
|
||||
RETURNING id, creator_id, created_ts, updated_ts, workspace_id, row_status, name, link, description, visibility
|
||||
`
|
||||
var shortcutRaw shortcutRaw
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(
|
||||
@ -232,6 +239,7 @@ func patchShortcut(ctx context.Context, tx *sql.Tx, patch *api.ShortcutPatch) (*
|
||||
&shortcutRaw.RowStatus,
|
||||
&shortcutRaw.Name,
|
||||
&shortcutRaw.Link,
|
||||
&shortcutRaw.Description,
|
||||
&shortcutRaw.Visibility,
|
||||
); err != nil {
|
||||
return nil, FormatError(err)
|
||||
@ -258,6 +266,9 @@ func findShortcutList(ctx context.Context, tx *sql.Tx, find *api.ShortcutFind) (
|
||||
if v := find.Link; v != nil {
|
||||
where, args = append(where, "link = ?"), append(args, *v)
|
||||
}
|
||||
if v := find.Description; v != nil {
|
||||
where, args = append(where, "description = ?"), append(args, *v)
|
||||
}
|
||||
if v := find.Visibility; v != nil {
|
||||
where, args = append(where, "visibility = ?"), append(args, *v)
|
||||
}
|
||||
@ -272,6 +283,7 @@ func findShortcutList(ctx context.Context, tx *sql.Tx, find *api.ShortcutFind) (
|
||||
row_status,
|
||||
name,
|
||||
link,
|
||||
description,
|
||||
visibility
|
||||
FROM shortcut
|
||||
WHERE `+strings.Join(where, " AND ")+`
|
||||
@ -295,6 +307,7 @@ func findShortcutList(ctx context.Context, tx *sql.Tx, find *api.ShortcutFind) (
|
||||
&shortcutRaw.RowStatus,
|
||||
&shortcutRaw.Name,
|
||||
&shortcutRaw.Link,
|
||||
&shortcutRaw.Description,
|
||||
&shortcutRaw.Visibility,
|
||||
); err != nil {
|
||||
return nil, FormatError(err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user