小程序一些功能更新
This commit is contained in:
@@ -155,6 +155,7 @@ func NoteDetail(ctx context.Context, req *v1.NoteDetailReq) (*v1.NoteDetailRes,
|
||||
|
||||
// SaveNote 新建(Id=0)或编辑(Id>0)笔记。
|
||||
// 新建计入额度校验;编辑不计入额度(PRD-02 R6-5)。
|
||||
// 标题留空时自动命名为「未命名笔记 YYYY-MM-DD hh:mm:ss」(用户端不强制起名)。
|
||||
func SaveNote(ctx context.Context, req *v1.NoteSaveReq) (*v1.NoteSaveRes, error) {
|
||||
userId := CtxUserId(ctx)
|
||||
_, isMember, err := noteUser(ctx, userId)
|
||||
@@ -172,11 +173,15 @@ func SaveNote(ctx context.Context, req *v1.NoteSaveReq) (*v1.NoteSaveRes, error)
|
||||
if req.IsPinned {
|
||||
pinned = 1
|
||||
}
|
||||
title := strings.TrimSpace(req.Title)
|
||||
if title == "" {
|
||||
title = "未命名笔记 " + now.Format("Y-m-d H:i:s")
|
||||
}
|
||||
|
||||
// 编辑既有笔记:不占用额度
|
||||
if req.Id > 0 {
|
||||
data := g.Map{
|
||||
"title": req.Title,
|
||||
"title": title,
|
||||
"content": req.Content,
|
||||
"tags": tags,
|
||||
"is_pinned": pinned,
|
||||
@@ -217,7 +222,7 @@ func SaveNote(ctx context.Context, req *v1.NoteSaveReq) (*v1.NoteSaveRes, error)
|
||||
}
|
||||
id, err := g.Model(consts.TableNotes).Data(g.Map{
|
||||
"user_id": userId,
|
||||
"title": req.Title,
|
||||
"title": title,
|
||||
"content": req.Content,
|
||||
"tags": tags,
|
||||
"is_pinned": pinned,
|
||||
|
||||
Reference in New Issue
Block a user