소스 검색

删除偶尔失效

mainqaq 2 년 전
부모
커밋
5643f08814
3개의 변경된 파일20개의 추가작업 그리고 17개의 파일을 삭제
  1. 3 2
      controllers/supply_order_api_contorller.go
  2. 10 10
      models/supply.models.go
  3. 7 5
      service/supply_service.go

+ 3 - 2
controllers/supply_order_api_contorller.go 파일 보기

@@ -454,14 +454,15 @@ func (this *SupplyOrderApiController) DelSupply() {
454 454
 	supply := models.SpSupplierName{
455 455
 		ID: suid,
456 456
 	}
457
-	err := service.DelSupply(supply, orgId)
457
+	shiwu, err := service.DelSupply(supply, orgId)
458 458
 	if err != nil {
459 459
 		utils.ErrorLog(err.Error())
460 460
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
461 461
 		return
462 462
 	}
463 463
 	this.ServeSuccessJSON(map[string]interface{}{
464
-		"list": "删除成功",
464
+		"list":  "删除成功",
465
+		"shiwu": shiwu,
465 466
 	})
466 467
 	return
467 468
 }

+ 10 - 10
models/supply.models.go 파일 보기

@@ -2,16 +2,16 @@ package models
2 2
 
3 3
 //供应商联系人
4 4
 type SpSupplierContacts struct {
5
-	ID           int64  `gorm:"column:id" json:"id" from:"id"`
6
-	Name         string `gorm:"column:name" json:"name" from:"name"`
7
-	Phone        string `gorm:"column:phone" json:"phone" from:"phone"`
8
-	Address      string `gorm:"column:address" json:"address" from:"address"`
9
-	IsFirst      int64  `gorm:"column:is_first" json:"is_first" from:"is_first"`
10
-	SupplierCode string `gorm:"column:supplier_code" json:"supplier_code" from:"supplier_code"`
11
-	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" from:"user_org_id"`
12
-	Status       int64  `gorm:"column:status" json:"status" from:"status"`
13
-	Ctime        int64  `gorm:"column:ctime" json:"ctime" from:"ctime"`
14
-	Mtime        int64  `gorm:"column:mtime" json:"mtime" from:"mtime"`
5
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
6
+	Name         string `gorm:"column:name" json:"name" form:"name"`
7
+	Phone        string `gorm:"column:phone" json:"phone" form:"phone"`
8
+	Address      string `gorm:"column:address" json:"address" form:"address"`
9
+	IsFirst      int64  `gorm:"column:is_first" json:"is_first" form:"is_first"`
10
+	SupplierCode string `gorm:"column:supplier_code" json:"supplier_code" form:"supplier_code"`
11
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
12
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
13
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
14
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
15 15
 }
16 16
 
17 17
 func (SpSupplierContacts) TableName() string {

+ 7 - 5
service/supply_service.go 파일 보기

@@ -169,30 +169,32 @@ func GetSupplyAndContactOne(id, orgId int64) (supply models.SpSupplierName, cont
169 169
 }
170 170
 
171 171
 //删除供应商及联系人
172
-func DelSupply(supply models.SpSupplierName, orgId int64) error {
172
+func DelSupply(supply models.SpSupplierName, orgId int64) (shiwu string, err error) {
173 173
 	tx := XTWriteDB().Begin()
174 174
 	defer func() {
175 175
 		if err != nil {
176
+			shiwu = "失败"
176 177
 			tx.Rollback()
177 178
 		} else {
179
+			shiwu = "成功"
178 180
 			tx.Commit()
179 181
 		}
180 182
 	}()
181 183
 	//删除供应商
182
-	err := tx.Model(&supply).Update("status", 0).Error
184
+	err = tx.Model(&supply).Update("status", 0).Error
183 185
 	if err != nil {
184
-		return err
186
+		return shiwu, err
185 187
 	}
186 188
 	var spcode models.SpSupplierName
187 189
 	//获取供应商编号
188 190
 	err = tx.Model(&models.SpSupplierName{}).Select("supplier_code").Where("user_org_id = ? and id = ?", orgId, supply.ID).First(&spcode).Error
189 191
 	if err != nil {
190
-		return err
192
+		return shiwu, err
191 193
 	}
192 194
 	//删除联系人
193 195
 	err = tx.Model(&models.SpSupplierContacts{}).Where("supplier_code = ? and user_org_id = ?", spcode.SupplierCode, orgId).Update("status", 0).Error
194 196
 
195
-	return err
197
+	return shiwu, err
196 198
 }
197 199
 
198 200
 //保存供应商和联系人