chore: update find memo api

pull/2407/head
Steven 1 year ago
parent 952539f817
commit 6f2ca6c87a

@ -473,6 +473,7 @@ func (s *APIV1Service) GetMemoStats(c echo.Context) error {
findMemoMessage := &store.FindMemo{
RowStatus: &normalStatus,
HasParent: &hasParentFlag,
ExcludeContent: true,
}
if creatorID, err := util.ConvertStringToInt32(c.QueryParam("creatorId")); err == nil {
findMemoMessage.CreatorID = &creatorID

@ -104,16 +104,22 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
}
orders = append(orders, "id DESC")
fields := []string{
`memo.id AS id`,
`memo.creator_id AS creator_id`,
`memo.created_ts AS created_ts`,
`memo.updated_ts AS updated_ts`,
`memo.row_status AS row_status`,
`memo.visibility AS visibility`,
}
if !find.ExcludeContent {
fields = append(fields, `memo.content AS content`)
}
query := `
SELECT
memo.id AS id,
memo.creator_id AS creator_id,
memo.created_ts AS created_ts,
memo.updated_ts AS updated_ts,
memo.row_status AS row_status,
memo.content AS content,
memo.visibility AS visibility,
CASE WHEN memo_organizer.pinned = 1 THEN 1 ELSE 0 END AS pinned,
` + strings.Join(fields, ", ") + `
CASE WHEN mo.pinned = 1 THEN 1 ELSE 0 END AS pinned,
(
SELECT
related_memo_id
@ -126,7 +132,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
GROUP_CONCAT(resource.id) AS resource_id_list,
(
SELECT
GROUP_CONCAT(memo_id || ':' || related_memo_id || ':' || type)
GROUP_CONCAT(memo_relation.memo_id || ':' || memo_relation.related_memo_id || ':' || memo_relation.type)
FROM
memo_relation
WHERE
@ -135,13 +141,12 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
FROM
memo
LEFT JOIN
memo_organizer ON memo.id = memo_organizer.memo_id
memo_organizer mo ON memo.id = mo.memo_id
LEFT JOIN
resource ON memo.id = resource.memo_id
WHERE ` + strings.Join(where, " AND ") + `
GROUP BY memo.id
ORDER BY ` + strings.Join(orders, ", ") + `
`
ORDER BY ` + strings.Join(orders, ", ")
if find.Limit != nil {
query = fmt.Sprintf("%s LIMIT %d", query, *find.Limit)
if find.Offset != nil {
@ -160,19 +165,19 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
var memo store.Memo
var memoResourceIDList sql.NullString
var memoRelationList sql.NullString
if err := rows.Scan(
dests := []any{
&memo.ID,
&memo.CreatorID,
&memo.CreatedTs,
&memo.UpdatedTs,
&memo.RowStatus,
&memo.Content,
&memo.Visibility,
&memo.Pinned,
&memo.ParentID,
&memoResourceIDList,
&memoRelationList,
); err != nil {
}
if !find.ExcludeContent {
dests = append(dests, &memo.Content)
}
dests = append(dests, &memo.Pinned, &memo.ParentID, &memoResourceIDList, &memoRelationList)
if err := rows.Scan(dests...); err != nil {
return nil, err
}

@ -64,6 +64,7 @@ type FindMemo struct {
VisibilityList []Visibility
Pinned *bool
HasParent *bool
ExcludeContent bool
// Pagination
Limit *int

@ -104,7 +104,7 @@ const MemoDetail = () => {
<>
<section className="relative top-0 w-full min-h-full overflow-x-hidden bg-zinc-100 dark:bg-zinc-900">
<div className="relative w-full h-auto mx-auto flex flex-col justify-start items-center bg-white dark:bg-zinc-700">
<div className="w-full flex flex-col justify-start items-center py-8">
<div className="w-full flex flex-col justify-start items-center pt-16 pb-8">
<UserAvatar className="!w-20 h-auto mb-2 drop-shadow" avatarUrl={systemStatus.customizedProfile.logoUrl} />
<p className="text-3xl text-black opacity-80 dark:text-gray-200">{systemStatus.customizedProfile.name}</p>
</div>
@ -186,7 +186,7 @@ const MemoDetail = () => {
</div>
</div>
</div>
<div className="py-6 w-full border-t dark:border-t-zinc-700">
<div className="pt-8 pb-16 w-full border-t dark:border-t-zinc-700">
<div className="relative mx-auto flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 gap-y-1">
{comments.length === 0 ? (
<div className="w-full flex flex-col justify-center items-center py-6 mb-2">

Loading…
Cancel
Save