This commit is contained in:
苏尹岚
2020-10-12 18:29:34 +08:00
parent 6aa221391a
commit 32506c47d4
5 changed files with 61 additions and 286 deletions

View File

@@ -1,205 +0,0 @@
package controllers
// type WeixinCallbackResult struct {
// Code int `json:"code"`
// Msg string `json:"msg"`
// Data interface{} `json:"data"`
// }
// // 认证相关API
// type AuthController struct {
// beego.Controller
// }
// var (
// ErrParameterIsIllegal = "参数不全或不合法"
// )
// // @Title 给微信用的回调接口
// // @Description 给微信用的回调接口,自己不能直接调用
// // @Param code query string true "客户同意后得到的code"
// // @Param block query string true "回调地址"
// // @Param state query string false "微信回调的登录状态"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /GetWeiXinUserInfo [get]
// func (c *AuthController) GetWeiXinUserInfo() {
// retVal := &WeixinCallbackResult{}
// var err error
// code := c.GetString("code")
// block := c.GetString("block")
// state := c.GetString("state")
// if block != "" {
// if code != "" {
// result, err2 := weixin.GetWeiXinUserInfo(code, state)
// if err = err2; err == nil {
// retVal.Code = 1
// retVal.Msg = "微信登录成功"
// retVal.Data = result
// } else {
// retVal.Msg = err.Error()
// }
// } else {
// retVal.Msg = "code为空"
// }
// } else {
// retVal.Msg = "没有block"
// }
// redirectURL := fmt.Sprintf("%s?info=%s", block, base64.StdEncoding.EncodeToString(utils.MustMarshal(retVal)))
// globals.SugarLogger.Debugf("auth GetWeiXinUserInfo retVal:%s, redirectURL:%s", utils.Format4Output(retVal, true), redirectURL)
// c.Redirect(redirectURL, http.StatusTemporaryRedirect)
// }
// // @Title 登录接口
// // @Description 登录接口
// // @Param id formData string false "登录ID"
// // @Param type formData string true "登录类型,当前支持[weixinsns微信公众号登录localpass本地账号密码mobile手机短信weixinmini小程序code登录]"
// // @Param secret formData string true "不同登录类型的登录秘密"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /Login [post]
// func (c *AuthController) Login() {
// c.callLogin(func(params *tAuthLoginParams) (retVal interface{}, errCode string, err error) {
// if params.Type == weixin.LoginTypeMiniProgram {
// params.Secret = GetComposedCode(&c.Controller, params.Secret)
// }
// retVal, err = auth.Login(params.Id, params.Type, params.Secret)
// if err == auth.ErrUserNotExist {
// return retVal, model.ErrCodeUserNotExist, err
// }
// return retVal, "", err
// })
// }
// // @Title 登出接口
// // @Description 登出接口
// // @Param token header string true "认证token"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /Logout [delete]
// func (c *AuthController) Logout() {
// c.callLogout(func(params *tAuthLogoutParams) (retVal interface{}, errCode string, err error) {
// err = auth.Logout(params.Token)
// globals.SugarLogger.Debug(err)
// return nil, "", err
// })
// }
// // @Title 得到用户信息
// // @Description 得到用户信息从token中
// // @Param token header string true "认证token"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /GetUserInfo [get]
// func (c *AuthController) GetUserInfo() {
// c.callGetUserInfo(func(params *tAuthGetUserInfoParams) (retVal interface{}, errCode string, err error) {
// retVal, err = auth.GetUserInfo(params.Token)
// return retVal, "", err
// })
// }
// // @Title 发送验证码
// // @Description 发送验证码
// // @Param mobile formData string true "手机号"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /SendMobileVerifyCode [post]
// func (c *AuthController) SendMobileVerifyCode() {
// c.callSendMobileVerifyCode(func(params *tAuthSendMobileVerifyCodeParams) (retVal interface{}, errCode string, err error) {
// err = mobile.SendVerifyCode(params.Mobile)
// return retVal, "", err
// })
// }
// // @Title 绑定手机
// // @Description 绑定手机,待删除
// // @Param token header string true "认证token"
// // @Param mobile formData string true "手机号"
// // @Param code formData string true "验证码"
// // @Param nickname formData string false "用户名"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /BindMobile [post]
// func (c *AuthController) BindMobile() {
// c.callBindMobile(func(params *tAuthBindMobileParams) (retVal interface{}, errCode string, err error) {
// err = weixin.BindMobile(params.Token, params.Mobile, params.Code, params.Nickname)
// if err == auth.ErrUserNotExist {
// return retVal, model.ErrCodeUserNotExist, err
// }
// return retVal, "", err
// })
// }
// // @Title 微信公众号绑定手机2
// // @Description 微信公众号绑定手机2
// // @Param openID formData string true "微信公众号ID"
// // @Param secret formData string true "后台之前返回的secret"
// // @Param nickname formData string false "用户名"
// // @Param mobile formData string true "手机号"
// // @Param verifyCode formData string true "手机验证码"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /BindMobile2 [post]
// func (c *AuthController) BindMobile2() {
// c.callBindMobile2(func(params *tAuthBindMobile2Params) (retVal interface{}, errCode string, err error) {
// if retVal, err = weixin.BindMobile2(params.OpenID, params.Secret, params.Mobile, params.VerifyCode, params.Nickname); err == nil {
// cms.TransferLegacyWeixins(params.Mobile)
// } else if err == auth.ErrUserNotExist {
// return retVal, model.ErrCodeUserNotExist, err
// }
// return retVal, "", err
// })
// }
// // @Title 绑定手机
// // @Description 绑定手机(调用此方法前先需要以短信方式登录),待删除
// // @Param token header string true "认证token"
// // @Param code formData string true "小程序用户code"
// // @Param nickname formData string false "用户名"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /MiniBindWeiXin [post]
// func (c *AuthController) MiniBindWeiXin() {
// c.callMiniBindWeiXin(func(params *tAuthMiniBindWeiXinParams) (retVal interface{}, errCode string, err error) {
// err = weixin.AutherMini.BindWeiXin(params.Ctx, GetComposedCode(&c.Controller, params.Code), params.Nickname)
// if err == auth.ErrUserNotExist {
// return retVal, model.ErrCodeUserNotExist, err
// }
// return retVal, "", err
// })
// }
// // @Title 绑定小程序
// // @Description 绑定小程序
// // @Param token header string true "认证token"
// // @Param code formData string true "小程序用户code"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /BindMiniProgram [post]
// func (c *AuthController) BindMiniProgram() {
// c.callBindMiniProgram(func(params *tAuthBindMiniProgramParams) (retVal interface{}, errCode string, err error) {
// err = weixin.AutherMini.BindMiniProgram(params.Ctx, GetComposedCode(&c.Controller, params.Code))
// if err == nil {
// cms.TransferLegacyWeixins(params.Ctx.GetLoginID())
// }
// if err == auth.ErrUserNotExist {
// return retVal, model.ErrCodeUserNotExist, err
// }
// return retVal, "", err
// })
// }
// // @Title 解密小程序数据
// // @Description 解密小程序数据
// // @Param token header string true "认证token"
// // @Param data formData string true "加密数据"
// // @Param iv formData string true "iv"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /MiniDecryptData [post]
// func (c *AuthController) MiniDecryptData() {
// c.callMiniDecryptData(func(params *tAuthMiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
// retVal, err = weixin.AutherMini.DecryptData(params.Ctx, params.Data, params.Iv)
// return retVal, "", err
// })
// }

View File

@@ -0,0 +1,21 @@
package controllers
import (
"github.com/astaxie/beego"
)
type OrderController struct {
beego.Controller
}
// @Title 支付
// @Description 支付
// @Param token header string true "认证token"
// @Param userID query string true "用户ID"
// @Param roleList query string true "角色列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /Pay [post]
func (c *OrderController) Pay() {
}