소스 검색

Merge branch 'cygx/cygx_14.0' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

zhangchuanxing 7 달 전
부모
커밋
78d09c91a9
1개의 변경된 파일17개의 추가작업 그리고 1개의 파일을 삭제
  1. 17 1
      models/industry_fllow.go

+ 17 - 1
models/industry_fllow.go

@@ -36,7 +36,23 @@ type IndustryFllowArryReq struct {
 
 // 添加
 func AddCygxIndustryFllow(item *CygxIndustryFllow) (lastId int64, err error) {
-	o := orm.NewOrm()
+
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	sql := `DELETE FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? `
+	_, err = o.Raw(sql, item.UserId, item.IndustrialManagementId).Exec()
+	if err != nil {
+		return
+	}
 	lastId, err = o.Insert(item)
 	return
 }