Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hezhuozhuo committed Sep 28, 2023
2 parents 1a98c7a + d80ab26 commit 7d4b76d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (c *AuthController) TenantRegister() {
if err != nil {
response.SuccessWithMessage(400, err.Error(), (*context2.Context)(c.Ctx))
} else {
response.SuccessWithMessage(400, "注册成功", (*context2.Context)(c.Ctx))
response.SuccessWithMessage(200, "注册成功", (*context2.Context)(c.Ctx))
}

}
Expand Down
21 changes: 21 additions & 0 deletions services/tp_scenario_strategy_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,27 @@ func (*TpScenarioStrategyService) EditTpScenarioStrategy(tp_scenario_strategy va
if scenarioAction.DeviceId == "" {
delete(scenarioActionMap, "DeviceId")
}

// 告警
if scenarioAction.ActionType == "3" {
// 创建策略
delete(scenarioActionMap, "Instruct")
scenarioAction.WarningStrategy.Id = utils.GetUuid()
result := tx.Model(&models.TpWarningStrategy{}).Create(scenarioAction.WarningStrategy)
if result.Error != nil {
tx.Rollback()
logs.Error(result.Error.Error())
return tp_scenario_strategy, result.Error
}
warning_strategy := make(map[string]interface{})
warning_strategy["warning_strategy_id"] = scenarioAction.WarningStrategy.Id
jsonData, err := json.Marshal(warning_strategy)
if err != nil {
return tp_scenario_strategy, err
}
scenarioActionMap["instruct"] = jsonData
}
delete(scenarioActionMap, "WarningStrategy")
result := tx.Model(&models.TpScenarioAction{}).Create(scenarioActionMap)
if result.Error != nil {
tx.Rollback()
Expand Down
15 changes: 8 additions & 7 deletions validate/tp_scenario_action_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package valid
import "ThingsPanel-Go/models"

type EditTpScenarioActionValidate struct {
Id string `json:"id" gorm:"primaryKey" valid:"MaxSize(36)"`
ScenarioStrategyId string `json:"scenario_strategy_id,omitempty" valid:"MaxSize(36)"`
ActionType string `json:"action_type,omitempty" valid:"MaxSize(2)"`
DeviceId string `json:"device_id,omitempty" valid:"MaxSize(36)"`
DeviceModel string `json:"device_model,omitempty" valid:"MaxSize(2)"` // 模型类型1-设定属性 2-调动服务
Instruct string `json:"instruct,omitempty" valid:"MaxSize(999)"` // 指令
Remark string `json:"remark,omitempty" valid:"MaxSize(255)"`
Id string `json:"id" gorm:"primaryKey" valid:"MaxSize(36)"`
ScenarioStrategyId string `json:"scenario_strategy_id,omitempty" valid:"MaxSize(36)"`
ActionType string `json:"action_type,omitempty" valid:"MaxSize(2)"`
DeviceId string `json:"device_id,omitempty" valid:"MaxSize(36)"`
DeviceModel string `json:"device_model,omitempty" valid:"MaxSize(2)"` // 模型类型1-设定属性 2-调动服务
Instruct string `json:"instruct,omitempty" valid:"MaxSize(999)"` // 指令
Remark string `json:"remark,omitempty" valid:"MaxSize(255)"`
WarningStrategy AddTpWarningStrategyValidate `json:"warning_strategy,omitempty"`
}

type AddTpScenarioActionValidate struct {
Expand Down

0 comments on commit 7d4b76d

Please sign in to comment.