-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
438 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/oldme-git/oldme-api/internal/model" | ||
"github.com/oldme-git/oldme-api/internal/model/entity" | ||
) | ||
|
||
type CreReq struct { | ||
g.Meta `path:"sentence/create" method:"post" sm:"新增" tags:"句子"` | ||
BookId model.Id `json:"book_id" v:"required"` | ||
TagIds []model.Id `json:"tag_ids"` | ||
Sentence string `json:"sentence" v:"required"` | ||
} | ||
|
||
type CreRes struct { | ||
} | ||
|
||
type UpdReq struct { | ||
g.Meta `path:"sentence/update/{id}" method:"post" sm:"修改" tags:"句子"` | ||
*model.IdInput | ||
BookId model.Id `json:"book_id" v:"required"` | ||
Sentence string `json:"sentence" v:"required"` | ||
} | ||
|
||
type UpdRes struct { | ||
} | ||
|
||
type ShowReq struct { | ||
g.Meta `path:"sentence/show/{id}" method:"get" sm:"查询详情" tags:"句子"` | ||
*model.IdInput | ||
} | ||
|
||
type ShowRes struct { | ||
*entity.Sentence | ||
TagList []entity.Tag `json:"tag_list"` | ||
} | ||
|
||
type DelReq struct { | ||
g.Meta `path:"sentence/delete/{id}" method:"post" sm:"删除" tags:"句子"` | ||
*model.IdInput | ||
} | ||
|
||
type DelRes struct { | ||
} | ||
|
||
type ListReq struct { | ||
g.Meta `path:"sentence/list" method:"get" sm:"查询列表" tags:"句子"` | ||
*model.Paging | ||
BookId model.Id `json:"book_id"` | ||
TagIds []model.Id `json:"tag_ids"` | ||
} | ||
|
||
type ListRes struct { | ||
List []List `json:"list"` | ||
Total uint `json:"total"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package v1 | ||
|
||
import "github.com/oldme-git/oldme-api/internal/model" | ||
|
||
type List struct { | ||
Id model.Id | ||
BookId model.Id `json:"book_id"` | ||
Sentence string `json:"sentence"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// ================================================================================= | ||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. | ||
// ================================================================================= | ||
|
||
package sentence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// ================================================================================= | ||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. | ||
// ================================================================================= | ||
|
||
package sentence | ||
|
||
import ( | ||
"github.com/oldme-git/oldme-api/api/sentence" | ||
) | ||
|
||
type ControllerV1 struct{} | ||
|
||
func NewV1() sentence.ISentenceV1 { | ||
return &ControllerV1{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package sentence | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/oldme-git/oldme-api/internal/logic/sentence" | ||
"github.com/oldme-git/oldme-api/internal/model" | ||
|
||
"github.com/oldme-git/oldme-api/api/sentence/v1" | ||
) | ||
|
||
func (c *ControllerV1) Cre(ctx context.Context, req *v1.CreReq) (res *v1.CreRes, err error) { | ||
err = sentence.Cre(ctx, &model.SentenceInput{ | ||
BookId: req.BookId, | ||
TagIds: req.TagIds, | ||
Sentence: req.Sentence, | ||
}) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package sentence | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/oldme-git/oldme-api/internal/logic/sentence" | ||
|
||
"github.com/oldme-git/oldme-api/api/sentence/v1" | ||
) | ||
|
||
func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) { | ||
err = sentence.Del(ctx, req.Id) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package sentence | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/oldme-git/oldme-api/api/sentence/v1" | ||
"github.com/oldme-git/oldme-api/internal/logic/sentence" | ||
"github.com/oldme-git/oldme-api/internal/model" | ||
) | ||
|
||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) { | ||
if req.Paging == nil { | ||
req.Paging = &model.Paging{ | ||
Page: 1, | ||
Size: 15, | ||
} | ||
} | ||
|
||
var ids []model.Id | ||
// 如果有tagId,根据tagId查询ids | ||
if len(req.TagIds) > 0 { | ||
ids, err = sentence.GetIdsByTagIds(ctx, req.TagIds, uint(req.Paging.Size)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
query := &model.SentenceQuery{ | ||
Paging: *req.Paging, | ||
BookId: req.BookId, | ||
Ids: ids, | ||
} | ||
|
||
data, total, err := sentence.List(ctx, query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var ( | ||
list []v1.List | ||
s string | ||
) | ||
for _, v := range data { | ||
if len(v.Sentence) > 100 { | ||
s = v.Sentence[:100] | ||
} else { | ||
s = v.Sentence | ||
} | ||
list = append(list, v1.List{ | ||
Id: model.Id(v.Id), | ||
BookId: model.Id(v.BookId), | ||
Sentence: s, | ||
}) | ||
} | ||
return &v1.ListRes{ | ||
List: list, | ||
Total: total, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package sentence | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/oldme-git/oldme-api/internal/logic/sentence" | ||
|
||
"github.com/oldme-git/oldme-api/api/sentence/v1" | ||
) | ||
|
||
func (c *ControllerV1) Show(ctx context.Context, req *v1.ShowReq) (res *v1.ShowRes, err error) { | ||
data, err := sentence.Show(ctx, req.Id) | ||
if err != nil { | ||
return nil, err | ||
} | ||
tagList, err := sentence.ShowTag(ctx, req.Id) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &v1.ShowRes{ | ||
Sentence: data, | ||
TagList: tagList, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package sentence | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/oldme-git/oldme-api/internal/logic/sentence" | ||
"github.com/oldme-git/oldme-api/internal/model" | ||
|
||
"github.com/oldme-git/oldme-api/api/sentence/v1" | ||
) | ||
|
||
func (c *ControllerV1) Upd(ctx context.Context, req *v1.UpdReq) (res *v1.UpdRes, err error) { | ||
err = sentence.Upd(ctx, &model.SentenceInput{ | ||
Id: req.Id, | ||
BookId: req.BookId, | ||
Sentence: req.Sentence, | ||
}) | ||
return | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.