fix 对接短信接口

This commit is contained in:
ZJY 2021-09-19 10:23:02 +08:00
parent 9d41e9896f
commit f18b8b06cc
2 changed files with 105 additions and 0 deletions

View File

@ -421,6 +421,110 @@ func (c *LoginController) CkLogin() {
}
func (c *LoginController) SMSLogin() {
token := c.GetString("token")
cookie := c.GetString("ck")
//key := c.GetString("key")
//qq, _ := c.GetInt("qq")
//bz := c.GetString("bz")
//push := c.GetString("push")
logs.Info(cookie)
//logs.Info(key)
if token == models.Config.ApiToken {
result := Result{
Data: "null",
Code: 200,
Message: "添加成功",
}
jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
c.Ctx.WriteString(string(jsons))
} else {
result := Result{
Data: "null",
Code: 300,
Message: "Token错误",
}
jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
c.Ctx.WriteString(string(jsons))
}
//if key != "" && pin != "" {
// //ptKey := FetchJdCookieValue("pt_key", cookies)
// //ptPin := FetchJdCookieValue("pt_pin", cookies)
// ck := &models.JdCookie{
// PtKey: key,
// PtPin: pin,
// Hack: models.False,
// QQ: qq,
// Note: bz,
// PushPlus: push,
// }
// if key != "" && pin != "" {
// if models.CookieOK(ck) {
// query := ck.Query()
// result := Result{
// Data: query,
// Code: 0,
// }
//
// if !models.HasPin(pin) {
// models.NewJdCookie(ck)
// result.Message = fmt.Sprintf("添加成功")
// result.Data = ck.Query()
// jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
// if errs != nil {
// fmt.Println(errs.Error())
// }
// c.Ctx.Redirect(200, "/userCenter")
// c.Ctx.WriteString(string(jsons))
// } else if !models.HasKey(key) {
// ck, _ := models.GetJdCookie(pin)
// ck.InPool(key)
// result.Message = fmt.Sprintf("更新成功")
// result.Data = ck.Query()
// jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
// if errs != nil {
// fmt.Println(errs.Error())
// }
// c.Ctx.WriteString(string(jsons))
// }
// } else {
// result := Result{
// Data: "null",
// Code: 1,
// Message: "CK过期",
// }
// jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
// if errs != nil {
// fmt.Println(errs.Error())
// }
// c.Ctx.WriteString(string(jsons))
// }
// }
//} else {
// result := Result{
// Data: "null",
// Code: 2,
// Message: "ck格式错误",
// }
// jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
// if errs != nil {
// fmt.Println(errs.Error())
// }
// c.Ctx.WriteString(string(jsons))
//}
}
func (c *LoginController) Cookie() {
cookies := c.Ctx.Input.Header("Set-Cookie")
pt_key := FetchJdCookieValue("pt_key", cookies)

View File

@ -57,6 +57,7 @@ func main() {
web.Router("/api/login/cookie", &controllers.LoginController{}, "get:Cookie")
web.Router("/api/login/admin", &controllers.LoginController{}, "post:IsAdmin")
web.Router("/api/login/cklogin", &controllers.LoginController{}, "post:CkLogin")
web.Router("/api/login/smslogin", &controllers.LoginController{}, "post:SMSLogin")
web.Router("/api/account", &controllers.AccountController{}, "get:List")
web.Router("/api/account", &controllers.AccountController{}, "post:CreateOrUpdate")
web.Router("/admin", &controllers.AccountController{}, "get:Admin")