mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-18 21:19:44 +00:00
chore: update list shortcut api
This commit is contained in:
parent
1084381bbf
commit
f0334d5755
@ -83,7 +83,7 @@ func (s *APIV1Service) registerShortcutRoutes(g *echo.Group) {
|
|||||||
Name: strings.ToLower(create.Name),
|
Name: strings.ToLower(create.Name),
|
||||||
Link: create.Link,
|
Link: create.Link,
|
||||||
Description: create.Description,
|
Description: create.Description,
|
||||||
Visibility: convertVisibilityToStore(create.Visibility),
|
Visibility: store.Visibility(create.Visibility.String()),
|
||||||
Tag: strings.Join(create.Tags, " "),
|
Tag: strings.Join(create.Tags, " "),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -176,13 +176,6 @@ func (s *APIV1Service) registerShortcutRoutes(g *echo.Group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
find := &store.FindShortcut{}
|
find := &store.FindShortcut{}
|
||||||
if creatorIDStr := c.QueryParam("creatorId"); creatorIDStr != "" {
|
|
||||||
creatorID, err := strconv.Atoi(creatorIDStr)
|
|
||||||
if err != nil {
|
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("unwanted creator id string: %s", creatorIDStr))
|
|
||||||
}
|
|
||||||
find.CreatorID = &creatorID
|
|
||||||
}
|
|
||||||
if tag := c.QueryParam("tag"); tag != "" {
|
if tag := c.QueryParam("tag"); tag != "" {
|
||||||
find.Tag = &tag
|
find.Tag = &tag
|
||||||
}
|
}
|
||||||
@ -325,19 +318,6 @@ func (s *APIV1Service) composeShortcut(ctx context.Context, shortcut *Shortcut)
|
|||||||
return shortcut, nil
|
return shortcut, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertVisibilityToStore(visibility Visibility) store.Visibility {
|
|
||||||
switch visibility {
|
|
||||||
case VisibilityPrivate:
|
|
||||||
return store.VisibilityPrivate
|
|
||||||
case VisibilityWorkspace:
|
|
||||||
return store.VisibilityWorkspace
|
|
||||||
case VisibilityPublic:
|
|
||||||
return store.VisibilityPublic
|
|
||||||
default:
|
|
||||||
return store.VisibilityPrivate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func convertShortcutFromStore(shortcut *store.Shortcut) *Shortcut {
|
func convertShortcutFromStore(shortcut *store.Shortcut) *Shortcut {
|
||||||
tags := []string{}
|
tags := []string{}
|
||||||
if shortcut.Tag != "" {
|
if shortcut.Tag != "" {
|
||||||
|
@ -45,9 +45,6 @@ export function deleteUser(userDelete: UserDelete) {
|
|||||||
|
|
||||||
export function getShortcutList(shortcutFind?: ShortcutFind) {
|
export function getShortcutList(shortcutFind?: ShortcutFind) {
|
||||||
const queryList = [];
|
const queryList = [];
|
||||||
if (shortcutFind?.creatorId) {
|
|
||||||
queryList.push(`creatorId=${shortcutFind.creatorId}`);
|
|
||||||
}
|
|
||||||
if (shortcutFind?.tag) {
|
if (shortcutFind?.tag) {
|
||||||
queryList.push(`tag=${shortcutFind.tag}`);
|
queryList.push(`tag=${shortcutFind.tag}`);
|
||||||
}
|
}
|
||||||
|
1
web/src/types/modules/shortcut.d.ts
vendored
1
web/src/types/modules/shortcut.d.ts
vendored
@ -38,6 +38,5 @@ interface ShortcutPatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ShortcutFind {
|
interface ShortcutFind {
|
||||||
creatorId?: UserId;
|
|
||||||
tag?: string;
|
tag?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user