player email
This commit is contained in:
parent
3d036641e0
commit
b5f2a9fcc8
@ -7,6 +7,7 @@ import (
|
||||
"main/model/system"
|
||||
"net/http"
|
||||
"q5"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -20,6 +21,7 @@ func (pai *PlayerApi) Info(c *gin.Context) {
|
||||
AccurateName bool `json:"accurate_name"`
|
||||
Account_id string `json:"account_id"`
|
||||
Address string `json:"address"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
reqJson := InfoForm{}
|
||||
@ -41,10 +43,45 @@ func (pai *PlayerApi) Info(c *gin.Context) {
|
||||
filterstr = " account_id = '" + reqJson.Account_id + "'"
|
||||
} else if reqJson.Address != "" {
|
||||
filterstr = " address = '" + reqJson.Address + "'"
|
||||
} else if reqJson.Email != "" {
|
||||
email := strings.ToLower(reqJson.Email)
|
||||
sql := fmt.Sprintf(`SELECT account_id FROM t_immutable_account WHERE idx > 1 AND lower_case_email = '%s'`, email)
|
||||
|
||||
accountids := []string{}
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.ACCOUNT_DB,
|
||||
sql,
|
||||
[]string{},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
accountids = append(accountids, ds.GetByIndex(0))
|
||||
}
|
||||
})
|
||||
|
||||
if len(accountids) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "",
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
filterstr = " account_id IN ("
|
||||
for _, id := range accountids {
|
||||
filterstr += "'" + id + "',"
|
||||
}
|
||||
filterstr = filterstr[:len(filterstr)-1]
|
||||
filterstr += ")"
|
||||
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": "input one of playername, account_id, address",
|
||||
"message": "input one of playername, account_id, address, email",
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -53,6 +90,38 @@ func (pai *PlayerApi) Info(c *gin.Context) {
|
||||
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
p := new(system.Player)
|
||||
p.LoadFromDs(ds)
|
||||
|
||||
accountid := ""
|
||||
if reqJson.Playername != "" {
|
||||
if reqJson.AccurateName {
|
||||
accountid = p.Account_id
|
||||
}
|
||||
} else if reqJson.Account_id != "" {
|
||||
accountid = reqJson.Account_id
|
||||
} else if reqJson.Address != "" {
|
||||
accountid = p.Account_id
|
||||
} else if reqJson.Email != "" {
|
||||
p.Email = strings.ToLower(reqJson.Email)
|
||||
}
|
||||
|
||||
if accountid != "" {
|
||||
sql := fmt.Sprintf(`SELECT lower_case_email FROM t_immutable_account WHERE idx > 1 AND account_id = '%s'`, accountid)
|
||||
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.ACCOUNT_DB,
|
||||
sql,
|
||||
[]string{},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if ds.Next() {
|
||||
p.Email = ds.GetByIndex(0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return p
|
||||
})
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"f5"
|
||||
//"fmt"
|
||||
"main/constant"
|
||||
"main/task"
|
||||
"main/mt"
|
||||
"main/task"
|
||||
//"sync"
|
||||
//"time"
|
||||
)
|
||||
@ -119,6 +119,16 @@ func (this *app) registerDataSources() {
|
||||
1,
|
||||
mt.Table.ConfDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.ConfDb.GetById(0).GetMaxIdleConns())
|
||||
f5.GetGoStyleDb().RegisterDataSource(
|
||||
constant.ACCOUNT_DB,
|
||||
mt.Table.AccountDb.GetById(0).GetHost(),
|
||||
mt.Table.AccountDb.GetById(0).GetPort(),
|
||||
mt.Table.AccountDb.GetById(0).GetUser(),
|
||||
mt.Table.AccountDb.GetById(0).GetPasswd(),
|
||||
mt.Table.AccountDb.GetById(0).GetDatabase(),
|
||||
1,
|
||||
mt.Table.AccountDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.AccountDb.GetById(0).GetMaxIdleConns())
|
||||
}
|
||||
|
||||
func (this *app) HasTask() bool {
|
||||
|
@ -48,6 +48,7 @@ type Player struct {
|
||||
Parachute int `gorm:"comment:降落伞id" json:"parachute"`
|
||||
Star_num int `gorm:"comment:星星数(成长任务)" json:"star_num"`
|
||||
Address string `gorm:"uniqueIndex;comment:钱包地址" json:"address"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func (this *Player) TableName() string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user