From 39d53cf7a2080b49224dec6c395fc4ed2463a424 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 18 十二月 2024 18:23:20 +0800
Subject: [PATCH] 修改参数的获取逻辑

---
 db/task.go |   54 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/db/task.go b/db/task.go
index e7c6dc3..cc22131 100644
--- a/db/task.go
+++ b/db/task.go
@@ -1,48 +1,55 @@
 package db
 
 import (
+	"encoding/json"
 	"fmt"
-	"gorm.io/gorm"
 	"strings"
 	"time"
+
+	"gorm.io/gorm"
 )
 
 type (
 	ModelTask struct {
 		BaseModel
-		Name           string    `gorm:"type:varchar(255)" json:"name"`    //浠诲姟鍚嶇О
-		ModelID        string    `gorm:"type:varchar(255)" json:"modelID"` //妯″瀷ID
-		BeginTime      time.Time //宸ヤ綔鏃堕棿寮�濮�
-		EndTime        time.Time //鍏鏃堕棿缁撴潫
-		DomainUnitIds  []string  `gorm:"-" json:"domainUnitIds"` //鍖哄煙id鍒楄〃
-		DomainIds      string    `gorm:"type:varchar(1000)" json:"-"`
-		Building       string    `gorm:"type:varchar(255)" json:"building"`    //妤兼爧
-		Floor          string    `gorm:"type:varchar(255)" json:"floor"`       //妤煎眰
-		AlarmType      AlarmType `gorm:"type:varchar(255);" json:"alarmType"`  //棰勮鏂瑰紡
-		PersonType     string    `gorm:"type:varchar(255);" json:"personType"` //浜哄憳绫诲瀷
-		GatherPersons  int       `gorm:"type:int;" json:"gatherPersons"`       //鑱氶泦浜烘暟
-		AppearInterval int       `gorm:"type:int;" json:"appearInterval"`      //鍑虹幇闂撮殧锛屽崟浣嶄负绉�
-		DaysWindow     int       `gorm:"type:int;" json:"daysWindow" `         //杩戝嚑澶╁唴
-		Threshold      int       `gorm:"type:int;" json:"threshold" `          //杈惧嚑娆�
-		Enabled        bool      `json:"enabled"`                              //鏄惁寮�鍚�
+		Name           string         `gorm:"type:varchar(255)" json:"name"`    // 浠诲姟鍚嶇О
+		ModelID        string         `gorm:"type:varchar(255)" json:"modelID"` // 妯″瀷ID
+		BeginTime      time.Time      `json:"beginTime"`                        // 宸ヤ綔鏃堕棿寮�濮�
+		EndTime        time.Time      `json:"endTime"`                          // 宸ヤ綔鏃堕棿缁撴潫
+		DomainUnitIds  []string       `gorm:"-" json:"domainUnitIds"`           // 鍖哄煙id鍒楄〃
+		DomainIds      string         `gorm:"type:varchar(1000)" json:"-"`
+		Building       string         `gorm:"type:varchar(255)" json:"building"`      // 妤兼爧
+		Floor          string         `gorm:"type:varchar(255)" json:"floor"`         // 妤煎眰
+		AlarmType      AlarmType      `gorm:"type:varchar(255);" json:"alarmType"`    // 棰勮鏂瑰紡
+		PersonType     string         `gorm:"type:varchar(255);" json:"personType"`   // 浜哄憳绫诲瀷
+		PersonLabel    string         `gorm:"type:varchar(255);" json:"personLabel"`  // 浜哄憳鏍囩
+		IdentityType   string         `gorm:"type:varchar(255);" json:"identityType"` // 韬唤鏍囩, 闄岀敓浜�, 璁垮, 浣忔埛
+		AlarmLevel     string         `gorm:"type:varchar(255);" json:"alarmLevel"`   // 棰勮绾у埆
+		GatherPersons  int            `gorm:"type:int;" json:"gatherPersons"`         // 鑱氶泦浜烘暟
+		AppearInterval int            `gorm:"type:int;" json:"appearInterval"`        // 鍑虹幇闂撮殧锛屽崟浣嶄负绉�
+		DaysWindow     int            `gorm:"type:int;" json:"daysWindow" `           // 杩戝嚑澶╁唴
+		Threshold      int            `gorm:"type:int;" json:"threshold" `            // 杈惧嚑娆�
+		Enabled        bool           `json:"enabled"`                                // 鏄惁寮�鍚�
+		RuleSet        string         `gorm:"type:text" json:"-"`                     // 瀛樺偍妯″瀷浠诲姟璁剧疆鐨勮鍒欏弬鏁�
+		Rules          []ModelRuleSet `gorm:"-" json:"rules"`                         // 瑙勫垯閰嶇疆
 	}
 
 	ModelTaskSearch struct {
 		ModelTask
 		Orm       *gorm.DB
+		ModelIDs  []string
+		Unexpired bool
 		PageNum   int
 		PageSize  int
 		Keyword   string
-		ModelIDs  []string
-		Unexpired bool
 	}
 )
 
 type AlarmType string
 
 const (
-	AlarmTypeSave        AlarmType = "save"    //浠呬繚瀛�
-	AlarmTypeSendMessage AlarmType = "message" //鍙戞秷鎭�
+	AlarmTypeSave        AlarmType = "save"    // 浠呬繚瀛�
+	AlarmTypeSendMessage AlarmType = "message" // 鍙戞秷鎭�
 )
 
 func (slf *ModelTask) TableName() string {
@@ -78,6 +85,13 @@
 	if slf.DomainIds != "" {
 		slf.DomainUnitIds = strings.Split(slf.DomainIds, ",")
 	}
+	if slf.DomainIds != "" {
+		slf.DomainUnitIds = strings.Split(slf.DomainIds, ",")
+	}
+
+	if slf.RuleSet != "" {
+		_ = json.Unmarshal([]byte(slf.RuleSet), &slf.Rules)
+	}
 	return nil
 }
 

--
Gitblit v1.8.0