github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/gen_method/examples/physics_delete_by_uniquustomer_g7__generated.go (about) 1 package examples 2 3 import ( 4 "fmt" 5 "reflect" 6 "strings" 7 "time" 8 9 "github.com/go-sql-driver/mysql" 10 "github.com/sirupsen/logrus" 11 12 "golib/gorm" 13 14 "github.com/johnnyeven/libtools/courier/enumeration" 15 "github.com/johnnyeven/libtools/duration" 16 "github.com/johnnyeven/libtools/mysql/dberr" 17 "github.com/johnnyeven/libtools/timelib" 18 ) 19 20 type PhysicsDeleteByUniquustomerG7List []PhysicsDeleteByUniquustomerG7 21 22 func init() { 23 DBTable.Register(&PhysicsDeleteByUniquustomerG7{}) 24 } 25 26 func (pdbug PhysicsDeleteByUniquustomerG7) TableName() string { 27 table_name := "t_physics_delete_by_uniquustomer_g7" 28 if DBTable.Name == "" { 29 return table_name 30 } 31 return DBTable.Name + "." + table_name 32 } 33 34 func (pdbugl *PhysicsDeleteByUniquustomerG7List) BatchFetchByCreateTimeList(db *gorm.DB, createTimeList []timelib.MySQLTimestamp) error { 35 defer duration.PrintDuration(map[string]interface{}{ 36 "request": "[DB]PhysicsDeleteByUniquustomerG7.BatchFetchByCreateTimeList", 37 })() 38 39 if len(createTimeList) == 0 { 40 return nil 41 } 42 43 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_create_time in (?) and F_enabled = ?", createTimeList, enumeration.BOOL__TRUE).Find(pdbugl).Error 44 if err != nil { 45 logrus.Errorf("%s", err.Error()) 46 return dberr.RecordFetchFailedError 47 } else { 48 return nil 49 } 50 } 51 52 func (pdbugl *PhysicsDeleteByUniquustomerG7List) BatchFetchByCustomerIDList(db *gorm.DB, customerIDList []uint64) error { 53 defer duration.PrintDuration(map[string]interface{}{ 54 "request": "[DB]PhysicsDeleteByUniquustomerG7.BatchFetchByCustomerIDList", 55 })() 56 57 if len(customerIDList) == 0 { 58 return nil 59 } 60 61 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_customer_id in (?) and F_enabled = ?", customerIDList, enumeration.BOOL__TRUE).Find(pdbugl).Error 62 if err != nil { 63 logrus.Errorf("%s", err.Error()) 64 return dberr.RecordFetchFailedError 65 } else { 66 return nil 67 } 68 } 69 70 func (pdbugl *PhysicsDeleteByUniquustomerG7List) BatchFetchByG7sOrgCodeList(db *gorm.DB, g7sOrgCodeList []string) error { 71 defer duration.PrintDuration(map[string]interface{}{ 72 "request": "[DB]PhysicsDeleteByUniquustomerG7.BatchFetchByG7sOrgCodeList", 73 })() 74 75 if len(g7sOrgCodeList) == 0 { 76 return nil 77 } 78 79 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_g7s_org_code in (?) and F_enabled = ?", g7sOrgCodeList, enumeration.BOOL__TRUE).Find(pdbugl).Error 80 if err != nil { 81 logrus.Errorf("%s", err.Error()) 82 return dberr.RecordFetchFailedError 83 } else { 84 return nil 85 } 86 } 87 88 func (pdbugl *PhysicsDeleteByUniquustomerG7List) BatchFetchByG7sUserIDList(db *gorm.DB, g7sUserIDList []string) error { 89 defer duration.PrintDuration(map[string]interface{}{ 90 "request": "[DB]PhysicsDeleteByUniquustomerG7.BatchFetchByG7sUserIDList", 91 })() 92 93 if len(g7sUserIDList) == 0 { 94 return nil 95 } 96 97 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_g7s_user_id in (?) and F_enabled = ?", g7sUserIDList, enumeration.BOOL__TRUE).Find(pdbugl).Error 98 if err != nil { 99 logrus.Errorf("%s", err.Error()) 100 return dberr.RecordFetchFailedError 101 } else { 102 return nil 103 } 104 } 105 106 func (pdbugl *PhysicsDeleteByUniquustomerG7List) BatchFetchByUpdateTimeList(db *gorm.DB, updateTimeList []timelib.MySQLTimestamp) error { 107 defer duration.PrintDuration(map[string]interface{}{ 108 "request": "[DB]PhysicsDeleteByUniquustomerG7.BatchFetchByUpdateTimeList", 109 })() 110 111 if len(updateTimeList) == 0 { 112 return nil 113 } 114 115 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_update_time in (?) and F_enabled = ?", updateTimeList, enumeration.BOOL__TRUE).Find(pdbugl).Error 116 if err != nil { 117 logrus.Errorf("%s", err.Error()) 118 return dberr.RecordFetchFailedError 119 } else { 120 return nil 121 } 122 } 123 124 func (pdbug *PhysicsDeleteByUniquustomerG7) Create(db *gorm.DB) error { 125 defer duration.PrintDuration(map[string]interface{}{ 126 "request": "[DB]PhysicsDeleteByUniquustomerG7.Create", 127 })() 128 129 if time.Time(pdbug.CreateTime).IsZero() { 130 pdbug.CreateTime = timelib.MySQLTimestamp(time.Now()) 131 } 132 133 if time.Time(pdbug.UpdateTime).IsZero() { 134 pdbug.UpdateTime = timelib.MySQLTimestamp(time.Now()) 135 } 136 137 pdbug.Enabled = enumeration.Bool(enumeration.BOOL__TRUE) 138 err := db.Table(pdbug.TableName()).Create(pdbug).Error 139 if err != nil { 140 if mysql_err, ok := err.(*mysql.MySQLError); !ok { 141 logrus.Errorf("%s", err.Error()) 142 return dberr.RecordCreateFailedError 143 } else if mysql_err.Number != dberr.DuplicateEntryErrNumber { 144 logrus.Errorf("%s", err.Error()) 145 return dberr.RecordCreateFailedError 146 } else { 147 return dberr.RecordConflictError 148 } 149 } else { 150 return nil 151 } 152 } 153 154 type PhysicsDeleteByUniquustomerG7DBFieldData struct { 155 G7sUserID string 156 CustomerID string 157 G7sOrgCode string 158 CreateTime string 159 UpdateTime string 160 Enabled string 161 } 162 163 // FetchNoneUniqueIndexFields without Enabled and CreateTime field. 164 func (pdbugdbfd *PhysicsDeleteByUniquustomerG7DBFieldData) FetchNoneUniqueIndexFields() []string { 165 return []string{ 166 "F_g7s_org_code", "F_update_time", 167 } 168 } 169 170 func (pdbug PhysicsDeleteByUniquustomerG7) DBField() *PhysicsDeleteByUniquustomerG7DBFieldData { 171 return &PhysicsDeleteByUniquustomerG7DBFieldData{ 172 G7sUserID: "F_g7s_user_id", 173 CustomerID: "F_customer_id", 174 G7sOrgCode: "F_g7s_org_code", 175 CreateTime: "F_create_time", 176 UpdateTime: "F_update_time", 177 Enabled: "F_enabled", 178 } 179 } 180 181 var PhysicsDeleteByUniquustomerG7StructFieldAndDBFieldRelate = map[string]string{ 182 "G7sUserID": "F_g7s_user_id", 183 "CustomerID": "F_customer_id", 184 "G7sOrgCode": "F_g7s_org_code", 185 "CreateTime": "F_create_time", 186 "UpdateTime": "F_update_time", 187 "Enabled": "F_enabled", 188 } 189 190 var PhysicsDeleteByUniquustomerG7DBFieldAndStructFieldRelate = map[string]string{ 191 "F_g7s_user_id": "G7sUserID", 192 "F_customer_id": "CustomerID", 193 "F_g7s_org_code": "G7sOrgCode", 194 "F_create_time": "CreateTime", 195 "F_update_time": "UpdateTime", 196 "F_enabled": "Enabled", 197 } 198 199 // CreateOnDuplicateWithUpdateFields only update the no unique index field, it return error if updateFields contain unique index field. 200 // It doesn't update the Enabled and CreateTime field. 201 func (pdbug *PhysicsDeleteByUniquustomerG7) CreateOnDuplicateWithUpdateFields(db *gorm.DB, updateFields []string) error { 202 defer duration.PrintDuration(map[string]interface{}{ 203 "request": "[DB]PhysicsDeleteByUniquustomerG7.CreateOnDuplicateWithUpdateFields", 204 })() 205 if len(updateFields) == 0 { 206 return fmt.Errorf("Must have update fields.") 207 } 208 209 noUniqueIndexFields := (&PhysicsDeleteByUniquustomerG7DBFieldData{}).FetchNoneUniqueIndexFields() 210 if len(noUniqueIndexFields) == 0 { 211 return fmt.Errorf("There are no unique fields.") 212 } 213 214 var noUniqueIndexFieldsMap = make(map[string]string) 215 for _, field := range noUniqueIndexFields { 216 noUniqueIndexFieldsMap[field] = "" 217 } 218 219 var updateFieldsMap = make(map[string]string) 220 for _, field := range updateFields { 221 // have unique field in updateFields 222 if _, ok := noUniqueIndexFieldsMap[field]; !ok { 223 return fmt.Errorf("Field[%s] is unique index or wrong field or Enable field", PhysicsDeleteByUniquustomerG7DBFieldAndStructFieldRelate[field]) 224 } 225 updateFieldsMap[field] = "" 226 } 227 228 if time.Time(pdbug.CreateTime).IsZero() { 229 pdbug.CreateTime = timelib.MySQLTimestamp(time.Now()) 230 } 231 232 if time.Time(pdbug.UpdateTime).IsZero() { 233 pdbug.UpdateTime = timelib.MySQLTimestamp(time.Now()) 234 } 235 236 pdbug.Enabled = enumeration.Bool(enumeration.BOOL__TRUE) 237 238 structType := reflect.TypeOf(pdbug).Elem() 239 if structType.Kind() != reflect.Struct { 240 return fmt.Errorf("Instance not struct type.") 241 } 242 structVal := reflect.ValueOf(pdbug).Elem() 243 244 var param_list []interface{} 245 var str_list = []string{"insert into"} 246 var insertFieldsStr = pdbug.TableName() + "(" 247 var placeHolder = "values(" 248 for i := 0; i < structType.NumField(); i++ { 249 if i == 0 { 250 insertFieldsStr += PhysicsDeleteByUniquustomerG7StructFieldAndDBFieldRelate[structType.Field(i).Name] 251 placeHolder += fmt.Sprintf("%s", "?") 252 } else { 253 insertFieldsStr += fmt.Sprintf(",%s", PhysicsDeleteByUniquustomerG7StructFieldAndDBFieldRelate[structType.Field(i).Name]) 254 placeHolder += fmt.Sprintf("%s", ", ?") 255 } 256 param_list = append(param_list, structVal.Field(i).Interface()) 257 } 258 insertFieldsStr += ")" 259 placeHolder += ")" 260 str_list = append(str_list, []string{insertFieldsStr, placeHolder, "on duplicate key update"}...) 261 262 var updateStr []string 263 for i := 0; i < structType.NumField(); i++ { 264 if dbField, ok := PhysicsDeleteByUniquustomerG7StructFieldAndDBFieldRelate[structType.Field(i).Name]; !ok { 265 return fmt.Errorf("Wrong field of struct, may be changed field but not regenerate code.") 266 } else { 267 if _, ok := updateFieldsMap[dbField]; ok { 268 updateStr = append(updateStr, fmt.Sprintf("%s = ?", dbField)) 269 param_list = append(param_list, structVal.Field(i).Interface()) 270 } 271 } 272 } 273 str_list = append(str_list, strings.Join(updateStr, ",")) 274 sql := strings.Join(str_list, " ") 275 err := db.Exec(sql, param_list...).Error 276 if err != nil { 277 logrus.Errorf("%s", err.Error()) 278 return dberr.RecordCreateFailedError 279 } 280 281 return nil 282 } 283 284 func (pdbug *PhysicsDeleteByUniquustomerG7) DeleteByG7sUserIDAndCustomerID(db *gorm.DB) error { 285 defer duration.PrintDuration(map[string]interface{}{ 286 "request": "[DB]PhysicsDeleteByUniquustomerG7.DeleteByG7sUserIDAndCustomerID", 287 })() 288 289 err := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Delete(pdbug).Error 290 if err != nil { 291 logrus.Errorf("%s", err.Error()) 292 return dberr.RecordDeleteFailedError 293 } else { 294 return nil 295 } 296 } 297 298 func (pdbugl *PhysicsDeleteByUniquustomerG7List) FetchByCreateTime(db *gorm.DB, createTime timelib.MySQLTimestamp) error { 299 defer duration.PrintDuration(map[string]interface{}{ 300 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByCreateTime", 301 })() 302 303 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_create_time = ? and F_enabled = ?", createTime, enumeration.BOOL__TRUE).Find(pdbugl).Error 304 if err == nil { 305 return nil 306 } else { 307 logrus.Errorf("%s", err.Error()) 308 return dberr.RecordFetchFailedError 309 } 310 } 311 312 func (pdbugl *PhysicsDeleteByUniquustomerG7List) FetchByCustomerID(db *gorm.DB, customerID uint64) error { 313 defer duration.PrintDuration(map[string]interface{}{ 314 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByCustomerID", 315 })() 316 317 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_customer_id = ? and F_enabled = ?", customerID, enumeration.BOOL__TRUE).Find(pdbugl).Error 318 if err == nil { 319 return nil 320 } else { 321 logrus.Errorf("%s", err.Error()) 322 return dberr.RecordFetchFailedError 323 } 324 } 325 326 func (pdbugl *PhysicsDeleteByUniquustomerG7List) FetchByG7sOrgCode(db *gorm.DB, g7sOrgCode string) error { 327 defer duration.PrintDuration(map[string]interface{}{ 328 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByG7sOrgCode", 329 })() 330 331 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_g7s_org_code = ? and F_enabled = ?", g7sOrgCode, enumeration.BOOL__TRUE).Find(pdbugl).Error 332 if err == nil { 333 return nil 334 } else { 335 logrus.Errorf("%s", err.Error()) 336 return dberr.RecordFetchFailedError 337 } 338 } 339 340 func (pdbugl *PhysicsDeleteByUniquustomerG7List) FetchByG7sUserID(db *gorm.DB, g7sUserID string) error { 341 defer duration.PrintDuration(map[string]interface{}{ 342 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByG7sUserID", 343 })() 344 345 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_g7s_user_id = ? and F_enabled = ?", g7sUserID, enumeration.BOOL__TRUE).Find(pdbugl).Error 346 if err == nil { 347 return nil 348 } else { 349 logrus.Errorf("%s", err.Error()) 350 return dberr.RecordFetchFailedError 351 } 352 } 353 354 func (pdbug *PhysicsDeleteByUniquustomerG7) FetchByG7sUserIDAndCustomerID(db *gorm.DB) error { 355 defer duration.PrintDuration(map[string]interface{}{ 356 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByG7sUserIDAndCustomerID", 357 })() 358 359 err := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Find(pdbug).Error 360 if err == nil { 361 return nil 362 } else { 363 if err == gorm.RecordNotFound { 364 return dberr.RecordNotFoundError 365 } else { 366 logrus.Errorf("%s", err.Error()) 367 return dberr.RecordFetchFailedError 368 } 369 } 370 } 371 372 func (pdbug *PhysicsDeleteByUniquustomerG7) FetchByG7sUserIDAndCustomerIDForUpdate(db *gorm.DB) error { 373 defer duration.PrintDuration(map[string]interface{}{ 374 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByG7sUserIDAndCustomerIDForUpdate", 375 })() 376 377 err := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Set("gorm:query_option", "FOR UPDATE").Find(pdbug).Error 378 if err == nil { 379 return nil 380 } else { 381 if err == gorm.RecordNotFound { 382 return dberr.RecordNotFoundError 383 } else { 384 logrus.Errorf("%s", err.Error()) 385 return dberr.RecordFetchFailedError 386 } 387 } 388 } 389 390 func (pdbugl *PhysicsDeleteByUniquustomerG7List) FetchByUpdateTime(db *gorm.DB, updateTime timelib.MySQLTimestamp) error { 391 defer duration.PrintDuration(map[string]interface{}{ 392 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchByUpdateTime", 393 })() 394 395 err := db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where("F_update_time = ? and F_enabled = ?", updateTime, enumeration.BOOL__TRUE).Find(pdbugl).Error 396 if err == nil { 397 return nil 398 } else { 399 logrus.Errorf("%s", err.Error()) 400 return dberr.RecordFetchFailedError 401 } 402 } 403 404 func (pdbugl *PhysicsDeleteByUniquustomerG7List) FetchList(db *gorm.DB, size, offset int32, query ...map[string]interface{}) (int32, error) { 405 defer duration.PrintDuration(map[string]interface{}{ 406 "request": "[DB]PhysicsDeleteByUniquustomerG7.FetchList", 407 })() 408 409 var count int32 410 if len(query) == 0 { 411 query = append(query, map[string]interface{}{"F_enabled": enumeration.BOOL__TRUE}) 412 } else { 413 if _, ok := query[0]["F_enabled"]; !ok { 414 query[0]["F_enabled"] = enumeration.BOOL__TRUE 415 } 416 } 417 418 if size <= 0 { 419 size = -1 420 offset = -1 421 } 422 var err error 423 424 err = db.Table(PhysicsDeleteByUniquustomerG7{}.TableName()).Where(query[0]).Count(&count).Limit(size).Offset(offset).Order("F_create_time desc").Find(pdbugl).Error 425 426 if err != nil { 427 logrus.Errorf("%s", err.Error()) 428 return 0, dberr.RecordFetchFailedError 429 } else { 430 return int32(count), nil 431 } 432 } 433 434 func (pdbug *PhysicsDeleteByUniquustomerG7) SoftDeleteByG7sUserIDAndCustomerID(db *gorm.DB) error { 435 defer duration.PrintDuration(map[string]interface{}{ 436 "request": "[DB]PhysicsDeleteByUniquustomerG7.SoftDeleteByG7sUserIDAndCustomerID", 437 })() 438 439 var updateMap = map[string]interface{}{} 440 updateMap["F_enabled"] = enumeration.BOOL__FALSE 441 442 if time.Time(pdbug.UpdateTime).IsZero() { 443 pdbug.UpdateTime = timelib.MySQLTimestamp(time.Now()) 444 } 445 446 err := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Updates(updateMap).Error 447 if err != nil { 448 if mysql_err, ok := err.(*mysql.MySQLError); !ok { 449 logrus.Errorf("%s", err.Error()) 450 return dberr.RecordDeleteFailedError 451 } else if mysql_err.Number != dberr.DuplicateEntryErrNumber { 452 logrus.Errorf("%s", err.Error()) 453 return dberr.RecordDeleteFailedError 454 } else { 455 logrus.Warningf("%s", err.Error()) 456 // 物理删除被软删除的数据 457 delErr := db.Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Delete(&PhysicsDeleteByUniquustomerG7{}).Error 458 if delErr != nil { 459 logrus.Errorf("%s", delErr.Error()) 460 return dberr.RecordDeleteFailedError 461 } 462 463 return nil 464 } 465 } else { 466 return nil 467 } 468 } 469 470 func (pdbug *PhysicsDeleteByUniquustomerG7) UpdateByG7sUserIDAndCustomerIDWithMap(db *gorm.DB, updateMap map[string]interface{}) error { 471 defer duration.PrintDuration(map[string]interface{}{ 472 "request": "[DB]PhysicsDeleteByUniquustomerG7.UpdateByG7sUserIDAndCustomerIDWithMap", 473 })() 474 475 if _, ok := updateMap["F_update_time"]; !ok { 476 updateMap["F_update_time"] = timelib.MySQLTimestamp(time.Now()) 477 478 } 479 dbRet := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Updates(updateMap) 480 err := dbRet.Error 481 if err != nil { 482 if mysql_err, ok := err.(*mysql.MySQLError); !ok { 483 logrus.Errorf("%s", err.Error()) 484 return dberr.RecordUpdateFailedError 485 } else if mysql_err.Number != dberr.DuplicateEntryErrNumber { 486 logrus.Errorf("%s", err.Error()) 487 return dberr.RecordUpdateFailedError 488 } else { 489 return dberr.RecordConflictError 490 } 491 } else { 492 if dbRet.RowsAffected == 0 { 493 findErr := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Find(&PhysicsDeleteByUniquustomerG7{}).Error 494 if findErr == gorm.RecordNotFound { 495 return dberr.RecordNotFoundError 496 } else if findErr != nil { 497 return dberr.RecordUpdateFailedError 498 } 499 //存在有效数据记录,返回成功 500 return nil 501 } else { 502 return nil 503 } 504 } 505 } 506 507 func (pdbug *PhysicsDeleteByUniquustomerG7) UpdateByG7sUserIDAndCustomerIDWithStruct(db *gorm.DB) error { 508 defer duration.PrintDuration(map[string]interface{}{ 509 "request": "[DB]PhysicsDeleteByUniquustomerG7.UpdateByG7sUserIDAndCustomerIDWithStruct", 510 })() 511 512 if time.Time(pdbug.UpdateTime).IsZero() { 513 pdbug.UpdateTime = timelib.MySQLTimestamp(time.Now()) 514 } 515 516 dbRet := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Updates(pdbug) 517 err := dbRet.Error 518 if err != nil { 519 if mysql_err, ok := err.(*mysql.MySQLError); !ok { 520 logrus.Errorf("%s", err.Error()) 521 return dberr.RecordUpdateFailedError 522 } else if mysql_err.Number != dberr.DuplicateEntryErrNumber { 523 logrus.Errorf("%s", err.Error()) 524 return dberr.RecordUpdateFailedError 525 } else { 526 return dberr.RecordConflictError 527 } 528 } else { 529 if dbRet.RowsAffected == 0 { 530 findErr := db.Table(pdbug.TableName()).Where("F_g7s_user_id = ? and F_customer_id = ? and F_enabled = ?", pdbug.G7sUserID, pdbug.CustomerID, enumeration.BOOL__TRUE).Find(&PhysicsDeleteByUniquustomerG7{}).Error 531 if findErr == gorm.RecordNotFound { 532 return dberr.RecordNotFoundError 533 } else if findErr != nil { 534 return dberr.RecordUpdateFailedError 535 } 536 //存在有效数据记录,返回成功 537 return nil 538 } else { 539 return nil 540 } 541 } 542 }