ソースを参照

fix:错误校验

duxin 1 年間 前
コミット
7332b5a03c

+ 15 - 10
src/jfw/modules/bigmember/src/entity/marketAnalysis/analysisPdf.go

@@ -264,17 +264,18 @@ func (me *MarketAnalysisEntity) GetPdfPageApi() (finalDate map[string]interface{
 	return
 }
 
-func (this *AnalysisReportPdf) PdfSave() error {
+func (this *AnalysisReportPdf) PdfSave() {
 	sessVal := this.Session().GetMultiple()
 	userId := qutil.ObjToString(sessVal["userId"])
 	if userId == "" || userId == "0" {
-		return fmt.Errorf("用户异常")
+		this.ServeJson(NewResult(nil, fmt.Errorf("用户异常")))
+		return
 	}
 	sEmail := this.GetString("s_email")
 	log.Println("s_email", sEmail)
 	if !jy.IsEmail(sEmail) {
 		this.ServeJson(NewResult(nil, fmt.Errorf("邮箱格式不正确")))
-		return fmt.Errorf("邮箱格式不正确")
+		return
 	}
 	sType := this.GetString("type")
 	var id string
@@ -288,7 +289,8 @@ func (this *AnalysisReportPdf) PdfSave() error {
 	case "3": //定制化分析
 		rid := util.DecodeId(this.GetString("sid")) //获取信息id
 		if rid == "" {
-			return fmt.Errorf("定制化分析异常")
+			this.ServeJson(NewResult(nil, fmt.Errorf("定制化分析异常")))
+			return
 		}
 		pid, _, _ := CheckPowerEquity(this.Session())
 		mae := &MarketAnalysisEntity{MgoRecordId: rid, UId: userId, Pid: pid, MgoUserId: qutil.ObjToString(sessVal["mgoUserId"]), PositionId: qutil.IntAll(sessVal["positionId"])}
@@ -303,7 +305,8 @@ func (this *AnalysisReportPdf) PdfSave() error {
 		}
 		resData, _ := db.Mgo.FindOne(ReportHistoryTable, queryMap)
 		if resData == nil || len(*resData) == 0 {
-			return fmt.Errorf("定制化分析异常")
+			this.ServeJson(NewResult(nil, fmt.Errorf("定制化分析异常")))
+			return
 		}
 		for s, i := range *resData {
 			value := i
@@ -324,7 +327,8 @@ func (this *AnalysisReportPdf) PdfSave() error {
 			entName = getBuyerNameById(util.DecodeId(entName))
 		}
 		if entName == "" {
-			return fmt.Errorf("采购单位异常")
+			this.ServeJson(NewResult(nil, fmt.Errorf("采购单位异常")))
+			return
 		}
 		res["ent"] = entName
 		res["entName"] = entName
@@ -337,7 +341,7 @@ func (this *AnalysisReportPdf) PdfSave() error {
 		tRange := strings.Split(timeRange, "_")
 		if len(tRange) != 2 {
 			this.ServeJson(NewResult(util.EncodeId(id), fmt.Errorf("错误时间格式")))
-			return fmt.Errorf("错误时间格式")
+			return
 		}
 		st := fmt.Sprintf("%s-01-01", tRange[0])
 		et := fmt.Sprintf("%s-12-31", tRange[1])
@@ -353,7 +357,8 @@ func (this *AnalysisReportPdf) PdfSave() error {
 		//}
 		entId := this.GetString("entId")
 		if util.DecodeId(entId) == "" {
-			return fmt.Errorf("企业名称异常")
+			this.ServeJson(NewResult(util.EncodeId(id), fmt.Errorf("企业名称异常")))
+			return
 		}
 		res["ent"] = util.DecodeId(entId)
 		res["entName"] = this.GetString("entName")
@@ -365,7 +370,7 @@ func (this *AnalysisReportPdf) PdfSave() error {
 		tRange := strings.Split(this.GetString("timeRange"), "_")
 		if len(tRange) != 2 {
 			this.ServeJson(NewResult(util.EncodeId(id), fmt.Errorf("错误时间格式")))
-			return fmt.Errorf("时间格式异常")
+			return
 		}
 		st := fmt.Sprintf("%s-01-01", tRange[0])
 		et := fmt.Sprintf("%s-12-31", tRange[1])
@@ -377,7 +382,7 @@ func (this *AnalysisReportPdf) PdfSave() error {
 	}
 	id = db.Mgo.Save(MgoPdfName, res)
 	this.ServeJson(NewResult(util.EncodeId(id), nil))
-	return nil
+	return
 }
 
 func getBuyerNameById(buyerId string) (buyerName string) {