Skip to content

Commit d86fe49

Browse files
committed
feat: 优化句子接口
1 parent ba1cfaf commit d86fe49

File tree

5 files changed

+33
-54
lines changed

5 files changed

+33
-54
lines changed

api/other/app/other.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,12 @@ type (
4545
)
4646

4747
type (
48-
PoemReq struct {
49-
g.Meta `path:"poem" method:"get" sm:"随机查询诗词" tags:"app"`
48+
SentenceReq struct {
49+
g.Meta `path:"poem" method:"get" sm:"随机查询句子组" tags:"app"`
5050
}
5151

52-
PoemRes struct {
53-
Poem string `json:"poem"`
54-
}
55-
)
56-
57-
type (
58-
SlangReq struct {
59-
g.Meta `path:"slang" method:"get" sm:"随机查询俚语" tags:"app"`
60-
}
61-
62-
SlangRes struct {
52+
SentenceRes struct {
53+
Poem string `json:"poem"`
6354
Slang string `json:"slang"`
6455
}
6556
)

api/other/other.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/other/other_app_poem.go

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package other
2+
3+
import (
4+
"context"
5+
6+
"github.com/oldme-git/oldme-api/internal/logic/sentence"
7+
"github.com/oldme-git/oldme-api/utility/uinit"
8+
9+
"github.com/oldme-git/oldme-api/api/other/app"
10+
)
11+
12+
func (c *ControllerApp) Sentence(ctx context.Context, req *app.SentenceReq) (res *app.SentenceRes, err error) {
13+
poem, err := sentence.Text(ctx, uinit.PoemTagId)
14+
if err != nil {
15+
return nil, err
16+
}
17+
18+
slang, err := sentence.Text(ctx, uinit.SlangTagId)
19+
if err != nil {
20+
return nil, err
21+
}
22+
23+
return &app.SentenceRes{
24+
Poem: poem.Sentence,
25+
Slang: slang.Sentence,
26+
}, nil
27+
28+
}

internal/controller/other/other_app_slang.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)