Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
refactor(api): Remove unnecessary parameter of ParamsDecode method
Browse files Browse the repository at this point in the history
Signed-off-by: qwqcode <[email protected]>
  • Loading branch information
qwqcode committed Apr 29, 2022
1 parent bb2e683 commit fcd44bc
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion http/admin_cache_flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ParamsAdminCacheFlush struct {
// 缓存清理
func (a *action) AdminCacheFlush(c echo.Context) error {
var p ParamsAdminCacheFlush
if isOK, resp := ParamsDecode(c, ParamsAdminCacheFlush{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_cache_warm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ParamsAdminCacheWarm struct {
// 缓存预热
func (a *action) AdminCacheWarm(c echo.Context) error {
var p ParamsAdminCacheWarm
if isOK, resp := ParamsDecode(c, ParamsAdminCacheWarm{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_comment_del.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ParamsCommentDel struct {

func (a *action) AdminCommentDel(c echo.Context) error {
var p ParamsCommentDel
if isOK, resp := ParamsDecode(c, ParamsCommentDel{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_comment_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ParamsCommentEdit struct {

func (a *action) AdminCommentEdit(c echo.Context) error {
var p ParamsCommentEdit
if isOK, resp := ParamsDecode(c, ParamsCommentEdit{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_page_del.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ParamsAdminPageDel struct {

func (a *action) AdminPageDel(c echo.Context) error {
var p ParamsAdminPageDel
if isOK, resp := ParamsDecode(c, ParamsAdminPageDel{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_page_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ParamsAdminPageEdit struct {

func (a *action) AdminPageEdit(c echo.Context) error {
var p ParamsAdminPageEdit
if isOK, resp := ParamsDecode(c, ParamsAdminPageEdit{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_page_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var allPageFetchTotal = 0

func (a *action) AdminPageFetch(c echo.Context) error {
var p ParamsAdminPageFetch
if isOK, resp := ParamsDecode(c, ParamsAdminPageFetch{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_page_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ResponseAdminPageGet struct {

func (a *action) AdminPageGet(c echo.Context) error {
var p ParamsAdminPageGet
if isOK, resp := ParamsDecode(c, ParamsAdminPageGet{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_send_mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ParamsAdminSendMail struct {

func (a *action) AdminSendMail(c echo.Context) error {
var p ParamsAdminSendMail
if isOK, resp := ParamsDecode(c, ParamsAdminSendMail{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ParamsAdminSettingSave struct {

func (a *action) AdminSettingSave(c echo.Context) error {
var p ParamsAdminSettingSave
if isOK, resp := ParamsDecode(c, ParamsAdminSettingSave{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_site_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ParamsAdminSiteAdd struct {

func (a *action) AdminSiteAdd(c echo.Context) error {
var p ParamsAdminSiteAdd
if isOK, resp := ParamsDecode(c, ParamsAdminSiteAdd{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_site_del.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ParamsAdminSiteDel struct {

func (a *action) AdminSiteDel(c echo.Context) error {
var p ParamsAdminSiteDel
if isOK, resp := ParamsDecode(c, ParamsAdminSiteDel{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_site_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ParamsAdminSiteEdit struct {

func (a *action) AdminSiteEdit(c echo.Context) error {
var p ParamsAdminSiteEdit
if isOK, resp := ParamsDecode(c, ParamsAdminSiteEdit{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_site_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ParamsAdminSiteGet struct {

func (a *action) AdminSiteGet(c echo.Context) error {
var p ParamsAdminSiteGet
if isOK, resp := ParamsDecode(c, ParamsAdminSiteGet{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type ParamsAdminImport struct {

func (a *action) AdminImport(c echo.Context) error {
var p ParamsAdminImport
if isOK, resp := ParamsDecode(c, ParamsAdminImport{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/admin_vote_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ParamsAdminVoteSync struct {

func (a *action) AdminVoteSync(c echo.Context) error {
var p ParamsAdminVoteSync
if isOK, resp := ParamsDecode(c, ParamsAdminVoteSync{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (a *action) CaptchaCheck(c echo.Context) error {
ip := c.RealIP()

var p ParamsCaptchaCheck
if isOK, resp := ParamsDecode(c, ParamsCaptchaCheck{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}
inputVal := p.Value
Expand Down
2 changes: 1 addition & 1 deletion http/comment_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ResponseAdd struct {

func (a *action) Add(c echo.Context) error {
var p ParamsAdd
if isOK, resp := ParamsDecode(c, ParamsAdd{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/comment_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func GetCommentQuery(a *action, c echo.Context, p ParamsGet, siteID uint) *gorm.

func (a *action) Get(c echo.Context) error {
var p ParamsGet
if isOK, resp := ParamsDecode(c, ParamsGet{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/img_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (a *action) ImgUpload(c echo.Context) error {

// 传入参数解析
var p ParamsImgUpload
if isOK, resp := ParamsDecode(c, ParamsImgUpload{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/mark_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ParamsMarkRead struct {

func (a *action) MarkRead(c echo.Context) error {
var p ParamsMarkRead
if isOK, resp := ParamsDecode(c, ParamsMarkRead{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/pv.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ParamsPV struct {

func (a *action) PV(c echo.Context) error {
var p ParamsPV
if isOK, resp := ParamsDecode(c, ParamsPV{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion http/user_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ParamsUserGet struct {

func (a *action) UserGet(c echo.Context) error {
var p ParamsUserGet
if isOK, resp := ParamsDecode(c, ParamsUserGet{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
4 changes: 2 additions & 2 deletions http/user_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ParamsLogin struct {

func (a *action) Login(c echo.Context) error {
var p ParamsLogin
if isOK, resp := ParamsDecode(c, ParamsLogin{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down Expand Up @@ -78,7 +78,7 @@ type ParamsLoginStatus struct {
// 获取当前登录状态
func (a *action) LoginStatus(c echo.Context) error {
var p ParamsLoginStatus
if isOK, resp := ParamsDecode(c, ParamsLoginStatus{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down
8 changes: 4 additions & 4 deletions http/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (

type Map = map[string]interface{}

func ParamsDecode(c echo.Context, paramsStruct interface{}, destParams interface{}) (isContinue bool, resp error) {
func ParamsDecode(c echo.Context, destParams interface{}) (isContinue bool, resp error) {
params := make(map[string]interface{})

refVal := reflect.ValueOf(paramsStruct)
for i := 0; i < refVal.Type().NumField(); i++ {
field := refVal.Type().Field(i)
refVal := reflect.ValueOf(destParams)
for i := 0; i < refVal.Elem().Type().NumField(); i++ {
field := refVal.Elem().Type().Field(i)
//fieldName := field.Name
paramName := field.Tag.Get("mapstructure")
paramTagP := field.Tag.Get("param")
Expand Down
2 changes: 1 addition & 1 deletion http/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ParamsVote struct {

func (a *action) Vote(c echo.Context) error {
var p ParamsVote
if isOK, resp := ParamsDecode(c, ParamsVote{}, &p); !isOK {
if isOK, resp := ParamsDecode(c, &p); !isOK {
return resp
}

Expand Down

0 comments on commit fcd44bc

Please sign in to comment.