|
|
@@ -0,0 +1,57 @@
|
|
|
+package partial
|
|
|
+
|
|
|
+import (
|
|
|
+ "git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
|
|
|
+ //sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
|
|
|
+ //sysutils "git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
|
|
|
+ //"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
|
|
|
+ sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
|
|
|
+ //__import_packages__
|
|
|
+ "github.com/dchest/captcha"
|
|
|
+ "bytes"
|
|
|
+)
|
|
|
+
|
|
|
+const captcha_session = "image_captcha"
|
|
|
+
|
|
|
+// _Image
|
|
|
+// @Title _Image
|
|
|
+// @Description 获取图片验证码
|
|
|
+// @Success 200 {object} Account
|
|
|
+// @Failure 403 :id is empty
|
|
|
+func Captcha_Image(c *entitys.CtrlContext) {
|
|
|
+ var content bytes.Buffer
|
|
|
+
|
|
|
+ captchaId := captcha.New()
|
|
|
+
|
|
|
+ c.Ctx.Set(captcha_session, captchaId)
|
|
|
+
|
|
|
+ err := captcha.WriteImage(&content, captchaId, 240, 80)
|
|
|
+ if err == nil {
|
|
|
+ c.Ctx.Header("Content-Type", "image/png")
|
|
|
+ c.Ctx.Writer.Write(content.Bytes())
|
|
|
+ c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
|
|
|
+ } else {
|
|
|
+ c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// _Sms
|
|
|
+// @Title _Sms
|
|
|
+// @Description 获取短信验证码
|
|
|
+// @Param phone string false "手机号码"
|
|
|
+// @Success 200 {object} Account
|
|
|
+// @Failure 403 :id is empty
|
|
|
+func Captcha_Sms(c *entitys.CtrlContext) {
|
|
|
+ phone := c.Ctx.Query("phone")
|
|
|
+
|
|
|
+ ret := __none_func_captcha__(phone)
|
|
|
+ if ret {
|
|
|
+ c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
|
|
|
+ } else {
|
|
|
+ c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func __none_func_captcha__(params ... interface{}) bool {
|
|
|
+ return true
|
|
|
+}
|