Skip to content

Commit

Permalink
Fix application query bug: AppID is actually app.name
Browse files Browse the repository at this point in the history
  • Loading branch information
cj1128 committed Mar 30, 2021
1 parent 818d6ef commit ec081f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions datatype/request/user.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package request

import (
"github.com/MuShare/pluto/utils/general"
"strings"

"github.com/MuShare/pluto/utils/general"
)

const (
Expand Down Expand Up @@ -74,7 +75,9 @@ func (gml *GoogleMobileLogin) Validation() bool {
type WechatMobileLogin struct {
Code string `json:"code"`
DeviceID string `json:"device_id"`
AppID string `json:"app_id"`

// NOTE(cj): 这里的 id 其实是目前的 app.name
AppID string `json:"app_id"`
}

func (wml *WechatMobileLogin) Validation() bool {
Expand All @@ -97,7 +100,9 @@ func (wml *WechatMobileLogin) Validation() bool {
type AppleMobileLogin struct {
Code string `json:"code"`
DeviceID string `json:"device_id"`
AppID string `json:"app_id"`

// NOTE(cj): 这里的 id 其实是目前的 app.name
AppID string `json:"app_id"`
}

func (aml *AppleMobileLogin) Validation() bool {
Expand Down
4 changes: 2 additions & 2 deletions manage/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func NewManager(db *sql.DB, config *config.Config, logger *plog.PlutoLog) (*Mana
}

func getAppAppleLogin(m *Manager, appID string) (*modelexts.AppleLogin, *perror.PlutoError) {
app, err := models.Applications(qm.Where("id = ?", appID)).One(m.db)
app, err := models.Applications(qm.Where("name = ?", appID)).One(m.db)

if err != nil && err != sql.ErrNoRows {
return nil, perror.ServerError.Wrapper(err)
Expand All @@ -203,7 +203,7 @@ func getAppAppleLogin(m *Manager, appID string) (*modelexts.AppleLogin, *perror.
}

func getAppWechatLogin(m *Manager, appID string) (*modelexts.WechatLogin, *perror.PlutoError) {
app, err := models.Applications(qm.Where("id = ?", appID)).One(m.db)
app, err := models.Applications(qm.Where("name = ?", appID)).One(m.db)

if err != nil && err != sql.ErrNoRows {
return nil, perror.ServerError.Wrapper(err)
Expand Down

0 comments on commit ec081f1

Please sign in to comment.