TODO: fix module name 无值问题
This commit is contained in:
parent
90743bfdc4
commit
809c0deaa2
|
@ -9,3 +9,7 @@ type KillaraCustomerDeviceLogModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
TableName string // 表名
|
TableName string // 表名
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *KillaraCustomerModel) InsertCustomerDeviceLog(logData *KillaraCustomerDeviceLog) error {
|
||||||
|
return m.db.Model(&KillaraCustomerDeviceLog{}).Create(logData).Error
|
||||||
|
}
|
||||||
|
|
|
@ -9,3 +9,7 @@ type KillaraCustomerDeviceModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
TableName string // 表名
|
TableName string // 表名
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *KillaraCustomerModel) InsertCustomerDevice(deviceData *KillaraCustomerDevice) error {
|
||||||
|
return m.db.Model(&KillaraCustomerDevice{}).Create(deviceData).Error
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package actions
|
package actions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/iapologizewhenimwrong/Vestmore_GO/model"
|
||||||
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/auth"
|
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/auth"
|
||||||
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/basic"
|
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/basic"
|
||||||
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/email"
|
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/email"
|
||||||
|
@ -25,18 +28,127 @@ func BaseGetToken(ctx *gin.Context, param *BaseGetTokenParam, resp *basic.Respon
|
||||||
|
|
||||||
// @Action account/loginWithTelephonePassword
|
// @Action account/loginWithTelephonePassword
|
||||||
// AccountLoginWithTelephonePassword
|
// AccountLoginWithTelephonePassword
|
||||||
// action: string;
|
// randstr: string;
|
||||||
// country_code: string;
|
// sign: string;
|
||||||
// device?: string;
|
|
||||||
// lang: string;
|
|
||||||
// password: string;
|
|
||||||
// telephone: string;
|
// telephone: string;
|
||||||
// token?: string;
|
// version: string;.0.14
|
||||||
// version?: string;
|
// token: string;
|
||||||
|
// country_code: string; 86
|
||||||
|
// password: string;
|
||||||
|
// action: string;
|
||||||
|
// device: string;,12
|
||||||
|
// app_market: uint64;
|
||||||
|
// email: string;
|
||||||
|
// timestamp: int64;
|
||||||
func AccountLoginWithTelephonePassword(ctx *gin.Context, param *AccountLoginWithTelephonePasswordParam, resp *basic.Response) {
|
func AccountLoginWithTelephonePassword(ctx *gin.Context, param *AccountLoginWithTelephonePasswordParam, resp *basic.Response) {
|
||||||
// ctx.ShouldBind()
|
// ctx.ShouldBind()
|
||||||
// model.Models.KillaraCustomerModel.Find()
|
// model.Models.KillaraCustomerModel.Find()
|
||||||
|
|
||||||
|
if param.CountryCode == "" {
|
||||||
|
resp.ErrorEx(1, "country_code 参数缺失")
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
if param.Telephone == "" {
|
||||||
|
resp.ErrorEx(1, "telephone 参数缺失")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if param.Password == "" {
|
||||||
|
resp.ErrorEx(1, "password 参数缺失")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
telephone := strings.TrimSpace(param.Telephone)
|
||||||
|
password := strings.TrimSpace(param.Password)
|
||||||
|
countryCode := strings.TrimSpace(param.CountryCode)
|
||||||
|
|
||||||
|
// 假设 modelCustomer 和 modelCustomerToken 是对应的服务接口
|
||||||
|
|
||||||
|
var customer *model.KillaraCustomer
|
||||||
|
var err error
|
||||||
|
|
||||||
|
customer, err = model.Models.KillaraCustomerModel.GetCustomerByTelephoneForBackEnd(telephone)
|
||||||
|
if err != nil {
|
||||||
|
resp.ErrorEx(1, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if customer == nil {
|
||||||
|
customer, err = model.Models.KillaraCustomerModel.GetCustomerByCode(telephone)
|
||||||
|
if err != nil {
|
||||||
|
resp.ErrorEx(1, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if customer == nil {
|
||||||
|
resp.ErrorEx(1, "账号未注册")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if *customer.CountryCode != countryCode {
|
||||||
|
resp.ErrorEx(1, "电话号码国家不正确")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if *customer.Status != 1 {
|
||||||
|
resp.ErrorEx(1, "账号已禁用,无法登录")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !auth.CheckPassword(*customer.Password, *customer.Salt, *customer.RandomPassword, password) {
|
||||||
|
resp.ErrorEx(1, "账号或密码错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
customerID := *customer.CustomerId
|
||||||
|
|
||||||
|
err = model.Models.KillaraCustomerTokenModel.UpdateTokenCustomerID(param.Token, customerID)
|
||||||
|
if err != nil {
|
||||||
|
resp.ErrorEx(1, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var deviceCode string
|
||||||
|
if param.Device != "" {
|
||||||
|
deviceCode = param.Device
|
||||||
|
}
|
||||||
|
|
||||||
|
var version string
|
||||||
|
if param.Version != "" {
|
||||||
|
version = param.Version
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip string
|
||||||
|
addr := strings.Split(ctx.Request.RemoteAddr, ":")
|
||||||
|
if len(addr) > 0 {
|
||||||
|
ip = addr[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println(deviceCode, version, ip)
|
||||||
|
|
||||||
|
// data := model.KillaraCustomerDevice{
|
||||||
|
// CustomerId: &customerID,
|
||||||
|
// Device: &deviceCode,
|
||||||
|
// Version: &version,
|
||||||
|
// Ip: &ip,
|
||||||
|
// AppMarket: ¶m.,
|
||||||
|
// Date: time.Now().Format("2006-01-02 15:04:05"),
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 假设 insertCustomerDevice 是对应的服务接口
|
||||||
|
// insertCustomerDevice(data)
|
||||||
|
|
||||||
|
// // 假设 clearDuplicateToken 是对应的服务接口
|
||||||
|
// clearDuplicateToken(customerID, param.Token)
|
||||||
|
|
||||||
|
// return map[string]interface{}{
|
||||||
|
// "success": true,
|
||||||
|
// "error_code": 0,
|
||||||
|
// "error_text": "",
|
||||||
|
// "data": make(map[string]interface{}),
|
||||||
|
// }, nil
|
||||||
|
|
||||||
// log.Println(param)
|
// log.Println(param)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package actions
|
package actions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"<no value>/utils/basic"
|
||||||
|
"<no value>/utils/log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/basic"
|
|
||||||
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var HandlersFuncRoutes map[string]gin.HandlerFunc = make(map[string]gin.HandlerFunc)
|
var HandlersFuncRoutes map[string]gin.HandlerFunc = make(map[string]gin.HandlerFunc)
|
||||||
|
@ -76,14 +77,18 @@ func AccountLoginWithEmailPasswordHandler(ctx *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountLoginWithTelephonePasswordParam struct {
|
type AccountLoginWithTelephonePasswordParam struct {
|
||||||
Action string `json:"action" form:"action" binding:"-"`
|
Randstr string `json:"randstr" form:"randstr" binding:"-"`
|
||||||
CountryCode string `json:"country_code" form:"country_code" binding:"-"`
|
Sign string `json:"sign" form:"sign" binding:"-"`
|
||||||
Device string `json:"device" form:"device" binding:"required"`
|
|
||||||
Lang string `json:"lang" form:"lang" binding:"-"`
|
|
||||||
Password string `json:"password" form:"password" binding:"-"`
|
|
||||||
Telephone string `json:"telephone" form:"telephone" binding:"-"`
|
Telephone string `json:"telephone" form:"telephone" binding:"-"`
|
||||||
Token string `json:"token" form:"token" binding:"required"`
|
Version string `json:"version" form:"version" binding:"-"`
|
||||||
Version string `json:"version" form:"version" binding:"required"`
|
Token string `json:"token" form:"token" binding:"-"`
|
||||||
|
CountryCode string `json:"country_code" form:"country_code" binding:"-"`
|
||||||
|
Password string `json:"password" form:"password" binding:"-"`
|
||||||
|
Action string `json:"action" form:"action" binding:"-"`
|
||||||
|
Device string `json:"device" form:"device" binding:"-"`
|
||||||
|
AppMarket uint64 `json:"app_market" form:"app_market" binding:"-"`
|
||||||
|
Email string `json:"email" form:"email" binding:"-"`
|
||||||
|
Timestamp int64 `json:"timestamp" form:"timestamp" binding:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func AccountLoginWithTelephonePasswordHandler(ctx *gin.Context) {
|
func AccountLoginWithTelephonePasswordHandler(ctx *gin.Context) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user