Kaynağa Gözat

feat:调整

wangshan 1 yıl önce
ebeveyn
işleme
a1d485e0a6
2 değiştirilmiş dosya ile 42 ekleme ve 41 silme
  1. 17 0
      src/entity/entity.go
  2. 25 41
      src/service/action/info.go

+ 17 - 0
src/entity/entity.go

@@ -1 +1,18 @@
 package entity
+
+// 接口统一返回值
+type NewResultSales struct {
+	Error_code int         `json:"error_code"`
+	Error_msg  string      `json:"error_msg"`
+	Data       interface{} `json:"data"`
+	Url        string      `json:"url"`
+	ActiveHref string      `json:"activeHref"`
+}
+
+type FuncResult struct {
+	Data       interface{}            `json:"data"`
+	Info       map[string]interface{} `json:"info"`
+	Active     map[string]interface{} `json:"active"`
+	Error_code int                    `json:"error_code"`
+	Error_msg  string                 `json:"error_msg"`
+}

+ 25 - 41
src/service/action/info.go

@@ -7,6 +7,7 @@ import (
 	"log"
 	"regexp"
 	. "salesLeads/src/config"
+	"salesLeads/src/entity"
 	. "salesLeads/src/util"
 	"strings"
 	"time"
@@ -48,49 +49,32 @@ func init() {
 	xweb.AddAction(&Info{})
 }
 
-// 接口统一返回值
-type NewResultSales struct {
-	Error_code int         `json:"error_code"`
-	Error_msg  string      `json:"error_msg"`
-	Data       interface{} `json:"data"`
-	Url        string      `json:"url"`
-	ActiveHref string      `json:"activeHref"`
-}
-
-type FuncResult struct {
-	Data       interface{}            `json:"data"`
-	Info       map[string]interface{} `json:"info"`
-	Active     map[string]interface{} `json:"active"`
-	Error_code int                    `json:"error_code"`
-	Error_msg  string                 `json:"error_msg"`
-}
-
 func (i *Info) CollectInfo() {
 	defer qu.Catch()
-	r := func() NewResultSales {
+	r := func() entity.NewResultSales {
 		infoMap := map[string]interface{}{}
 		if string(i.Body()) == "" {
-			return NewResultSales{Data: nil, Error_msg: Error_msg_1003}
+			return entity.NewResultSales{Data: nil, Error_msg: Error_msg_1003}
 		}
 		body := xweb.FilterXSS(string(i.Body()))
 		//接收参数
 		json.Unmarshal([]byte(body), &infoMap)
 		if len(infoMap) == 0 {
-			return NewResultSales{Data: nil, Error_msg: Error_msg_1002}
+			return entity.NewResultSales{Data: nil, Error_msg: Error_msg_1002}
 		}
 		//必填项
 		if infoMap["name"] == nil || infoMap["phone"] == nil || infoMap["source"] == nil {
-			return NewResultSales{Data: nil, Error_msg: Error_msg_1002}
+			return entity.NewResultSales{Data: nil, Error_msg: Error_msg_1002}
 		}
 		//验证
 		phone := qu.ObjToString(infoMap["phone"]) //手机号
 		if !phoneReg.MatchString(phone) {
-			return NewResultSales{Error_code: -1, Error_msg: "手机号格式有误", Data: false}
+			return entity.NewResultSales{Error_code: -1, Error_msg: "手机号格式有误", Data: false}
 		}
 		//i.Session().Set("sales_MyPhone", phone)
 		mail := qu.ObjToString(infoMap["mail"]) //邮箱
 		if mail != "" && !emailReg.MatchString(mail) {
-			return NewResultSales{Error_code: -1, Error_msg: "邮箱格式有误", Data: false}
+			return entity.NewResultSales{Error_code: -1, Error_msg: "邮箱格式有误", Data: false}
 		}
 		//获取用户id
 		userid, _ := i.GetSession("userId").(string)
@@ -109,7 +93,7 @@ func (i *Info) CollectInfo() {
 		if Sysconfig.Source[source] != nil && Sysconfig.Source[source].EntValidation {
 			entName := qu.ObjToString(infoMap["company"])
 			if entName == "" || (entName != "" && !EnterpriseValidation(entName)) {
-				return NewResultSales{Data: nil, Error_msg: "暂无此企业信息"}
+				return entity.NewResultSales{Data: nil, Error_msg: "暂无此企业信息"}
 			}
 		}
 		//三级页面留资带有发布id时解密
@@ -130,7 +114,7 @@ func (i *Info) CollectInfo() {
 				}
 			}
 			if !checkCodeBool {
-				return NewResultSales{Error_code: -1, Error_msg: "手机号验证码错误", Data: false}
+				return entity.NewResultSales{Error_code: -1, Error_msg: "手机号验证码错误", Data: false}
 			}
 		}
 		infoMap["createtime"] = time.Now().Unix()
@@ -143,7 +127,7 @@ func (i *Info) CollectInfo() {
 				"source": "doubleEleven",
 				"userid": userid,
 			}); rd != nil && len(*rd) > 0 && ok {
-				return NewResultSales{Error_code: 1, Error_msg: "", Data: true}
+				return entity.NewResultSales{Error_code: 1, Error_msg: "", Data: true}
 			}
 		}
 		infoMap["client"] = i.Header("user-agent")
@@ -161,9 +145,9 @@ func (i *Info) CollectInfo() {
 				FreeuserManage(source, userid)
 			}
 			isApp := strings.Contains(i.Request.Host, "h5") || strings.Contains(i.Request.Host, "app")
-			return NewResultSales{Error_code: 1, Error_msg: "", Data: true, Url: href, ActiveHref: exh.GetExhibitionActiveHref(mail, phone, source, i.Session(), isApp)} //会展活动---
+			return entity.NewResultSales{Error_code: 1, Error_msg: "", Data: true, Url: href, ActiveHref: exh.GetExhibitionActiveHref(mail, phone, source, i.Session(), isApp)} //会展活动---
 		}
