正在显示
9 个修改的文件
包含
227 行增加
和
22 行删除
| @@ -13,9 +13,9 @@ type ( | @@ -13,9 +13,9 @@ type ( | ||
| 13 | TagCreateRequest { | 13 | TagCreateRequest { |
| 14 | CompanyId int64 `json:"companyId"` | 14 | CompanyId int64 `json:"companyId"` |
| 15 | Image string `json:"image"` | 15 | Image string `json:"image"` |
| 16 | - Name string `json:"name"` // 标签名称 | ||
| 17 | - Group string `json:"group"` // 标签分类 | ||
| 18 | - Remark string `json:"remark"` // 备注 | 16 | + Name string `json:"name"` // 标签名称 |
| 17 | + Group string `json:"group"` // 标签分类 | ||
| 18 | + Remark string `json:"remark,optional"` // 备注 | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | TagCreateResponse { | 21 | TagCreateResponse { |
| @@ -27,11 +27,11 @@ type ( | @@ -27,11 +27,11 @@ type ( | ||
| 27 | type ( | 27 | type ( |
| 28 | TagEditRequest { | 28 | TagEditRequest { |
| 29 | Id int64 `json:"id"` | 29 | Id int64 `json:"id"` |
| 30 | - CompanyId int64 `json:"companyId"` | 30 | + CompanyId int64 `json:"-"` |
| 31 | Image string `json:"image"` | 31 | Image string `json:"image"` |
| 32 | - Name string `json:"name"` // 标签名称 | ||
| 33 | - Group string `json:"group"` // 标签分类 | ||
| 34 | - Remark string `json:"remark"` // 备注 | 32 | + Name string `json:"name"` // 标签名称 |
| 33 | + Group string `json:"group"` // 标签分类 | ||
| 34 | + Remark string `json:"remark,optional"` // 备注 | ||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | TagEditResponse { | 37 | TagEditResponse { |
| @@ -42,7 +42,8 @@ type ( | @@ -42,7 +42,8 @@ type ( | ||
| 42 | // 获取标签详情 | 42 | // 获取标签详情 |
| 43 | type ( | 43 | type ( |
| 44 | TagGetRequest { | 44 | TagGetRequest { |
| 45 | - Id int64 `path:"id"` | 45 | + Id int64 `path:"id"` |
| 46 | + CompanyId int64 `path:"-"` | ||
| 46 | } | 47 | } |
| 47 | TagGetResponse { | 48 | TagGetResponse { |
| 48 | Id int64 `json:"id"` | 49 | Id int64 `json:"id"` |
| @@ -56,11 +57,15 @@ type ( | @@ -56,11 +57,15 @@ type ( | ||
| 56 | //标签列表 | 57 | //标签列表 |
| 57 | type ( | 58 | type ( |
| 58 | TagListRequest { | 59 | TagListRequest { |
| 59 | - Page int `json:"page"` | ||
| 60 | - Size int `json:"size"` | 60 | + Page int `json:"page"` |
| 61 | + Size int `json:"size"` | ||
| 62 | + CompanyId int64 `json:"-"` | ||
| 63 | + TagName string `json:"tagName,optional"` | ||
| 64 | + Group string `json:"group,optional"` | ||
| 65 | + Remark string `json:"remark,optional"` | ||
| 61 | } | 66 | } |
| 62 | TagListResponse { | 67 | TagListResponse { |
| 63 | - Total int `json:"total"` | 68 | + Total int64 `json:"total"` |
| 64 | List []TagItem `json:"list"` | 69 | List []TagItem `json:"list"` |
| 65 | } | 70 | } |
| 66 | TagItem { | 71 | TagItem { |
| @@ -76,7 +81,8 @@ type ( | @@ -76,7 +81,8 @@ type ( | ||
| 76 | //删除标签 | 81 | //删除标签 |
| 77 | type ( | 82 | type ( |
| 78 | TagDeleteRequest { | 83 | TagDeleteRequest { |
| 79 | - Id int64 `path:"id"` | 84 | + Id int64 `path:"id"` |
| 85 | + CompanyId int64 `path:"-"` | ||
| 80 | } | 86 | } |
| 81 | TagDeleteResponse { | 87 | TagDeleteResponse { |
| 82 | Id int64 `json:"id"` | 88 | Id int64 `json:"id"` |
| @@ -92,13 +98,20 @@ service Core { | @@ -92,13 +98,20 @@ service Core { | ||
| 92 | @doc "后台创建文章标签" | 98 | @doc "后台创建文章标签" |
| 93 | @handler CreateTag | 99 | @handler CreateTag |
| 94 | post /article_tag (TagCreateRequest) returns (TagCreateResponse) | 100 | post /article_tag (TagCreateRequest) returns (TagCreateResponse) |
| 101 | + | ||
| 95 | @doc "后台编辑文章标签" | 102 | @doc "后台编辑文章标签" |
| 96 | @handler EditTag | 103 | @handler EditTag |
| 97 | put /article_tag (TagEditRequest) returns (TagEditResponse) | 104 | put /article_tag (TagEditRequest) returns (TagEditResponse) |
| 105 | + | ||
| 98 | @doc "后台获取文章标签" | 106 | @doc "后台获取文章标签" |
| 99 | @handler GetTag | 107 | @handler GetTag |
| 100 | get /article_tag/:id (TagGetRequest) returns (TagGetResponse) | 108 | get /article_tag/:id (TagGetRequest) returns (TagGetResponse) |
| 109 | + | ||
| 101 | @doc "后台删除文章标签" | 110 | @doc "后台删除文章标签" |
| 102 | @handler DeleteTag | 111 | @handler DeleteTag |
| 103 | - delete /article_tag (TagDeleteRequest) returns (TagDeleteResponse) | 112 | + delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse) |
| 113 | + | ||
| 114 | + @doc "后台搜索标签" | ||
| 115 | + @handler SearchTag | ||
| 116 | + post/article_tag/search (TagListRequest) returns (TagListResponse) | ||
| 104 | } | 117 | } |
| @@ -78,6 +78,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -78,6 +78,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 78 | Path: "/article_tag", | 78 | Path: "/article_tag", |
| 79 | Handler: tags.DeleteTagHandler(serverCtx), | 79 | Handler: tags.DeleteTagHandler(serverCtx), |
| 80 | }, | 80 | }, |
| 81 | + { | ||
| 82 | + Method: http.MethodPost, | ||
| 83 | + Path: "/article_tag/search", | ||
| 84 | + Handler: tags.SearchTagHandler(serverCtx), | ||
| 85 | + }, | ||
| 81 | }, | 86 | }, |
| 82 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | 87 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), |
| 83 | rest.WithPrefix("/v1/mini"), | 88 | rest.WithPrefix("/v1/mini"), |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.TagListRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewSearchTagLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SearchTag(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | 6 | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 10 | 11 | ||
| 11 | "github.com/zeromicro/go-zero/core/logx" | 12 | "github.com/zeromicro/go-zero/core/logx" |
| @@ -25,6 +26,7 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT | @@ -25,6 +26,7 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT | ||
| 25 | } | 26 | } |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 29 | +// 创建标签 | ||
| 28 | func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { | 30 | func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { |
| 29 | var conn = l.svcCtx.DefaultDBConn() | 31 | var conn = l.svcCtx.DefaultDBConn() |
| 30 | //检查重复 | 32 | //检查重复 |
| @@ -39,5 +41,29 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | @@ -39,5 +41,29 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | ||
| 39 | if cnt > 0 { | 41 | if cnt > 0 { |
| 40 | return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name)) | 42 | return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name)) |
| 41 | } | 43 | } |
| 44 | + //TODO 获取图片的尺寸大小 | ||
| 45 | + | ||
| 46 | + newTag := &domain.ArticleTag{ | ||
| 47 | + Id: 0, | ||
| 48 | + CompanyId: req.CompanyId, | ||
| 49 | + CreatedAt: 0, | ||
| 50 | + UpdatedAt: 0, | ||
| 51 | + DeletedAt: 0, | ||
| 52 | + Version: 0, | ||
| 53 | + Image: domain.Image{ | ||
| 54 | + Url: req.Image, | ||
| 55 | + Width: 0, | ||
| 56 | + Height: 0, | ||
| 57 | + }, | ||
| 58 | + Name: req.Name, | ||
| 59 | + Group: req.Group, | ||
| 60 | + Remark: req.Remark, | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag) | ||
| 64 | + if err != nil { | ||
| 65 | + return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 66 | + } | ||
| 67 | + resp = &types.TagCreateResponse{Id: newTag.Id} | ||
| 42 | return | 68 | return |
| 43 | } | 69 | } |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | 5 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 8 | 9 | ||
| 9 | "github.com/zeromicro/go-zero/core/logx" | 10 | "github.com/zeromicro/go-zero/core/logx" |
| 10 | ) | 11 | ) |
| @@ -24,7 +25,18 @@ func NewDeleteTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteT | @@ -24,7 +25,18 @@ func NewDeleteTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteT | ||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.TagDeleteResponse, err error) { | 27 | func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.TagDeleteResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | ||
| 28 | - | 28 | + var conn = l.svcCtx.DefaultDBConn() |
| 29 | + oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) | ||
| 30 | + if err != nil { | ||
| 31 | + return nil, xerr.NewErrMsgErr("不存在待修改的标签", err) | ||
| 32 | + } | ||
| 33 | + if oldTag.CompanyId != req.CompanyId { | ||
| 34 | + return nil, xerr.NewErrMsg("删除标签失败") | ||
| 35 | + } | ||
| 36 | + _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag) | ||
| 37 | + if err != nil { | ||
| 38 | + return nil, xerr.NewErrMsg("删除标签失败") | ||
| 39 | + } | ||
| 40 | + resp = &types.TagDeleteResponse{Id: oldTag.Id} | ||
| 29 | return | 41 | return |
| 30 | } | 42 | } |
| @@ -2,9 +2,12 @@ package tags | @@ -2,9 +2,12 @@ package tags | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "fmt" | ||
| 5 | 6 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 8 | 11 | ||
| 9 | "github.com/zeromicro/go-zero/core/logx" | 12 | "github.com/zeromicro/go-zero/core/logx" |
| 10 | ) | 13 | ) |
| @@ -23,8 +26,44 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo | @@ -23,8 +26,44 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo | ||
| 23 | } | 26 | } |
| 24 | } | 27 | } |
| 25 | 28 | ||
| 29 | +// 编辑标签 | ||
| 26 | func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { | 30 | func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | 31 | + var conn = l.svcCtx.DefaultDBConn() |
| 32 | + //检查重复 | ||
| 33 | + queryOptions := domain.NewQueryOptions(). | ||
| 34 | + WithFindOnly(). | ||
| 35 | + MustWithKV("name", req.Name). | ||
| 36 | + MustWithKV("group", req.Group). | ||
| 37 | + WithOffsetLimit(1, 1) | ||
| 28 | 38 | ||
| 39 | + _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | ||
| 40 | + if err != nil { | ||
| 41 | + return nil, xerr.NewErrMsgErr("修改标签失败", err) | ||
| 42 | + } | ||
| 43 | + if len(tagList) > 0 { | ||
| 44 | + if tagList[0].Id != req.Id { | ||
| 45 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name)) | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) | ||
| 49 | + if err != nil { | ||
| 50 | + return nil, xerr.NewErrMsgErr("不存在待修改的标签", err) | ||
| 51 | + } | ||
| 52 | + if oldTag.CompanyId != req.CompanyId { | ||
| 53 | + return nil, xerr.NewErrMsg("修改标签失败") | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + //TODO 获取图片的尺寸大小 | ||
| 57 | + | ||
| 58 | + oldTag.Group = req.Group | ||
| 59 | + oldTag.Image.Url = req.Image | ||
| 60 | + oldTag.Name = req.Name | ||
| 61 | + oldTag.Remark = req.Remark | ||
| 62 | + | ||
| 63 | + oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) | ||
| 64 | + if err != nil { | ||
| 65 | + return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 66 | + } | ||
| 67 | + resp = &types.TagEditResponse{Id: oldTag.Id} | ||
| 29 | return | 68 | return |
| 30 | } | 69 | } |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | 5 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 8 | 9 | ||
| 9 | "github.com/zeromicro/go-zero/core/logx" | 10 | "github.com/zeromicro/go-zero/core/logx" |
| 10 | ) | 11 | ) |
| @@ -23,8 +24,22 @@ func NewGetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagLogi | @@ -23,8 +24,22 @@ func NewGetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagLogi | ||
| 23 | } | 24 | } |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 27 | +// 获取详情 | ||
| 26 | func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetResponse, err error) { | 28 | func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | ||
| 28 | - | 29 | + var conn = l.svcCtx.DefaultDBConn() |
| 30 | + oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) | ||
| 31 | + if err != nil { | ||
| 32 | + return nil, xerr.NewErrMsgErr("不存在的标签", err) | ||
| 33 | + } | ||
| 34 | + if oldTag.CompanyId != req.CompanyId { | ||
| 35 | + return nil, xerr.NewErrMsg("获取标签失败") | ||
| 36 | + } | ||
| 37 | + resp = &types.TagGetResponse{ | ||
| 38 | + Id: oldTag.Id, | ||
| 39 | + Image: oldTag.Image.Url, | ||
| 40 | + Name: oldTag.Name, | ||
| 41 | + Group: oldTag.Group, | ||
| 42 | + Remark: oldTag.Remark, | ||
| 43 | + } | ||
| 29 | return | 44 | return |
| 30 | } | 45 | } |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type SearchTagLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchTagLogic { | ||
| 19 | + return &SearchTagLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) { | ||
| 27 | + var conn = l.svcCtx.DefaultDBConn() | ||
| 28 | + queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) | ||
| 29 | + | ||
| 30 | + if len(req.Group) > 0 { | ||
| 31 | + queryOptions = queryOptions.MustWithKV("group", req.Group) | ||
| 32 | + } | ||
| 33 | + if len(req.TagName) > 0 { | ||
| 34 | + queryOptions = queryOptions.MustWithKV("name", req.TagName) | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + if len(req.Remark) > 0 { | ||
| 38 | + queryOptions = queryOptions.MustWithKV("remark", "%"+req.Remark+"%") | ||
| 39 | + } | ||
| 40 | + cnt, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | ||
| 41 | + if err != nil { | ||
| 42 | + return &types.TagListResponse{}, nil | ||
| 43 | + } | ||
| 44 | + resp = &types.TagListResponse{ | ||
| 45 | + Total: cnt, | ||
| 46 | + List: make([]types.TagItem, len(tagList)), | ||
| 47 | + } | ||
| 48 | + for i := range tagList { | ||
| 49 | + resp.List[i] = types.TagItem{ | ||
| 50 | + Id: tagList[i].Id, | ||
| 51 | + Image: tagList[i].Image.Url, | ||
| 52 | + Name: tagList[i].Name, | ||
| 53 | + Group: tagList[i].Group, | ||
| 54 | + Remark: tagList[i].Remark, | ||
| 55 | + CreatedAt: tagList[i].CreatedAt, | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + return | ||
| 59 | +} |
| @@ -69,7 +69,7 @@ type TagCreateRequest struct { | @@ -69,7 +69,7 @@ type TagCreateRequest struct { | ||
| 69 | Image string `json:"image"` | 69 | Image string `json:"image"` |
| 70 | Name string `json:"name"` // 标签名称 | 70 | Name string `json:"name"` // 标签名称 |
| 71 | Group string `json:"group"` // 标签分类 | 71 | Group string `json:"group"` // 标签分类 |
| 72 | - Remark string `json:"remark"` // 备注 | 72 | + Remark string `json:"remark,optional"` // 备注 |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | type TagCreateResponse struct { | 75 | type TagCreateResponse struct { |
| @@ -78,11 +78,11 @@ type TagCreateResponse struct { | @@ -78,11 +78,11 @@ type TagCreateResponse struct { | ||
| 78 | 78 | ||
| 79 | type TagEditRequest struct { | 79 | type TagEditRequest struct { |
| 80 | Id int64 `json:"id"` | 80 | Id int64 `json:"id"` |
| 81 | - CompanyId int64 `json:"companyId"` | 81 | + CompanyId int64 `json:"-"` |
| 82 | Image string `json:"image"` | 82 | Image string `json:"image"` |
| 83 | Name string `json:"name"` // 标签名称 | 83 | Name string `json:"name"` // 标签名称 |
| 84 | Group string `json:"group"` // 标签分类 | 84 | Group string `json:"group"` // 标签分类 |
| 85 | - Remark string `json:"remark"` // 备注 | 85 | + Remark string `json:"remark,optional"` // 备注 |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | type TagEditResponse struct { | 88 | type TagEditResponse struct { |
| @@ -91,6 +91,7 @@ type TagEditResponse struct { | @@ -91,6 +91,7 @@ type TagEditResponse struct { | ||
| 91 | 91 | ||
| 92 | type TagGetRequest struct { | 92 | type TagGetRequest struct { |
| 93 | Id int64 `path:"id"` | 93 | Id int64 `path:"id"` |
| 94 | + CompanyId int64 `path:"-"` | ||
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | type TagGetResponse struct { | 97 | type TagGetResponse struct { |
| @@ -104,10 +105,14 @@ type TagGetResponse struct { | @@ -104,10 +105,14 @@ type TagGetResponse struct { | ||
| 104 | type TagListRequest struct { | 105 | type TagListRequest struct { |
| 105 | Page int `json:"page"` | 106 | Page int `json:"page"` |
| 106 | Size int `json:"size"` | 107 | Size int `json:"size"` |
| 108 | + CompanyId int64 `json:"-"` | ||
| 109 | + TagName string `json:"tagName,optional"` | ||
| 110 | + Group string `json:"group,optional"` | ||
| 111 | + Remark string `json:"remark,optional"` | ||
| 107 | } | 112 | } |
| 108 | 113 | ||
| 109 | type TagListResponse struct { | 114 | type TagListResponse struct { |
| 110 | - Total int `json:"total"` | 115 | + Total int64 `json:"total"` |
| 111 | List []TagItem `json:"list"` | 116 | List []TagItem `json:"list"` |
| 112 | } | 117 | } |
| 113 | 118 | ||
| @@ -122,12 +127,15 @@ type TagItem struct { | @@ -122,12 +127,15 @@ type TagItem struct { | ||
| 122 | 127 | ||
| 123 | type TagDeleteRequest struct { | 128 | type TagDeleteRequest struct { |
| 124 | Id int64 `path:"id"` | 129 | Id int64 `path:"id"` |
| 130 | + CompanyId int64 `path:"-"` | ||
| 125 | } | 131 | } |
| 126 | 132 | ||
| 127 | type TagDeleteResponse struct { | 133 | type TagDeleteResponse struct { |
| 128 | Id int64 `json:"id"` | 134 | Id int64 `json:"id"` |
| 129 | } | 135 | } |
| 130 | 136 | ||
| 137 | + | ||
| 138 | + | ||
| 131 | type MiniUserLoginRequest struct { | 139 | type MiniUserLoginRequest struct { |
| 132 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login | 140 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login |
| 133 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 | 141 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 |
-
请 注册 或 登录 后发表评论