|
- package svc
-
- import (
- "applet/app/e"
- "code.fnuoos.com/EggPlanet/egg_system_rules.git/aliyun"
- "code.fnuoos.com/EggPlanet/egg_system_rules.git/mob"
- "errors"
- "fmt"
- "github.com/gin-gonic/gin"
- )
-
- func CommSmsSend(c *gin.Context, mobile, types string) error {
- smsPlatform := GetSysCfgStr("sms_platform")
- var err error
- if smsPlatform == "mob" {
- err = mob.MobSms(GetSysCfgStr("mob_key"), mobile, GetSysCfgStr("mob_temple_code"))
- if err != nil {
- fmt.Println("短信错误:" + err.Error())
- return err
- }
- } else {
- data := AliyunSmsBase(c, types)
- //发送短信
- err = aliyun.AliyunSendSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], mobile, data["aliyun_sms_sign_name"], data["aliyun_sms_code"], "")
- if err != nil {
- fmt.Println("短信错误:" + err.Error())
- return errors.New("发送失败")
- }
- }
- return nil
- }
-
- func CommSmsCheck(c *gin.Context, mobile, code string) error {
- //校验短信
- smsPlatform := GetSysCfgStr("sms_platform")
- var err error
- var bools bool
- if smsPlatform == "mob" {
- bools, err = mob.MobSMSCheck(GetSysCfgStr("mob_key"), mobile, code)
- if err != nil {
- fmt.Println("短信错误:" + err.Error())
- return err
- }
- if bools == false {
- return e.NewErr(400, "验证码错误,请重试")
- }
- } else {
- data := AliyunSmsBase(c, "")
- err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], mobile, code)
- if err != nil {
- return e.NewErr(400, "验证码错误,请重试")
- }
- }
- return nil
- }
|