Skip to content

Commit

Permalink
feat: 增加部分接口
Browse files Browse the repository at this point in the history
  • Loading branch information
oldme-git committed Nov 22, 2024
1 parent 646e105 commit 2b772f4
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/tag/tag.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions api/tag/v1/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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 {
Expand Down Expand Up @@ -40,3 +41,12 @@ type ListReq struct {
type ListRes struct {
List []List `json:"list"`
}

type ShowReq struct {
g.Meta `path:"tag/show/{id}" method:"get" sm:"查询详情" tags:"标签"`
*model.IdInput
}

type ShowRes struct {
*entity.Tag
}
1 change: 1 addition & 0 deletions api/tag_grp/tag_grp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions api/tag_grp/v1/tag_grp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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 {
Expand Down Expand Up @@ -30,6 +31,15 @@ type DelReq struct {
type DelRes struct {
}

type ShowReq struct {
g.Meta `path:"tag/group/show/{id}" method:"get" sm:"查询详情" tags:"标签分类"`
*model.IdInput
}

type ShowRes struct {
*entity.TagGrp
}

type ListReq struct {
g.Meta `path:"tag/group/list" method:"get" sm:"查询列表" tags:"标签分类"`
}
Expand Down
19 changes: 19 additions & 0 deletions internal/controller/tag/tag_v1_show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tag

import (
"context"

"github.com/oldme-git/oldme-api/internal/logic/tag"

"github.com/oldme-git/oldme-api/api/tag/v1"
)

func (c *ControllerV1) Show(ctx context.Context, req *v1.ShowReq) (res *v1.ShowRes, err error) {
info, err := tag.Show(ctx, req.Id)
if err != nil {
return nil, err
}
return &v1.ShowRes{
Tag: info,
}, nil
}
19 changes: 19 additions & 0 deletions internal/controller/tag_grp/tag_grp_v1_show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tag_grp

import (
"context"

"github.com/oldme-git/oldme-api/internal/logic/tag_grp"

"github.com/oldme-git/oldme-api/api/tag_grp/v1"
)

func (c *ControllerV1) Show(ctx context.Context, req *v1.ShowReq) (res *v1.ShowRes, err error) {
info, err := tag_grp.Show(ctx, req.Id)
if err != nil {
return nil, err
}
return &v1.ShowRes{
TagGrp: info,
}, nil
}
9 changes: 9 additions & 0 deletions internal/logic/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ func Del(ctx context.Context, id model.Id) (err error) {
_, err = dao.Tag.Ctx(ctx).Where("id", id).Delete()
return
}

// Show 读取详情
func Show(ctx context.Context, id model.Id) (info *entity.Tag, err error) {
err = dao.Tag.Ctx(ctx).Where("id", id).Scan(&info)
if err != nil {
err = utility.Err.Skip(10504)
}
return
}
11 changes: 7 additions & 4 deletions internal/logic/tag_grp/tag_grp.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ func List(ctx context.Context) (list []entity.TagGrp, err error) {
return
}

// IsExist 根据id判断一个标签分类是否存在
func IsExist(ctx context.Context, id model.Id) bool {
num, _ := dao.TagGrp.Ctx(ctx).Where("id", id).Count()
return num == 1
// Show 读取详情
func Show(ctx context.Context, id model.Id) (info *entity.TagGrp, err error) {
err = dao.TagGrp.Ctx(ctx).Where("id", id).Scan(&info)
if err != nil {
err = utility.Err.Skip(10504)
}
return
}
1 change: 1 addition & 0 deletions internal/utility/err.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var Err = &pErr{
10303: "你要回复的内容不见了",
10501: "图片类型不正确",
10503: "文件不存在",
10504: "资源不存在",
20100: "你的账号或者密码不对哩",
20101: "不正确的或者过期的token,请重新获取",
20102: "┗|`O′|┛ 嗷~~,获取你信息失败了",
Expand Down

0 comments on commit 2b772f4

Please sign in to comment.