| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package controller
- import (
- "net/http"
- "video_course/service"
- "github.com/sirupsen/logrus"
- "github.com/mojocn/base64Captcha"
- )
- type Auth struct {
- BaseController
- }
- // SignUp godoc
- // @Summary 用户添加
- // @tags Auth
- // @Description 用户添加
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param userCode formData string true "用户名"
- // @Param password formData string true "密码"
- // @Param email formData string false "邮箱"
- // @Param phone formData string false "手机号"
- // @Param name formData string false "姓名"
- // @Success 200 {object} controller.ResponseBase
- // @Router /Auth/SignUp [post]
- func (a *Auth) HttpPostSignUp() (err error) {
- userCode := a.Ctx().PostForm("userCode")
- test := a.PostFromInt("test")
- test2 := a.PostFromIntPtr("test2")
- logrus.Info(userCode, test, test2)
- a.Ctx().JSON(http.StatusOK, newResponseBase())
- return
- }
- type ResponseVerifyPic struct {
- Id string
- Pic string
- }
- // GenVerifyPic godoc
- // @Summary 获取验证图片
- // @tags Auth
- // @Description 获取验证图片和验证id
- // @Accept x-www-form-urlencoded
- // @Param height formData string true "高"
- // @Param width formData string true "宽"
- // @Param noiseCount formData string true "噪点数量"
- // @Param length formData string true "验证码字数"
- // @Param source formData string true "验证码取值范围 比如 1234567890 或者 abcdef等"
- // @Produce json
- // @Success 200 {object} controller.ResponseVerifyPic
- // @Router /Auth/GenVerifyPic [post]
- func (a *Auth) GenVerifyPic() (err error) {
- config := &base64Captcha.DriverString{}
- config.Height = a.postIntNecessary("height")
- config.Width = a.postIntNecessary("width")
- config.NoiseCount = a.postIntNecessary("noiseCount")
- config.Length = a.postIntNecessary("length")
- config.Source = a.Ctx().PostForm("source")
- if config.Source == "" {
- config.Source = "1234567890"
- }
- id, pic := service.Auth{}.GenVerifyPic(config)
- r := ResponseVerifyPic{
- id,
- pic,
- }
- a.Ctx().JSON(http.StatusOK, r)
- return
- }
- // GetPhoneVFCode godoc
- // @Summary 手机获取验证码
- // @tags Auth
- // @Description 手机获取验证码
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param phone formData string true "手机号"
- // @Param codeType formData int true "验证码类型 1:登录"
- // @Param picId formData string true "图形验证码id"
- // @Param picCode formData string true "图形验证码"
- // @Success 200 {object} controller.ResponseBase
- // @Router /Auth/GetPhoneVFCode [post]
- func (a *Auth) GetPhoneVFCode() (err error) {
- phone := a.postString("phone", true)
- codeType := a.postIntNecessary("codeType")
- picId := a.Ctx().PostForm("picId")
- picCode := a.Ctx().PostForm("picCode")
- service.Auth{}.GenVFCode(codeType, phone, a.getIp(), picId, picCode)
- a.json(newResponseBase())
- return
- }
|