// Copyright 2019 getensh.com. All rights reserved. // Use of this source code is governed by getensh.com. package task import ( "adm-ads/apis" "adm-ads/common.in/clinit" "adm-ads/consts" "adm-ads/model" "encoding/json" "gorm.io/gorm" "strings" ) // 处理任务8的删除 func handleTask8Delete(ads8 *model.Ads8) error { err := ads8.Delete(clinit.DB(),map[string]interface{}{"vin":ads8.Vin,"third_style_id":ads8.ThirdStyleId,"source":ads8.Source}) if err == gorm.ErrRecordNotFound{ return nil } return err } // 处理任务8的插入 func handleTask8InsertOrUpdate(ads8 *model.Ads8)error{ err := ads8.Insert(clinit.DB()) if err != nil && !strings.Contains(err.Error(), "Duplicate") { return err } return nil } // vin定型 func Task8(adsMsg *apis.AdsMessage) (err error) { ads8 := &model.Ads8{} json.Unmarshal([]byte(adsMsg.Content),&ads8) if ads8.Vin == "" || ads8.ThirdStyleId == "" { return nil } if adsMsg.Action == consts.ACTIONDELETE{ // 删除 err = handleTask8Delete(ads8) }else{ // 新增或插入 err = handleTask8InsertOrUpdate(ads8) } return err }