6
6
"github.com/kataras/iris/v12"
7
7
"github.com/mlogclub/simple/sqls"
8
8
"github.com/mlogclub/simple/web"
9
- "github.com/mlogclub/simple/web/params"
10
9
11
10
"bbs-go/internal/models"
12
11
"bbs-go/internal/services"
@@ -16,60 +15,37 @@ type LinkController struct {
16
15
Ctx iris.Context
17
16
}
18
17
19
- func (c * LinkController ) GetBy (id int64 ) * web.JsonResult {
20
- link := services .LinkService .Get (id )
21
- if link == nil || link .Status == constants .StatusDeleted {
22
- return web .JsonErrorMsg ("数据不存在" )
23
- }
24
- return web .JsonData (c .buildLink (* link ))
25
- }
26
-
27
18
// 列表
28
19
func (c * LinkController ) GetList () * web.JsonResult {
29
20
links := services .LinkService .Find (sqls .NewCnd ().
30
21
Eq ("status" , constants .StatusOk ).Asc ("id" ))
31
22
32
- var itemList []map [string ]interface {}
23
+ var itemList []map [string ]any
33
24
for _ , v := range links {
34
25
itemList = append (itemList , c .buildLink (v ))
35
26
}
36
27
return web .JsonData (itemList )
37
28
}
38
29
39
- // 列表
40
- func (c * LinkController ) GetLinks () * web.JsonResult {
41
- page := params .FormValueIntDefault (c .Ctx , "page" , 1 )
42
-
43
- links , paging := services .LinkService .FindPageByCnd (sqls .NewCnd ().
44
- Eq ("status" , constants .StatusOk ).Page (page , 20 ).Asc ("id" ))
45
-
46
- var itemList []map [string ]interface {}
47
- for _ , v := range links {
48
- itemList = append (itemList , c .buildLink (v ))
49
- }
50
- return web .JsonPageData (itemList , paging )
51
- }
52
-
53
30
// 前10个链接
54
31
func (c * LinkController ) GetToplinks () * web.JsonResult {
55
32
links := services .LinkService .Find (sqls .NewCnd ().
56
33
Eq ("status" , constants .StatusOk ).Limit (10 ).Asc ("id" ))
57
34
58
- var itemList []map [string ]interface {}
35
+ var itemList []map [string ]any
59
36
for _ , v := range links {
60
37
itemList = append (itemList , c .buildLink (v ))
61
38
}
62
39
return web .JsonData (itemList )
63
40
}
64
41
65
- func (c * LinkController ) buildLink (link models.Link ) map [string ]interface {} {
66
- return map [string ]interface {} {
42
+ func (c * LinkController ) buildLink (link models.Link ) map [string ]any {
43
+ return map [string ]any {
67
44
"id" : link .Id ,
68
45
"linkId" : link .Id ,
69
46
"url" : link .Url ,
70
47
"title" : link .Title ,
71
48
"summary" : link .Summary ,
72
- "logo" : link .Logo ,
73
49
"createTime" : link .CreateTime ,
74
50
}
75
51
}
0 commit comments