123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // 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/consts"
- "adm-ads/model"
- "encoding/json"
- "strings"
- "adm-ads/common.in/clinit"
- "gorm.io/gorm"
- )
- // 处理任务9的删除
- func handleTask9Delete(ads9 *model.Ads9) error {
- err := ads9.Delete(clinit.DB(), map[string]interface{}{"uniq": ads9.Uniq})
- if err == gorm.ErrRecordNotFound {
- return nil
- }
- return err
- }
- // 处理任务9的插入
- func handleTask9InsertOrUpdate(ads9 *model.Ads9) error {
- err := ads9.Insert(clinit.DB())
- if err != nil && !strings.Contains(err.Error(), "Duplicate") {
- return err
- }
- return nil
- }
- // vin定型
- func Task9(adsMsg *apis.AdsMessage) (err error) {
- ads9 := &model.Ads9{}
- json.Unmarshal([]byte(adsMsg.Content), &ads9)
- if ads9.Uniq == "" || ads9.ModelNo == "" || ads9.SeriesId == "" || ads9.VinRule == "" {
- return nil
- }
- if adsMsg.Action == consts.ACTIONDELETE {
- // 删除
- err = handleTask9Delete(ads9)
- } else {
- // 新增或插入
- err = handleTask9InsertOrUpdate(ads9)
- }
- return err
- }
|