Skip to content

Commit

Permalink
api update
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Mar 4, 2022
1 parent 0804446 commit aa54e9a
Show file tree
Hide file tree
Showing 31 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion apiv1/api.go → api/v1/api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

type CommonPaginationReq struct {
Page int `json:"page" in:"query" d:"1" v:"min:0#分页号码错误" dc:"分页号码,默认1"`
Expand Down
2 changes: 1 addition & 1 deletion apiv1/article.go → api/v1/article.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/ask.go → api/v1/ask.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/captcha.go → api/v1/captcha.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/category.go → api/v1/category.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"focus-single/internal/model"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/content.go → api/v1/content.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/file.go → api/v1/file.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/index.go → api/v1/index.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/interact.go → api/v1/interact.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import "github.com/gogf/gf/v2/frame/g"

Expand Down
2 changes: 1 addition & 1 deletion apiv1/login.go → api/v1/login.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import "github.com/gogf/gf/v2/frame/g"

Expand Down
2 changes: 1 addition & 1 deletion apiv1/profile.go → api/v1/profile.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/register.go → api/v1/register.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import "github.com/gogf/gf/v2/frame/g"

Expand Down
2 changes: 1 addition & 1 deletion apiv1/reply.go → api/v1/reply.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/search.go → api/v1/search.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
2 changes: 1 addition & 1 deletion apiv1/topic.go → api/v1/topic.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down
6 changes: 3 additions & 3 deletions apiv1/user.go → api/v1/user.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apiv1
package v1

import (
"github.com/gogf/gf/v2/frame/g"
Expand Down Expand Up @@ -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:"<html/>"`
}
}
6 changes: 3 additions & 3 deletions internal/controller/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"context"

"focus-single/apiv1"
"focus-single/api/v1"
"focus-single/internal/consts"
"focus-single/internal/service"
)
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions internal/controller/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"context"

"focus-single/apiv1"
"focus-single/api/v1"
"focus-single/internal/service"
)

Expand All @@ -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
}
14 changes: 7 additions & 7 deletions internal/controller/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"context"

"focus-single/apiv1"
"focus-single/api/v1"
"focus-single/internal/model"
"focus-single/internal/service"
)
Expand All @@ -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,
Expand All @@ -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 {
Expand All @@ -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{
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions internal/controller/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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, "请选择需要上传的文件")
}
Expand All @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"context"

"focus-single/apiv1"
"focus-single/api/v1"
"focus-single/internal/model"
"focus-single/internal/service"
)
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions internal/controller/interact.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"context"

"focus-single/apiv1"
"focus-single/api/v1"
"focus-single/internal/service"
)

Expand All @@ -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
}
8 changes: 4 additions & 4 deletions internal/controller/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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, "请输入正确的验证码")
}
Expand Down
Loading

0 comments on commit aa54e9a

Please sign in to comment.