mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
@ -67,6 +67,9 @@ type MemoPatch struct {
|
|||||||
// Domain specific fields
|
// Domain specific fields
|
||||||
Content *string `json:"content"`
|
Content *string `json:"content"`
|
||||||
Visibility *Visibility `json:"visibility"`
|
Visibility *Visibility `json:"visibility"`
|
||||||
|
|
||||||
|
// Related fields
|
||||||
|
ResourceIDList []int `json:"resourceIdList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MemoFind struct {
|
type MemoFind struct {
|
||||||
|
@ -116,6 +116,20 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to patch memo").SetInternal(err)
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to patch memo").SetInternal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, resourceID := range memoPatch.ResourceIDList {
|
||||||
|
if _, err := s.Store.UpsertMemoResource(ctx, &api.MemoResourceUpsert{
|
||||||
|
MemoID: memo.ID,
|
||||||
|
ResourceID: resourceID,
|
||||||
|
}); err != nil {
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to upsert memo resource").SetInternal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memo, err = s.Store.ComposeMemo(ctx, memo)
|
||||||
|
if err != nil {
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to compose memo").SetInternal(err)
|
||||||
|
}
|
||||||
|
|
||||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
|
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
|
||||||
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(memo)); err != nil {
|
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(memo)); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to encode memo response").SetInternal(err)
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to encode memo response").SetInternal(err)
|
||||||
|
@ -164,6 +164,7 @@ const MemoEditor: React.FC = () => {
|
|||||||
await memoService.patchMemo({
|
await memoService.patchMemo({
|
||||||
id: prevMemo.id,
|
id: prevMemo.id,
|
||||||
content,
|
content,
|
||||||
|
resourceIdList: state.resourceList.map((resource) => resource.id),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
editorStateService.clearEditMemo();
|
editorStateService.clearEditMemo();
|
||||||
|
1
web/src/types/modules/memo.d.ts
vendored
1
web/src/types/modules/memo.d.ts
vendored
@ -30,6 +30,7 @@ interface MemoPatch {
|
|||||||
createdTs?: TimeStamp;
|
createdTs?: TimeStamp;
|
||||||
rowStatus?: RowStatus;
|
rowStatus?: RowStatus;
|
||||||
content?: string;
|
content?: string;
|
||||||
|
resourceIdList?: ResourceId[];
|
||||||
visibility?: Visibility;
|
visibility?: Visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user