From aa54e9a238a303eca865c0555311401603790e1d Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 4 Mar 2022 17:01:56 +0800 Subject: [PATCH] api update --- {apiv1 => api/v1}/api.go | 2 +- {apiv1 => api/v1}/article.go | 2 +- {apiv1 => api/v1}/ask.go | 2 +- {apiv1 => api/v1}/captcha.go | 2 +- {apiv1 => api/v1}/category.go | 2 +- {apiv1 => api/v1}/content.go | 2 +- {apiv1 => api/v1}/file.go | 2 +- {apiv1 => api/v1}/index.go | 2 +- {apiv1 => api/v1}/interact.go | 2 +- {apiv1 => api/v1}/login.go | 2 +- {apiv1 => api/v1}/profile.go | 2 +- {apiv1 => api/v1}/register.go | 2 +- {apiv1 => api/v1}/reply.go | 2 +- {apiv1 => api/v1}/search.go | 2 +- {apiv1 => api/v1}/topic.go | 2 +- {apiv1 => api/v1}/user.go | 6 +++--- internal/controller/article.go | 6 +++--- internal/controller/ask.go | 6 +++--- internal/controller/captcha.go | 4 ++-- internal/controller/category.go | 6 +++--- internal/controller/content.go | 14 +++++++------- internal/controller/file.go | 6 +++--- internal/controller/index.go | 4 ++-- internal/controller/interact.go | 10 +++++----- internal/controller/login.go | 8 ++++---- internal/controller/profile.go | 16 ++++++++-------- internal/controller/register.go | 6 +++--- internal/controller/reply.go | 10 +++++----- internal/controller/search.go | 4 ++-- internal/controller/topic.go | 6 +++--- internal/controller/user.go | 14 +++++++------- 31 files changed, 78 insertions(+), 78 deletions(-) rename {apiv1 => api/v1}/api.go (95%) rename {apiv1 => api/v1}/article.go (97%) rename {apiv1 => api/v1}/ask.go (97%) rename {apiv1 => api/v1}/captcha.go (95%) rename {apiv1 => api/v1}/category.go (97%) rename {apiv1 => api/v1}/content.go (99%) rename {apiv1 => api/v1}/file.go (96%) rename {apiv1 => api/v1}/index.go (93%) rename {apiv1 => api/v1}/interact.go (98%) rename {apiv1 => api/v1}/login.go (98%) rename {apiv1 => api/v1}/profile.go (99%) rename {apiv1 => api/v1}/register.go (98%) rename {apiv1 => api/v1}/reply.go (99%) rename {apiv1 => api/v1}/search.go (97%) rename {apiv1 => api/v1}/topic.go (97%) rename {apiv1 => api/v1}/user.go (97%) diff --git a/apiv1/api.go b/api/v1/api.go similarity index 95% rename from apiv1/api.go rename to api/v1/api.go index 5699254..35769a8 100644 --- a/apiv1/api.go +++ b/api/v1/api.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 type CommonPaginationReq struct { Page int `json:"page" in:"query" d:"1" v:"min:0#分页号码错误" dc:"分页号码,默认1"` diff --git a/apiv1/article.go b/api/v1/article.go similarity index 97% rename from apiv1/article.go rename to api/v1/article.go index e03e308..18d9cc1 100644 --- a/apiv1/article.go +++ b/api/v1/article.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/ask.go b/api/v1/ask.go similarity index 97% rename from apiv1/ask.go rename to api/v1/ask.go index f874571..3913187 100644 --- a/apiv1/ask.go +++ b/api/v1/ask.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/captcha.go b/api/v1/captcha.go similarity index 95% rename from apiv1/captcha.go rename to api/v1/captcha.go index 4738c1d..4a5f9bf 100644 --- a/apiv1/captcha.go +++ b/api/v1/captcha.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/category.go b/api/v1/category.go similarity index 97% rename from apiv1/category.go rename to api/v1/category.go index 40e7519..246dc71 100644 --- a/apiv1/category.go +++ b/api/v1/category.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "focus-single/internal/model" diff --git a/apiv1/content.go b/api/v1/content.go similarity index 99% rename from apiv1/content.go rename to api/v1/content.go index 81e19a8..74bedf4 100644 --- a/apiv1/content.go +++ b/api/v1/content.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/file.go b/api/v1/file.go similarity index 96% rename from apiv1/file.go rename to api/v1/file.go index f20a7e4..460e82c 100644 --- a/apiv1/file.go +++ b/api/v1/file.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/index.go b/api/v1/index.go similarity index 93% rename from apiv1/index.go rename to api/v1/index.go index f5159e3..57ac1aa 100644 --- a/apiv1/index.go +++ b/api/v1/index.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/interact.go b/api/v1/interact.go similarity index 98% rename from apiv1/interact.go rename to api/v1/interact.go index e1c232b..7a33c05 100644 --- a/apiv1/interact.go +++ b/api/v1/interact.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/login.go b/api/v1/login.go similarity index 98% rename from apiv1/login.go rename to api/v1/login.go index b2d1f17..a6f09b4 100644 --- a/apiv1/login.go +++ b/api/v1/login.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/profile.go b/api/v1/profile.go similarity index 99% rename from apiv1/profile.go rename to api/v1/profile.go index 92ac3cb..19f9c3e 100644 --- a/apiv1/profile.go +++ b/api/v1/profile.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/register.go b/api/v1/register.go similarity index 98% rename from apiv1/register.go rename to api/v1/register.go index dd4465a..a5145f8 100644 --- a/apiv1/register.go +++ b/api/v1/register.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/reply.go b/api/v1/reply.go similarity index 99% rename from apiv1/reply.go rename to api/v1/reply.go index cf4702c..dfb3073 100644 --- a/apiv1/reply.go +++ b/api/v1/reply.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/search.go b/api/v1/search.go similarity index 97% rename from apiv1/search.go rename to api/v1/search.go index 21a00d3..824e7b3 100644 --- a/apiv1/search.go +++ b/api/v1/search.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/topic.go b/api/v1/topic.go similarity index 97% rename from apiv1/topic.go rename to api/v1/topic.go index a0bbaf4..ded02dc 100644 --- a/apiv1/topic.go +++ b/api/v1/topic.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" diff --git a/apiv1/user.go b/api/v1/user.go similarity index 97% rename from apiv1/user.go rename to api/v1/user.go index f1ce7b1..9a478ef 100644 --- a/apiv1/user.go +++ b/api/v1/user.go @@ -1,4 +1,4 @@ -package apiv1 +package v1 import ( "github.com/gogf/gf/v2/frame/g" @@ -44,6 +44,6 @@ type UserLogoutReq struct { g.Meta `path:"/user/logout" method:"get" summary:"执行用户注销接口" tags:"个人"` } -type UserLogoutRes struct{ +type UserLogoutRes struct { g.Meta `mime:"text/html" type:"string" example:""` -} \ No newline at end of file +} diff --git a/internal/controller/article.go b/internal/controller/article.go index 160de0c..13c8e49 100644 --- a/internal/controller/article.go +++ b/internal/controller/article.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/model" "focus-single/internal/service" @@ -15,7 +15,7 @@ var Article = cArticle{} type cArticle struct{} // Index article list -func (a *cArticle) Index(ctx context.Context, req *apiv1.ArticleIndexReq) (res *apiv1.ArticleIndexRes, err error) { +func (a *cArticle) Index(ctx context.Context, req *v1.ArticleIndexReq) (res *v1.ArticleIndexRes, err error) { req.Type = consts.ContentTypeArticle getListRes, err := service.Content().GetList(ctx, model.ContentGetListInput{ Type: req.Type, @@ -39,7 +39,7 @@ func (a *cArticle) Index(ctx context.Context, req *apiv1.ArticleIndexReq) (res * } // Detail .article details -func (a *cArticle) Detail(ctx context.Context, req *apiv1.ArticleDetailReq) (res *apiv1.ArticleDetailRes, err error) { +func (a *cArticle) Detail(ctx context.Context, req *v1.ArticleDetailReq) (res *v1.ArticleDetailRes, err error) { getDetailRes, err := service.Content().GetDetail(ctx, req.Id) if err != nil { return nil, err diff --git a/internal/controller/ask.go b/internal/controller/ask.go index f1fbbcd..78f0166 100644 --- a/internal/controller/ask.go +++ b/internal/controller/ask.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/model" "focus-single/internal/service" @@ -14,7 +14,7 @@ var Ask = cAak{} type cAak struct{} -func (a *cAak) Index(ctx context.Context, req *apiv1.AskIndexReq) (res *apiv1.AskIndexRes, err error) { +func (a *cAak) Index(ctx context.Context, req *v1.AskIndexReq) (res *v1.AskIndexRes, err error) { req.Type = consts.ContentTypeAsk if getListRes, err := service.Content().GetList(ctx, model.ContentGetListInput{ Type: req.Type, @@ -37,7 +37,7 @@ func (a *cAak) Index(ctx context.Context, req *apiv1.AskIndexReq) (res *apiv1.As return } -func (a *cAak) Detail(ctx context.Context, req *apiv1.AskDetailReq) (res *apiv1.AskDetailRes, err error) { +func (a *cAak) Detail(ctx context.Context, req *v1.AskDetailReq) (res *v1.AskDetailRes, err error) { if getDetailRes, err := service.Content().GetDetail(ctx, req.Id); err != nil { return nil, err } else { diff --git a/internal/controller/captcha.go b/internal/controller/captcha.go index b85d282..ee30dd8 100644 --- a/internal/controller/captcha.go +++ b/internal/controller/captcha.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/service" ) @@ -13,7 +13,7 @@ var Captcha = cCaptcha{} type cCaptcha struct{} -func (a *cCaptcha) Index(ctx context.Context, req *apiv1.CaptchaIndexReq) (res *apiv1.CaptchaIndexRes, err error) { +func (a *cCaptcha) Index(ctx context.Context, req *v1.CaptchaIndexReq) (res *v1.CaptchaIndexRes, err error) { err = service.Captcha().NewAndStore(ctx, consts.CaptchaDefaultName) return } diff --git a/internal/controller/category.go b/internal/controller/category.go index 64468e1..2fbaaee 100644 --- a/internal/controller/category.go +++ b/internal/controller/category.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/service" ) @@ -12,8 +12,8 @@ var Category = cCategory{} type cCategory struct{} -func (a *cCategory) Tree(ctx context.Context, req *apiv1.CategoryTreeReq) (res *apiv1.CategoryTreeRes, err error) { - res = &apiv1.CategoryTreeRes{} +func (a *cCategory) Tree(ctx context.Context, req *v1.CategoryTreeReq) (res *v1.CategoryTreeRes, err error) { + res = &v1.CategoryTreeRes{} res.List, err = service.Category().GetTree(ctx, req.ContentType) return } diff --git a/internal/controller/content.go b/internal/controller/content.go index 42576b9..c9ca8d5 100644 --- a/internal/controller/content.go +++ b/internal/controller/content.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/model" "focus-single/internal/service" ) @@ -13,14 +13,14 @@ var Content = cContent{} type cContent struct{} -func (a *cContent) ShowCreate(ctx context.Context, req *apiv1.ContentShowCreateReq) (res *apiv1.ContentShowCreateRes, err error) { +func (a *cContent) ShowCreate(ctx context.Context, req *v1.ContentShowCreateReq) (res *v1.ContentShowCreateRes, err error) { service.View().Render(ctx, model.View{ ContentType: req.Type, }) return } -func (a *cContent) Create(ctx context.Context, req *apiv1.ContentCreateReq) (res *apiv1.ContentCreateRes, err error) { +func (a *cContent) Create(ctx context.Context, req *v1.ContentCreateReq) (res *v1.ContentCreateRes, err error) { out, err := service.Content().Create(ctx, model.ContentCreateInput{ ContentCreateUpdateBase: model.ContentCreateUpdateBase{ Type: req.Type, @@ -37,10 +37,10 @@ func (a *cContent) Create(ctx context.Context, req *apiv1.ContentCreateReq) (res if err != nil { return nil, err } - return &apiv1.ContentCreateRes{ContentId: out.ContentId}, nil + return &v1.ContentCreateRes{ContentId: out.ContentId}, nil } -func (a *cContent) ShowUpdate(ctx context.Context, req *apiv1.ContentShowUpdateReq) (res *apiv1.ContentShowUpdateRes, err error) { +func (a *cContent) ShowUpdate(ctx context.Context, req *v1.ContentShowUpdateReq) (res *v1.ContentShowUpdateRes, err error) { if getDetailRes, err := service.Content().GetDetail(ctx, req.Id); err != nil { return nil, err } else { @@ -62,7 +62,7 @@ func (a *cContent) ShowUpdate(ctx context.Context, req *apiv1.ContentShowUpdateR return } -func (a *cContent) Update(ctx context.Context, req *apiv1.ContentUpdateReq) (res *apiv1.ContentUpdateRes, err error) { +func (a *cContent) Update(ctx context.Context, req *v1.ContentUpdateReq) (res *v1.ContentUpdateRes, err error) { err = service.Content().Update(ctx, model.ContentUpdateInput{ Id: req.Id, ContentCreateUpdateBase: model.ContentCreateUpdateBase{ @@ -79,7 +79,7 @@ func (a *cContent) Update(ctx context.Context, req *apiv1.ContentUpdateReq) (res return } -func (a *cContent) Delete(ctx context.Context, req *apiv1.ContentDeleteReq) (res *apiv1.ContentDeleteRes, err error) { +func (a *cContent) Delete(ctx context.Context, req *v1.ContentDeleteReq) (res *v1.ContentDeleteRes, err error) { err = service.Content().Delete(ctx, req.Id) return } diff --git a/internal/controller/file.go b/internal/controller/file.go index ea85a8c..3095861 100644 --- a/internal/controller/file.go +++ b/internal/controller/file.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/model" "focus-single/internal/service" "github.com/gogf/gf/v2/errors/gcode" @@ -15,7 +15,7 @@ var File = cFile{} type cFile struct{} -func (a *cFile) Upload(ctx context.Context, req *apiv1.FileUploadReq) (res *apiv1.FileUploadRes, err error) { +func (a *cFile) Upload(ctx context.Context, req *v1.FileUploadReq) (res *v1.FileUploadRes, err error) { if req.File == nil { return nil, gerror.NewCode(gcode.CodeMissingParameter, "请选择需要上传的文件") } @@ -26,7 +26,7 @@ func (a *cFile) Upload(ctx context.Context, req *apiv1.FileUploadReq) (res *apiv if err != nil { return nil, err } - res = &apiv1.FileUploadRes{ + res = &v1.FileUploadRes{ Name: result.Name, Url: result.Url, } diff --git a/internal/controller/index.go b/internal/controller/index.go index a236872..60cc299 100644 --- a/internal/controller/index.go +++ b/internal/controller/index.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/model" "focus-single/internal/service" ) @@ -13,7 +13,7 @@ var Index = cIndex{} type cIndex struct{} -func (a *cIndex) Index(ctx context.Context, req *apiv1.IndexReq) (res *apiv1.IndexRes, err error) { +func (a *cIndex) Index(ctx context.Context, req *v1.IndexReq) (res *v1.IndexRes, err error) { if getListRes, err := service.Content().GetList(ctx, model.ContentGetListInput{ Type: req.Type, CategoryId: req.CategoryId, diff --git a/internal/controller/interact.go b/internal/controller/interact.go index ca94e36..a6c415a 100644 --- a/internal/controller/interact.go +++ b/internal/controller/interact.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/service" ) @@ -12,22 +12,22 @@ var Interact = cInteract{} type cInteract struct{} -func (a *cInteract) Zan(ctx context.Context, req *apiv1.InteractZanReq) (res *apiv1.InteractZanRes, err error) { +func (a *cInteract) Zan(ctx context.Context, req *v1.InteractZanReq) (res *v1.InteractZanRes, err error) { err = service.Interact().Zan(ctx, req.Type, req.Id) return } -func (a *cInteract) CancelZan(ctx context.Context, req *apiv1.InteractCancelZanReq) (res *apiv1.InteractCancelZanRes, err error) { +func (a *cInteract) CancelZan(ctx context.Context, req *v1.InteractCancelZanReq) (res *v1.InteractCancelZanRes, err error) { err = service.Interact().CancelZan(ctx, req.Type, req.Id) return } -func (a *cInteract) Cai(ctx context.Context, req *apiv1.InteractCaiReq) (res *apiv1.InteractCaiRes, err error) { +func (a *cInteract) Cai(ctx context.Context, req *v1.InteractCaiReq) (res *v1.InteractCaiRes, err error) { err = service.Interact().Cai(ctx, req.Type, req.Id) return } -func (a *cInteract) CancelCai(ctx context.Context, req *apiv1.InteractCancelCaiReq) (res *apiv1.InteractCancelCaiRes, err error) { +func (a *cInteract) CancelCai(ctx context.Context, req *v1.InteractCancelCaiReq) (res *v1.InteractCancelCaiRes, err error) { err = service.Interact().CancelCai(ctx, req.Type, req.Id) return } diff --git a/internal/controller/login.go b/internal/controller/login.go index 0b617ac..b26c571 100644 --- a/internal/controller/login.go +++ b/internal/controller/login.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/model" "focus-single/internal/service" @@ -17,13 +17,13 @@ var Login = cLogin{} type cLogin struct{} -func (a *cLogin) Index(ctx context.Context, req *apiv1.LoginIndexReq) (res *apiv1.LoginIndexRes, err error) { +func (a *cLogin) Index(ctx context.Context, req *v1.LoginIndexReq) (res *v1.LoginIndexRes, err error) { service.View().Render(ctx, model.View{}) return } -func (a *cLogin) Login(ctx context.Context, req *apiv1.LoginDoReq) (res *apiv1.LoginDoRes, err error) { - res = &apiv1.LoginDoRes{} +func (a *cLogin) Login(ctx context.Context, req *v1.LoginDoReq) (res *v1.LoginDoRes, err error) { + res = &v1.LoginDoRes{} if !service.Captcha().VerifyAndClear(g.RequestFromCtx(ctx), consts.CaptchaDefaultName, req.Captcha) { return res, gerror.NewCode(gcode.CodeBusinessValidationFailed, "请输入正确的验证码") } diff --git a/internal/controller/profile.go b/internal/controller/profile.go index ed91a6d..79fe305 100644 --- a/internal/controller/profile.go +++ b/internal/controller/profile.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/model" "focus-single/internal/service" "github.com/gogf/gf/v2/errors/gcode" @@ -16,7 +16,7 @@ var Profile = cProfile{} type cProfile struct{} -func (a *cProfile) Index(ctx context.Context, req *apiv1.ProfileIndexReq) (res *apiv1.ProfileIndexRes, err error) { +func (a *cProfile) Index(ctx context.Context, req *v1.ProfileIndexReq) (res *v1.ProfileIndexRes, err error) { if getProfile, err := service.User().GetProfile(ctx); err != nil { return nil, err } else { @@ -31,7 +31,7 @@ func (a *cProfile) Index(ctx context.Context, req *apiv1.ProfileIndexReq) (res * } } -func (a *cProfile) Avatar(ctx context.Context, req *apiv1.ProfileAvatarReq) (res *apiv1.ProfileAvatarRes, err error) { +func (a *cProfile) Avatar(ctx context.Context, req *v1.ProfileAvatarReq) (res *v1.ProfileAvatarRes, err error) { if getProfile, err := service.User().GetProfile(ctx); err != nil { return nil, err } else { @@ -46,7 +46,7 @@ func (a *cProfile) Avatar(ctx context.Context, req *apiv1.ProfileAvatarReq) (res } } -func (a *cProfile) UpdateAvatar(ctx context.Context, req *apiv1.ProfileUpdateAvatarReq) (res *apiv1.ProfileUpdateAvatarRes, err error) { +func (a *cProfile) UpdateAvatar(ctx context.Context, req *v1.ProfileUpdateAvatarReq) (res *v1.ProfileUpdateAvatarRes, err error) { var ( request = g.RequestFromCtx(ctx) file = request.GetUploadFile("file") @@ -78,7 +78,7 @@ func (a *cProfile) UpdateAvatar(ctx context.Context, req *apiv1.ProfileUpdateAva return } -func (a *cProfile) Password(ctx context.Context, req *apiv1.ProfilePasswordReq) (res *apiv1.ProfilePasswordRes, err error) { +func (a *cProfile) Password(ctx context.Context, req *v1.ProfilePasswordReq) (res *v1.ProfilePasswordRes, err error) { if getProfile, err := service.User().GetProfile(ctx); err != nil { return nil, err } else { @@ -93,7 +93,7 @@ func (a *cProfile) Password(ctx context.Context, req *apiv1.ProfilePasswordReq) } } -func (a *cProfile) UpdatePassword(ctx context.Context, req *apiv1.ProfileUpdatePasswordReq) (res *apiv1.ProfileUpdatePasswordRes, err error) { +func (a *cProfile) UpdatePassword(ctx context.Context, req *v1.ProfileUpdatePasswordReq) (res *v1.ProfileUpdatePasswordRes, err error) { err = service.User().UpdatePassword(ctx, model.UserPasswordInput{ OldPassword: req.OldPassword, NewPassword: req.NewPassword, @@ -101,7 +101,7 @@ func (a *cProfile) UpdatePassword(ctx context.Context, req *apiv1.ProfileUpdateP return } -func (a *cProfile) UpdateProfile(ctx context.Context, req *apiv1.ProfileUpdateReq) (res *apiv1.ProfileUpdateRes, err error) { +func (a *cProfile) UpdateProfile(ctx context.Context, req *v1.ProfileUpdateReq) (res *v1.ProfileUpdateRes, err error) { err = service.User().UpdateProfile(ctx, model.UserUpdateProfileInput{ UserId: req.Id, Nickname: req.Nickname, @@ -111,7 +111,7 @@ func (a *cProfile) UpdateProfile(ctx context.Context, req *apiv1.ProfileUpdateRe return } -func (a *cProfile) Message(ctx context.Context, req *apiv1.ProfileMessageReq) (res *apiv1.ProfileMessageRes, err error) { +func (a *cProfile) Message(ctx context.Context, req *v1.ProfileMessageReq) (res *v1.ProfileMessageRes, err error) { if getListRes, err := service.User().GetMessageList(ctx, model.UserGetMessageListInput{ Page: req.Page, Size: req.Size, diff --git a/internal/controller/register.go b/internal/controller/register.go index ad5b2ac..5caa034 100644 --- a/internal/controller/register.go +++ b/internal/controller/register.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/model" "focus-single/internal/service" @@ -17,12 +17,12 @@ var Register = cRegister{} type cRegister struct{} -func (a *cRegister) Index(ctx context.Context, req *apiv1.RegisterIndexReq) (res *apiv1.RegisterIndexRes, err error) { +func (a *cRegister) Index(ctx context.Context, req *v1.RegisterIndexReq) (res *v1.RegisterIndexRes, err error) { service.View().Render(ctx, model.View{}) return } -func (a *cRegister) Register(ctx context.Context, req *apiv1.RegisterDoReq) (res *apiv1.RegisterDoRes, err error) { +func (a *cRegister) Register(ctx context.Context, req *v1.RegisterDoReq) (res *v1.RegisterDoRes, err error) { if !service.Captcha().VerifyAndClear(g.RequestFromCtx(ctx), consts.CaptchaDefaultName, req.Captcha) { return nil, gerror.NewCode(gcode.CodeBusinessValidationFailed, "请输入正确的验证码") } diff --git a/internal/controller/reply.go b/internal/controller/reply.go index 501c953..152399f 100644 --- a/internal/controller/reply.go +++ b/internal/controller/reply.go @@ -5,7 +5,7 @@ import ( "github.com/gogf/gf/v2/frame/g" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/model" "focus-single/internal/service" ) @@ -15,7 +15,7 @@ var Reply = cReply{} type cReply struct{} -func (a *cReply) GetListContent(ctx context.Context, req *apiv1.ReplyGetListContentReq) (res *apiv1.ReplyGetListContentRes, err error) { +func (a *cReply) GetListContent(ctx context.Context, req *v1.ReplyGetListContentReq) (res *v1.ReplyGetListContentRes, err error) { if getListRes, err := service.Reply().GetList(ctx, model.ReplyGetListInput{ Page: req.Page, Size: req.Size, @@ -28,11 +28,11 @@ func (a *cReply) GetListContent(ctx context.Context, req *apiv1.ReplyGetListCont service.View().RenderTpl(ctx, "index/reply.html", model.View{Data: getListRes}) tplContent := request.Response.BufferString() request.Response.ClearBuffer() - return &apiv1.ReplyGetListContentRes{Content: tplContent}, nil + return &v1.ReplyGetListContentRes{Content: tplContent}, nil } } -func (a *cReply) Create(ctx context.Context, req *apiv1.ReplyCreateReq) (res *apiv1.ReplyCreateRes, err error) { +func (a *cReply) Create(ctx context.Context, req *v1.ReplyCreateReq) (res *v1.ReplyCreateRes, err error) { err = service.Reply().Create(ctx, model.ReplyCreateInput{ Title: req.Title, ParentId: req.ParentId, @@ -44,7 +44,7 @@ func (a *cReply) Create(ctx context.Context, req *apiv1.ReplyCreateReq) (res *ap return } -func (a *cReply) Delete(ctx context.Context, req *apiv1.ReplyDeleteReq) (res *apiv1.ReplyDeleteRes, err error) { +func (a *cReply) Delete(ctx context.Context, req *v1.ReplyDeleteReq) (res *v1.ReplyDeleteRes, err error) { err = service.Reply().Delete(ctx, req.Id) return } diff --git a/internal/controller/search.go b/internal/controller/search.go index 1395af1..ad11927 100644 --- a/internal/controller/search.go +++ b/internal/controller/search.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/model" "focus-single/internal/service" ) @@ -13,7 +13,7 @@ var Search = cSearch{} type cSearch struct{} -func (a *cSearch) Index(ctx context.Context, req *apiv1.SearchIndexReq) (res *apiv1.SearchIndexRes, err error) { +func (a *cSearch) Index(ctx context.Context, req *v1.SearchIndexReq) (res *v1.SearchIndexRes, err error) { if searchRes, err := service.Content().Search(ctx, model.ContentSearchInput{ Key: req.Key, Type: req.Type, diff --git a/internal/controller/topic.go b/internal/controller/topic.go index ce24b7e..f40d1de 100644 --- a/internal/controller/topic.go +++ b/internal/controller/topic.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/model" "focus-single/internal/service" @@ -14,7 +14,7 @@ var Topic = cTopic{} type cTopic struct{} -func (a *cTopic) Index(ctx context.Context, req *apiv1.TopicIndexReq) (res *apiv1.TopicIndexRes, err error) { +func (a *cTopic) Index(ctx context.Context, req *v1.TopicIndexReq) (res *v1.TopicIndexRes, err error) { req.Type = consts.ContentTypeTopic if getListRes, err := service.Content().GetList(ctx, model.ContentGetListInput{ Type: req.Type, @@ -38,7 +38,7 @@ func (a *cTopic) Index(ctx context.Context, req *apiv1.TopicIndexReq) (res *apiv } } -func (a *cTopic) Detail(ctx context.Context, req *apiv1.TopicDetailReq) (res *apiv1.TopicDetailRes, err error) { +func (a *cTopic) Detail(ctx context.Context, req *v1.TopicDetailReq) (res *v1.TopicDetailRes, err error) { if getDetailRes, err := service.Content().GetDetail(ctx, req.Id); err != nil { return nil, err } else { diff --git a/internal/controller/user.go b/internal/controller/user.go index cd7b51f..424dbc8 100644 --- a/internal/controller/user.go +++ b/internal/controller/user.go @@ -3,7 +3,7 @@ package controller import ( "context" - "focus-single/apiv1" + "focus-single/api/v1" "focus-single/internal/consts" "focus-single/internal/model" "focus-single/internal/service" @@ -15,30 +15,30 @@ var User = cUser{} type cUser struct{} -func (a *cUser) Index(ctx context.Context, req *apiv1.UserIndexReq) (res *apiv1.UserIndexRes, err error) { +func (a *cUser) Index(ctx context.Context, req *v1.UserIndexReq) (res *v1.UserIndexRes, err error) { err = a.getContentList(ctx, req.UserId, req.ContentGetListCommonReq) return } -func (a *cUser) Article(ctx context.Context, req *apiv1.UserArticleReq) (res *apiv1.UserArticleRes, err error) { +func (a *cUser) Article(ctx context.Context, req *v1.UserArticleReq) (res *v1.UserArticleRes, err error) { req.Type = consts.ContentTypeArticle err = a.getContentList(ctx, req.UserId, req.ContentGetListCommonReq) return } -func (a *cUser) Topic(ctx context.Context, req *apiv1.UserTopicReq) (res *apiv1.UserTopicRes, err error) { +func (a *cUser) Topic(ctx context.Context, req *v1.UserTopicReq) (res *v1.UserTopicRes, err error) { req.Type = consts.ContentTypeTopic err = a.getContentList(ctx, req.UserId, req.ContentGetListCommonReq) return } -func (a *cUser) Ask(ctx context.Context, req *apiv1.UserAskReq) (res *apiv1.UserAskRes, err error) { +func (a *cUser) Ask(ctx context.Context, req *v1.UserAskReq) (res *v1.UserAskRes, err error) { req.Type = consts.ContentTypeAsk err = a.getContentList(ctx, req.UserId, req.ContentGetListCommonReq) return } -func (a *cUser) getContentList(ctx context.Context, userId uint, req apiv1.ContentGetListCommonReq) error { +func (a *cUser) getContentList(ctx context.Context, userId uint, req v1.ContentGetListCommonReq) error { if out, err := service.User().GetList(ctx, model.UserGetContentListInput{ ContentGetListInput: model.ContentGetListInput{ Type: req.Type, @@ -64,7 +64,7 @@ func (a *cUser) getContentList(ctx context.Context, userId uint, req apiv1.Conte } } -func (a *cUser) Logout(ctx context.Context, req *apiv1.UserLogoutReq) (res *apiv1.UserLogoutRes, err error) { +func (a *cUser) Logout(ctx context.Context, req *v1.UserLogoutReq) (res *v1.UserLogoutRes, err error) { if err = service.User().Logout(ctx); err != nil { return }