作者 tangxvhui

新建文件

... ... @@ -7,6 +7,7 @@ import (
comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment"
company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company"
message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message"
tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags"
user "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
... ... @@ -59,6 +60,33 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_tag",
Handler: tags.CreateTagHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article_tag",
Handler: tags.EditTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/:id",
Handler: tags.GetTagHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_tag",
Handler: tags.DeleteTagHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/mini/user/apply-join-company",
Handler: user.MiniUserApplyJoinCompanyHandler(serverCtx),
},
... ...
package tags
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TagCreateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := tags.NewCreateTagLogic(r.Context(), svcCtx)
resp, err := l.CreateTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package tags
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TagDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := tags.NewDeleteTagLogic(r.Context(), svcCtx)
resp, err := l.DeleteTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package tags
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TagEditRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := tags.NewEditTagLogic(r.Context(), svcCtx)
resp, err := l.EditTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package tags
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TagGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := tags.NewGetTagLogic(r.Context(), svcCtx)
resp, err := l.GetTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package tags
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTagLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTagLogic {
return &CreateTagLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package tags
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteTagLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTagLogic {
return &DeleteTagLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.TagDeleteResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package tags
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type EditTagLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLogic {
return &EditTagLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package tags
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetTagLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagLogic {
return &GetTagLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
... ... @@ -63,6 +63,70 @@ type User struct {
Position string `json:"position,omitempty"` // 职位
}
type TagCreateRequest struct {
CompanyId int64 `json:"companyId"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
}
type TagCreateResponse struct {
Id int64 `json:"id"`
}
type TagEditRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
}
type TagEditResponse struct {
Id int64 `json:"id"`
}
type TagGetRequest struct {
Id int64 `json:"id"`
}
type TagGetResponse struct {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
}
type TagListRequest struct {
Page int `json:"page"`
Size int `json:"size"`
}
type TagListResponse struct {
Total int `json:"total"`
List []TagItem `json:"list"`
}
type TagItem struct {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
CreatedAt int64 `json:"createdAt"`
}
type TagDeleteRequest struct {
Id int64 `json:"id"`
}
type TagDeleteResponse struct {
Id int64 `json:"id"`
}
type MiniUserLoginRequest struct {
LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
... ...