-		return NewResultSales{Error_code: -1, Error_msg: "保存失败", Data: false}
+		return entity.NewResultSales{Error_code: -1, Error_msg: "保存失败", Data: false}
 	}()
 	i.ServeJson(r)
 }
@@ -248,7 +232,7 @@ func (i *Info) RetainedCapital() {
 	if phone != nil {
 		i.SetSession("sales_MyPhone", phone)
 	}
-	i.ServeJson(FuncResult{Data: M{
+	i.ServeJson(entity.FuncResult{Data: M{
 		"retainedCapital": Whether.Do(userId, source, i.Session()),
 		"fource":          Sysconfig.Source[source] != nil && Sysconfig.Source[source].Force,
 	}, Info: data, Active: exh.ExhibitionActive(i.Request.Host, source, i.Session(), "first_ad_code")})
@@ -386,17 +370,17 @@ func (i *Info) AppIsNewUerSales() {
 }
 func (i *Info) AppNewUerSales() {
 	defer qu.Catch()
-	r := func() NewResultSales {
+	r := func() entity.NewResultSales {
 		infoMap := map[string]interface{}{}
 		if string(i.Body()) == "" {
-			return NewResultSales{Error_code: -1, Error_msg: Error_msg_1003}
+			return entity.NewResultSales{Error_code: -1, Error_msg: Error_msg_1003}
 		}
 		body := xweb.FilterXSS(string(i.Body()))
 		log.Println("body:", body)
 		//接收参数
 		json.Unmarshal([]byte(body), &infoMap)
 		if len(infoMap) == 0 {
-			return NewResultSales{Error_code: -1, Error_msg: Error_msg_1002}
+			return entity.NewResultSales{Error_code: -1, Error_msg: Error_msg_1002}
 		}
 		userid, _ := i.GetSession("userId").(string)
 		var userSales bool
@@ -494,10 +478,10 @@ func (i *Info) AppNewUerSales() {
 		})
 
 		if !ok && !ok2 {
-			return NewResultSales{Error_code: -1, Error_msg: "用户信息保存失败"}
+			return entity.NewResultSales{Error_code: -1, Error_msg: "用户信息保存失败"}
 		}
 		//redis.Put("other", fmt.Sprintf(AppNewUserRegistration, userid), 1, 60*60*24*7)
-		return NewResultSales{Error_msg: "保存成功"}
+		return entity.NewResultSales{Error_msg: "保存成功"}
 	}()
 	i.ServeJson(r)
 }
@@ -593,20 +577,20 @@ func (i *Info) ClearCheckCodeSess() {
 
 func (i *Info) OfficialNotLogin() {
 	defer qu.Catch()
-	r := func() NewResultSales {
+	r := func() entity.NewResultSales {
 		infoMap := map[string]interface{}{}
 		if string(i.Body()) == "" {
-			return NewResultSales{Data: nil, Error_msg: Error_msg_1003}
+			return entity.NewResultSales{Data: nil, Error_msg: Error_msg_1003}
 		}
 		body := xweb.FilterXSS(string(i.Body()))
 		//接收参数
 		json.Unmarshal([]byte(body), &infoMap)
 		if len(infoMap) == 0 {
-			return NewResultSales{Data: nil, Error_msg: Error_msg_1002}
+			return entity.NewResultSales{Data: nil, Error_msg: Error_msg_1002}
 		}
 		//必填项
 		if infoMap["phone"] == nil || infoMap["source"] == nil {
-			return NewResultSales{Data: nil, Error_msg: Error_msg_1002}
+			return entity.NewResultSales{Data: nil, Error_msg: Error_msg_1002}
 		}
 		//验证
 		phone := qu.ObjToString(infoMap["phone"]) //手机号
@@ -620,7 +604,7 @@ func (i *Info) OfficialNotLogin() {
 		//获取用户id
 		userid, _ := i.GetSession("userId").(string)
 		if !phoneReg.MatchString(phone) {
-			return NewResultSales{Error_code: -1, Error_msg: "手机号格式有误", Data: false}
+			return entity.NewResultSales{Error_code: -1, Error_msg: "手机号格式有误", Data: false}
 		}
 		if userid != "" {
 			infoMap["userid"] = userid
@@ -629,9 +613,9 @@ func (i *Info) OfficialNotLogin() {
 		href := ""
 		infoMap["client"] = i.Header("user-agent")
 		if id := MQFW.Save("saleLeads", infoMap); id != "" {
-			return NewResultSales{Error_code: 1, Error_msg: "", Data: true, Url: href}
+			return entity.NewResultSales{Error_code: 1, Error_msg: "", Data: true, Url: href}
 		}
-		return NewResultSales{Error_code: -1, Error_msg: "保存失败", Data: false}
+		return entity.NewResultSales{Error_code: -1, Error_msg: "保存失败", Data: false}
 	}()
 	i.ServeJson(r)
 }