diff --git a/app/controllers/userController/reg.go b/app/controllers/userController/reg.go index b15f33e..8a0a875 100644 --- a/app/controllers/userController/reg.go +++ b/app/controllers/userController/reg.go @@ -17,7 +17,7 @@ type createStudentUserForm struct { StudentID string `json:"studentID" binding:"required"` IDCardNumber string `json:"idCardNumber" binding:"required"` Email string `json:"email" binding:"required"` - LoginType string `json:"type"` + Type uint `json:"type" ` // 用户类型 0-本科生 1-研究生 } type createStudentUserWechatForm struct { Username string `json:"username" binding:"required"` @@ -26,7 +26,7 @@ type createStudentUserWechatForm struct { IDCardNumber string `json:"idCardNumber" binding:"required"` Email string `json:"email" binding:"required"` Code string `json:"code" binding:"required"` - LoginType string `json:"type"` + Type uint `json:"type" ` // 用户类型 0-本科生 1-研究生 } func BindOrCreateStudentUserFromWechat(c *gin.Context) { @@ -52,7 +52,8 @@ func BindOrCreateStudentUserFromWechat(c *gin.Context) { postForm.StudentID, postForm.IDCardNumber, postForm.Email, - session.OpenID) + session.OpenID, + postForm.Type) if err != nil && err != apiException.ReactiveError { _ = c.AbortWithError(200, err) return @@ -87,7 +88,8 @@ func CreateStudentUser(c *gin.Context) { postForm.Password, postForm.StudentID, postForm.IDCardNumber, - postForm.Email) + postForm.Email, + postForm.Type) if err != nil && err != apiException.ReactiveError { _ = c.AbortWithError(200, err) return diff --git a/app/services/userCenterServices/auth.go b/app/services/userCenterServices/auth.go index 584ccfe..7175756 100644 --- a/app/services/userCenterServices/auth.go +++ b/app/services/userCenterServices/auth.go @@ -14,9 +14,10 @@ func Login(stu_id string, pass string) error { } Url.RawQuery = params.Encode() urlPath := Url.String() - regMap := make(map[string]string) + regMap := make(map[string]any) regMap["stu_id"] = stu_id regMap["password"] = pass + regMap["bound_system"] = 0 resp, err := FetchHandleOfPost(regMap, userCenterApi.UserCenterApi(urlPath)) if err != nil { return apiException.RequestError diff --git a/app/services/userCenterServices/del.go b/app/services/userCenterServices/del.go index a6e1bd1..37390ac 100644 --- a/app/services/userCenterServices/del.go +++ b/app/services/userCenterServices/del.go @@ -1,6 +1,7 @@ package userCenterServices import ( + "fmt" "net/url" "wejh-go/app/apiException" "wejh-go/config/api/userCenterApi" @@ -15,10 +16,12 @@ func DelAccount(stuID, iid string) error { } Url.RawQuery = params.Encode() urlPath := Url.String() - regMap := make(map[string]string) + regMap := make(map[string]any) regMap["stuid"] = stuID regMap["iid"] = iid + regMap["bound_system"] = 0 resp, err := FetchHandleOfPost(regMap, userCenterApi.UserCenterApi(urlPath)) + fmt.Println(resp) if err != nil { return err } diff --git a/app/services/userCenterServices/reg.go b/app/services/userCenterServices/reg.go index 3919373..a5b0dba 100644 --- a/app/services/userCenterServices/reg.go +++ b/app/services/userCenterServices/reg.go @@ -6,7 +6,7 @@ import ( "wejh-go/config/api/userCenterApi" ) -func RegWithoutVerify(stu_id string, pass string, iid string, email string) error { +func RegWithoutVerify(stu_id string, pass string, iid string, email string, userType uint) error { params := url.Values{} Url, err := url.Parse(string(userCenterApi.UCRegWithoutVerify)) if err != nil { @@ -14,11 +14,13 @@ func RegWithoutVerify(stu_id string, pass string, iid string, email string) erro } Url.RawQuery = params.Encode() urlPath := Url.String() - regMap := make(map[string]string) + regMap := make(map[string]any) regMap["stu_id"] = stu_id regMap["password"] = pass regMap["iid"] = iid regMap["email"] = email + regMap["type"] = userType + regMap["bound_system"] = 0 resp, err := FetchHandleOfPost(regMap, userCenterApi.UserCenterApi(urlPath)) if err != nil { return err diff --git a/app/services/userCenterServices/repass.go b/app/services/userCenterServices/repass.go index cc1d2bd..d157547 100644 --- a/app/services/userCenterServices/repass.go +++ b/app/services/userCenterServices/repass.go @@ -15,7 +15,7 @@ func ResetPass(stuID, iid, password string) error { } Url.RawQuery = params.Encode() urlPath := Url.String() - regMap := make(map[string]string) + regMap := make(map[string]any) regMap["stuid"] = stuID regMap["iid"] = iid regMap["pwd"] = password diff --git a/app/services/userCenterServices/userCenterService.go b/app/services/userCenterServices/userCenterService.go index 062220c..e00405a 100644 --- a/app/services/userCenterServices/userCenterService.go +++ b/app/services/userCenterServices/userCenterService.go @@ -13,7 +13,7 @@ type UserCenterResponse struct { Data interface{} `json:"data"` } -func FetchHandleOfPost(form map[string]string, url userCenterApi.UserCenterApi) (*UserCenterResponse, error) { +func FetchHandleOfPost(form map[string]any, url userCenterApi.UserCenterApi) (*UserCenterResponse, error) { f := fetch.Fetch{} f.Init() res, err := f.PostJsonForm(userCenterApi.UserCenterHost+string(url), form) diff --git a/app/services/userServices/create.go b/app/services/userServices/create.go index 7c1aa34..52cb629 100755 --- a/app/services/userServices/create.go +++ b/app/services/userServices/create.go @@ -10,11 +10,11 @@ import ( "wejh-go/config/database" ) -func CreateStudentUser(username, password, studentID, IDCardNumber, email string) (*models.User, error) { +func CreateStudentUser(username, password, studentID, IDCardNumber, email string, userType uint) (*models.User, error) { if CheckUsername(username) { return nil, apiException.UserAlreadyExisted } - err := userCenterServices.RegWithoutVerify(studentID, password, IDCardNumber, email) + err := userCenterServices.RegWithoutVerify(studentID, password, IDCardNumber, email, userType) if err != nil && err != apiException.ReactiveError { return nil, err } @@ -26,7 +26,7 @@ func CreateStudentUser(username, password, studentID, IDCardNumber, email string user := &models.User{ JHPassword: pass, Username: username, - Type: models.Undergraduate, + Type: models.UserType(userType), StudentID: studentID, LibPassword: "", PhoneNum: "", @@ -41,11 +41,11 @@ func CreateStudentUser(username, password, studentID, IDCardNumber, email string return user, res.Error } -func CreateStudentUserWechat(username, password, studentID, IDCardNumber, email, wechatOpenID string) (*models.User, error) { +func CreateStudentUserWechat(username, password, studentID, IDCardNumber, email, wechatOpenID string, userType uint) (*models.User, error) { if CheckWechatOpenID(wechatOpenID) { return nil, apiException.OpenIDError } - user, err := CreateStudentUser(username, password, studentID, IDCardNumber, email) + user, err := CreateStudentUser(username, password, studentID, IDCardNumber, email, userType) if err != nil && err != apiException.ReactiveError { return nil, err } diff --git a/app/services/userServices/del.go b/app/services/userServices/del.go index 0e44b3d..5eb71bb 100644 --- a/app/services/userServices/del.go +++ b/app/services/userServices/del.go @@ -7,7 +7,6 @@ import ( ) func DelAccount(user *models.User, iid string) error { - if err := userCenterServices.DelAccount(user.Username, iid); err != nil { return err } diff --git a/app/services/yxyServices/bindService.go b/app/services/yxyServices/bindService.go index d0aa330..8888c68 100644 --- a/app/services/yxyServices/bindService.go +++ b/app/services/yxyServices/bindService.go @@ -67,7 +67,7 @@ func GetCaptchaImage(deviceId, securityToken string) (*string, error) { } func SendVerificationCode(securityToken, deviceId, phoneNum string) error { - form := make(map[string]string) + form := make(map[string]any) form["phone_num"] = phoneNum form["security_token"] = securityToken form["captcha"] = "" @@ -95,7 +95,7 @@ func SendVerificationCode(securityToken, deviceId, phoneNum string) error { } func LoginByCode(code, deviceId, phoneNum string) (*string, error) { - form := make(map[string]string) + form := make(map[string]any) form["phone_num"] = phoneNum form["code"] = code form["device_id"] = deviceId @@ -121,7 +121,7 @@ func LoginByCode(code, deviceId, phoneNum string) (*string, error) { } func SilentLogin(deviceId, uid, phoneNum string) error { - form := make(map[string]string) + form := make(map[string]any) form["uid"] = uid form["device_id"] = deviceId form["phone_num"] = phoneNum diff --git a/app/services/yxyServices/yxyService.go b/app/services/yxyServices/yxyService.go index 8fba45a..24e1397 100644 --- a/app/services/yxyServices/yxyService.go +++ b/app/services/yxyServices/yxyService.go @@ -14,7 +14,7 @@ type YxyResponse struct { Data interface{} `json:"data"` } -func FetchHandleOfPost(form map[string]string, url yxyApi.YxyApi) (*YxyResponse, error) { +func FetchHandleOfPost(form map[string]any, url yxyApi.YxyApi) (*YxyResponse, error) { f := fetch.Fetch{} f.Init() res, err := f.PostJsonForm(yxyApi.YxyHost+string(url), form) diff --git a/app/utils/fetch/fetch.go b/app/utils/fetch/fetch.go index 53f5ec0..d0741fd 100644 --- a/app/utils/fetch/fetch.go +++ b/app/utils/fetch/fetch.go @@ -84,7 +84,7 @@ func (f *Fetch) PostForm(url string, requestData url.Values) ([]byte, error) { return ioutil.ReadAll(response.Body) } -func (f *Fetch) PostJsonFormRaw(url string, requestData map[string]string) (*http.Response, error) { +func (f *Fetch) PostJsonFormRaw(url string, requestData map[string]any) (*http.Response, error) { bytesData, _ := json.Marshal(requestData) request, _ := http.NewRequest("POST", url, bytes.NewReader(bytesData)) request.Header.Set("Content-Type", "application/json") @@ -94,7 +94,7 @@ func (f *Fetch) PostJsonFormRaw(url string, requestData map[string]string) (*htt return f.client.Do(request) } -func (f *Fetch) PostJsonForm(url string, requestData map[string]string) ([]byte, error) { +func (f *Fetch) PostJsonForm(url string, requestData map[string]any) ([]byte, error) { response, err := f.PostJsonFormRaw(url, requestData) if err != nil { return nil, err