🐛 经纬度修复
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
import (
|
||||
"likedream-goframe/internal/framework/captcha"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type CpSchoolListReq struct {
|
||||
g.Meta `path:"/school" method:"get" tags:"CpSchool" summary:"获取cp学校列表"`
|
||||
@@ -14,6 +18,21 @@ type CpUserAddReq struct {
|
||||
SchoolId string `json:"school_id"`
|
||||
Email string `json:"email" v:"email|regex:^.*@qq\\.com$#邮箱格式不正确|必须是QQ邮箱"`
|
||||
}
|
||||
type LoginGetCode struct {
|
||||
g.Meta `path:"/user/getCode" method:"post" tags:"CpUser" summary:"获取手机号登录验证码"`
|
||||
Mobile string `json:"mobile" v:"required#手机号不能为空"`
|
||||
CaptchaKey string `json:"captchaKey" v:"required#验证码不能不能为空"`
|
||||
Dots []captcha.ConfirmData `json:"dots" v:"required#验证码不能为空"`
|
||||
}
|
||||
|
||||
type AddByCode struct {
|
||||
g.Meta `path:"/user/addByCode" method:"post" tags:"CpUser" summary:"手机号登录"`
|
||||
CaptchaKey string `json:"captchaKey" v:"required#验证码不能不能为空"`
|
||||
Dots []captcha.ConfirmData `json:"dots" v:"required#验证码不能为空"`
|
||||
Mobile string `json:"mobile" v:"required#手机号不能为空"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type CpUserConfirmAddReq struct {
|
||||
g.Meta `path:"/user/confirm" method:"post" tags:"CpUser" summary:"多因子确认添加cp用户"`
|
||||
Key string `json:"key"`
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cryptoutil
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAesDecrypt(t *testing.T) {
|
||||
str := "szFn6zAbjjU="
|
||||
decodeString, _ := base64.StdEncoding.DecodeString(str)
|
||||
decrypt := AesDecrypt(decodeString)
|
||||
t.Log(string(decrypt))
|
||||
encrypt := AesEncrypt([]byte("c9fe4f05-e1ed-4c15-aeb4-b05fa9bfb16f"))
|
||||
t.Log(base64.StdEncoding.EncodeToString(encrypt))
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"likedream-goframe/internal/application/cpdaily/cryptoutil"
|
||||
"likedream-goframe/internal/application/httpclient"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"resty.dev/v3"
|
||||
)
|
||||
|
||||
type CpdailyCodeLogin struct {
|
||||
client *resty.Client
|
||||
}
|
||||
|
||||
func NewCode(ctx context.Context) *CpdailyCodeLogin {
|
||||
return &CpdailyCodeLogin{
|
||||
client: httpclient.NewCpdailyClient(),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CpdailyCodeLogin) GetLoginCode(mobile string) {
|
||||
mobileBytes := cryptoutil.AesEncrypt([]byte(mobile))
|
||||
mobile = base64.StdEncoding.EncodeToString(mobileBytes)
|
||||
c.client.R().SetBody(map[string]string{
|
||||
"a": mobile,
|
||||
"b": "first_v4",
|
||||
}).Post("https://mobile.campushoy.com/app/auth/authentication/mobile/messageCode/v-8222")
|
||||
}
|
||||
|
||||
func (c *CpdailyCodeLogin) LoginByCode(mobile, code string) {
|
||||
type loginStruct struct {
|
||||
C string `json:"c"`
|
||||
D string `json:"d"`
|
||||
E string `json:"e"`
|
||||
F string `json:"f"`
|
||||
}
|
||||
data := loginStruct{
|
||||
C: mobile,
|
||||
D: code,
|
||||
E: "CPDAILY",
|
||||
F: "86",
|
||||
}
|
||||
marshal, _ := sonic.Marshal(data)
|
||||
marshalBytes := cryptoutil.AesEncrypt(marshal)
|
||||
c.client.R().SetBody(map[string]string{
|
||||
"a": base64.StdEncoding.EncodeToString(marshalBytes),
|
||||
"b": "first_v4",
|
||||
}).Post("https://mobile.campushoy.com/app/auth/authentication/mobileLogin/v-8222")
|
||||
}
|
||||
@@ -495,6 +495,11 @@ func (c *CpdailyAutoSignTask) FillCustomForm(ctx context.Context, form map[strin
|
||||
lon = v.Content
|
||||
case "address":
|
||||
address = v.Content
|
||||
case "latAndLon":
|
||||
{
|
||||
res := strings.Split(v.Content, ",")
|
||||
lat, lon = res[1], res[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ func (c *CpdailySleepCheckTask) FillCustomForm(ctx context.Context, form map[str
|
||||
case "latAndLon":
|
||||
{
|
||||
res := strings.Split(v.Content, ",")
|
||||
lat, lon = res[0], res[1]
|
||||
lat, lon = res[1], res[0]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,3 +61,12 @@ func (c CpUserCtrlV1) AuthorizeRandom(ctx context.Context, req *v1.CpUserAuthori
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpUser.AuthorizeRandom(ctx, req), nil
|
||||
}
|
||||
func (c CpUserCtrlV1) LoginGetCode(ctx context.Context, req *v1.LoginGetCode) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpUser.LoginGetCode(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpUserCtrlV1) AddByCode(ctx context.Context, req *v1.AddByCode) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpUser.AddByCode(ctx, req), nil
|
||||
}
|
||||
|
||||
@@ -25,4 +25,8 @@ type ICpUserCtrlV1 interface {
|
||||
AuthorizeConfirm(ctx context.Context, req *v1.CpUserAuthorizeConfirmReq) (*utils.Response[any], error)
|
||||
// 随机授权
|
||||
AuthorizeRandom(ctx context.Context, req *v1.CpUserAuthorizeRandomReq) (res *utils.Response[any], err error)
|
||||
|
||||
// 手机登录获取验证码
|
||||
LoginGetCode(ctx context.Context, req *v1.LoginGetCode) (*utils.Response[any], error)
|
||||
AddByCode(ctx context.Context, req *v1.AddByCode) (*utils.Response[any], error)
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ func (v CpUserServiceV1) Add(ctx context.Context, req *v1.CpUserAddReq) *utils.R
|
||||
SaveX(ctx)
|
||||
return utils.SuccessWithMsg("添加成功")
|
||||
}
|
||||
|
||||
func (v CpUserServiceV1) ConfirmAdd(ctx context.Context, req *v1.CpUserConfirmAddReq) *utils.Response[any] {
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
schoolInfo, err := redis.GetClient().Get(ctx, req.Key+":school").Result()
|
||||
@@ -171,3 +172,11 @@ func (v CpUserServiceV1) AuthorizeRandom(ctx context.Context, req *v1.CpUserAuth
|
||||
db.Global.CpUser.UpdateOne(cpUser).SetMobileCode(utils.UUID()).SetMobileType(cpuser.MobileTypeRandom).ExecX(ctx)
|
||||
return utils.SuccessWithMsg("已改为随机设备码")
|
||||
}
|
||||
|
||||
func (v CpUserServiceV1) LoginGetCode(ctx context.Context, req *v1.LoginGetCode) *utils.Response[any] {
|
||||
|
||||
}
|
||||
|
||||
func (v CpUserServiceV1) AddByCode(ctx context.Context, req *v1.AddByCode) *utils.Response[any] {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user