|
@@ -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
|
|
|
}
|