|
@@ -933,3 +933,74 @@ func GetProjectId(id string) string {
|
|
|
}
|
|
|
return projectId
|
|
|
}
|
|
|
+
|
|
|
+//
|
|
|
+func PushLtData(w http.ResponseWriter, r *http.Request) {
|
|
|
+ //身份参数
|
|
|
+ signature := r.Header.Get("signature")
|
|
|
+ timestamp := r.Header.Get("timestamp")
|
|
|
+ appid := r.FormValue("appid")
|
|
|
+ //
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+
|
|
|
+ // fmt.Println(MD5("jyMi1XQgMABQNcSkBMIhBq" + fmt.Sprint(time.Now().Unix()) + "6PzV0CUa"))
|
|
|
+ // fmt.Println(time.Now().Unix())
|
|
|
+
|
|
|
+ //
|
|
|
+ if r.Header.Get("Content-Type") != "application/x-www-form-urlencoded" {
|
|
|
+ return -1, fmt.Errorf("Content-Type格式错误")
|
|
|
+ }
|
|
|
+ if signature == "" || timestamp == "" || appid == "" {
|
|
|
+ return -1, fmt.Errorf("参数错误")
|
|
|
+ }
|
|
|
+ isOk, _, _, _ := Check(signature, timestamp, appid)
|
|
|
+ if !isOk {
|
|
|
+ return -1, fmt.Errorf("签名错误")
|
|
|
+ }
|
|
|
+ //必选
|
|
|
+ dataType := r.FormValue("dataType") //1校准,2-补充
|
|
|
+ href := r.FormValue("href") //源网站链接
|
|
|
+ infoTypeSegment := r.FormValue("infoTypeSegment") //信息类型二级分类
|
|
|
+ infoTitle := r.FormValue("infoTitle") //标题
|
|
|
+ zhaoBiaoUnit := r.FormValue("zhaoBiaoUnit") //招标单位
|
|
|
+ zhongBiaoUnit := r.FormValue("zhongBiaoUnit") //中标单位
|
|
|
+ amount := r.FormValue("amount") //中标金额
|
|
|
+ batchNumber := r.FormValue("batchNumber") //批次号
|
|
|
+ //选填
|
|
|
+ fieldName := r.FormValue("fieldName") //有问题的字段名,多个用逗号拼接
|
|
|
+ xmNumber := r.FormValue("xmNumber") //项目编号
|
|
|
+ //必选校验
|
|
|
+ for _, v := range []string{"dataType", "href", "infoTypeSegment", "infoTitle", "zhaoBiaoUnit", "zhongBiaoUnit", "amount", "batchNumber"} {
|
|
|
+ if len(r.Form[v]) <= 0 {
|
|
|
+ return -1, fmt.Errorf(fmt.Sprintf("%s字段缺失", v))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if util.IntAll(dataType) != 1 && util.IntAll(dataType) != 2 {
|
|
|
+ return -1, fmt.Errorf("dataType参数错误")
|
|
|
+ }
|
|
|
+ if Mgo.Save("ltPushData", map[string]interface{}{
|
|
|
+ "dataType": util.IntAll(dataType),
|
|
|
+ "href": href,
|
|
|
+ "infoTypeSegment": infoTypeSegment,
|
|
|
+ "infoTitle": infoTitle,
|
|
|
+ "zhaoBiaoUnit": zhaoBiaoUnit,
|
|
|
+ "zhongBiaoUnit": zhongBiaoUnit,
|
|
|
+ "amount": util.Float64All(amount),
|
|
|
+ "batchNumber": batchNumber,
|
|
|
+ "fieldName": fieldName,
|
|
|
+ "xmNumber": xmNumber,
|
|
|
+ "createTime": time.Now().Unix(),
|
|
|
+ "appid": appid,
|
|
|
+ }) != "" {
|
|
|
+ return 1, nil
|
|
|
+ }
|
|
|
+ return -1, fmt.Errorf("保存失败")
|
|
|
+ }()
|
|
|
+
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("用户%s PushLtData err :%s\n", appid, errMsg.Error())
|
|
|
+ }
|
|
|
+ ret := JSON{"status": rData}
|
|
|
+ WriteJSON(w, &ret)
|
|
|
+}
|