@@ -10,7 +10,6 @@ import (
1010 "github.com/oldme-git/oldme-api/internal/model/do"
1111 "github.com/oldme-git/oldme-api/internal/model/entity"
1212 "github.com/oldme-git/oldme-api/internal/utility"
13- "github.com/oldme-git/oldme-api/utility/uinit"
1413)
1514
1615// Cre 创建句子
@@ -214,33 +213,12 @@ func GetIdsByTagIds(ctx context.Context, tagIds []model.Id, p model.Paging) (ids
214213 return
215214}
216215
217- // Saying 随机读取一句话,用于首页展示
218- func Saying (ctx context.Context ) (info * entity.Sentence , err error ) {
216+ // Text 根据 tagId 随机读取一个句子
217+ func Text (ctx context.Context , tagId uint32 ) (info * entity.Sentence , err error ) {
219218 db := dao .SentenceTag .Ctx (ctx ).
220219 Fields ("s_id" ).
220+ Where ("t_id" , tagId ).
221221 OrderRandom ()
222- if uinit .SayingTagId > 0 {
223- db = db .Where ("t_id" , uinit .SayingTagId )
224- }
225-
226- idData , err := db .Limit (1 ).One ()
227- if err != nil {
228- err = utility .Err .Sys (err )
229- }
230- id := model .Id (idData ["s_id" ].Int ())
231- info , err = Show (ctx , id )
232-
233- return
234- }
235-
236- // Poem 随机读取诗词
237- func Poem (ctx context.Context ) (info * entity.Sentence , err error ) {
238- db := dao .SentenceTag .Ctx (ctx ).
239- Fields ("s_id" ).
240- OrderRandom ()
241- if uinit .PoemTagId > 0 {
242- db = db .Where ("t_id" , uinit .PoemTagId )
243- }
244222
245223 idData , err := db .Limit (1 ).One ()
246224 if err != nil {
0 commit comments