Skip to content

Commit 2b772f4

Browse files
committed
feat: 增加部分接口
1 parent 646e105 commit 2b772f4

File tree

9 files changed

+77
-4
lines changed

9 files changed

+77
-4
lines changed

api/tag/tag.go

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

api/tag/v1/tag.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1
33
import (
44
"github.com/gogf/gf/v2/frame/g"
55
"github.com/oldme-git/oldme-api/internal/model"
6+
"github.com/oldme-git/oldme-api/internal/model/entity"
67
)
78

89
type CreReq struct {
@@ -40,3 +41,12 @@ type ListReq struct {
4041
type ListRes struct {
4142
List []List `json:"list"`
4243
}
44+
45+
type ShowReq struct {
46+
g.Meta `path:"tag/show/{id}" method:"get" sm:"查询详情" tags:"标签"`
47+
*model.IdInput
48+
}
49+
50+
type ShowRes struct {
51+
*entity.Tag
52+
}

api/tag_grp/tag_grp.go

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

api/tag_grp/v1/tag_grp.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1
33
import (
44
"github.com/gogf/gf/v2/frame/g"
55
"github.com/oldme-git/oldme-api/internal/model"
6+
"github.com/oldme-git/oldme-api/internal/model/entity"
67
)
78

89
type CreReq struct {
@@ -30,6 +31,15 @@ type DelReq struct {
3031
type DelRes struct {
3132
}
3233

34+
type ShowReq struct {
35+
g.Meta `path:"tag/group/show/{id}" method:"get" sm:"查询详情" tags:"标签分类"`
36+
*model.IdInput
37+
}
38+
39+
type ShowRes struct {
40+
*entity.TagGrp
41+
}
42+
3343
type ListReq struct {
3444
g.Meta `path:"tag/group/list" method:"get" sm:"查询列表" tags:"标签分类"`
3545
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tag
2+
3+
import (
4+
"context"
5+
6+
"github.com/oldme-git/oldme-api/internal/logic/tag"
7+
8+
"github.com/oldme-git/oldme-api/api/tag/v1"
9+
)
10+
11+
func (c *ControllerV1) Show(ctx context.Context, req *v1.ShowReq) (res *v1.ShowRes, err error) {
12+
info, err := tag.Show(ctx, req.Id)
13+
if err != nil {
14+
return nil, err
15+
}
16+
return &v1.ShowRes{
17+
Tag: info,
18+
}, nil
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tag_grp
2+
3+
import (
4+
"context"
5+
6+
"github.com/oldme-git/oldme-api/internal/logic/tag_grp"
7+
8+
"github.com/oldme-git/oldme-api/api/tag_grp/v1"
9+
)
10+
11+
func (c *ControllerV1) Show(ctx context.Context, req *v1.ShowReq) (res *v1.ShowRes, err error) {
12+
info, err := tag_grp.Show(ctx, req.Id)
13+
if err != nil {
14+
return nil, err
15+
}
16+
return &v1.ShowRes{
17+
TagGrp: info,
18+
}, nil
19+
}

internal/logic/tag/tag.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ func Del(ctx context.Context, id model.Id) (err error) {
4747
_, err = dao.Tag.Ctx(ctx).Where("id", id).Delete()
4848
return
4949
}
50+
51+
// Show 读取详情
52+
func Show(ctx context.Context, id model.Id) (info *entity.Tag, err error) {
53+
err = dao.Tag.Ctx(ctx).Where("id", id).Scan(&info)
54+
if err != nil {
55+
err = utility.Err.Skip(10504)
56+
}
57+
return
58+
}

internal/logic/tag_grp/tag_grp.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ func List(ctx context.Context) (list []entity.TagGrp, err error) {
4545
return
4646
}
4747

48-
// IsExist 根据id判断一个标签分类是否存在
49-
func IsExist(ctx context.Context, id model.Id) bool {
50-
num, _ := dao.TagGrp.Ctx(ctx).Where("id", id).Count()
51-
return num == 1
48+
// Show 读取详情
49+
func Show(ctx context.Context, id model.Id) (info *entity.TagGrp, err error) {
50+
err = dao.TagGrp.Ctx(ctx).Where("id", id).Scan(&info)
51+
if err != nil {
52+
err = utility.Err.Skip(10504)
53+
}
54+
return
5255
}

internal/utility/err.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var Err = &pErr{
2626
10303: "你要回复的内容不见了",
2727
10501: "图片类型不正确",
2828
10503: "文件不存在",
29+
10504: "资源不存在",
2930
20100: "你的账号或者密码不对哩",
3031
20101: "不正确的或者过期的token,请重新获取",
3132
20102: "┗|`O′|┛ 嗷~~,获取你信息失败了",

0 commit comments

Comments
 (0)