作者 tangxvhui

日常保存

1 package domain 1 package domain
2 2
3 -import "testing" 3 +import (
  4 + "testing"
  5 +
  6 + "github.com/dgrijalva/jwt-go"
  7 +)
4 8
5 func TestGenerateToken(t *testing.T) { 9 func TestGenerateToken(t *testing.T) {
6 ut := UserAuth{ 10 ut := UserAuth{
@@ -24,5 +28,9 @@ func TestParsetToken2(t *testing.T) { @@ -24,5 +28,9 @@ func TestParsetToken2(t *testing.T) {
24 ut := UserAuth{} 28 ut := UserAuth{}
25 str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ` 29 str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ`
26 tk, _ := ut.ParseAccessToken(str) 30 tk, _ := ut.ParseAccessToken(str)
27 - t.Logf("%+v", tk) 31 + t.Logf("===》%+v", tk)
  32 + tk.StandardClaims = jwt.StandardClaims{}
  33 + tk.PlatformId = 29
  34 + tkStr, _ := tk.CreateAccessToken()
  35 + t.Logf(" ===》%v", tkStr)
28 } 36 }
@@ -36,6 +36,7 @@ func (repo *LogSmsRepository) Save(param *domain.LogSms) error { @@ -36,6 +36,7 @@ func (repo *LogSmsRepository) Save(param *domain.LogSms) error {
36 if err != nil { 36 if err != nil {
37 return err 37 return err
38 } 38 }
  39 + return nil
39 } 40 }
40 _, err := tx.Model(&m).WherePK().Update() 41 _, err := tx.Model(&m).WherePK().Update()
41 if err != nil { 42 if err != nil {
@@ -27,7 +27,7 @@ func (controller *AuthController) User() { @@ -27,7 +27,7 @@ func (controller *AuthController) User() {
27 }, nil) 27 }, nil)
28 } 28 }
29 29
30 -// Login PC端登录 30 +// Login 手机端登录
31 func (controller *AuthController) MobileLogin() { 31 func (controller *AuthController) MobileLogin() {
32 authService := &service.AuthService{} 32 authService := &service.AuthService{}
33 loginCommand := &command.MobileLoginCommand{} 33 loginCommand := &command.MobileLoginCommand{}