mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 01:50:25 +08:00
通知媒介可以设置发送频率
This commit is contained in:
@@ -21,6 +21,6 @@ const (
|
|||||||
NodeVersion = "0.3.0"
|
NodeVersion = "0.3.0"
|
||||||
UserNodeVersion = "0.0.10"
|
UserNodeVersion = "0.0.10"
|
||||||
AuthorityNodeVersion = "0.0.2"
|
AuthorityNodeVersion = "0.0.2"
|
||||||
MonitorNodeVersion = "0.0.2"
|
MonitorNodeVersion = "0.0.3"
|
||||||
DNSNodeVersion = "0.2.0"
|
DNSNodeVersion = "0.2.0"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func (this *MessageMediaInstanceDAO) FindEnabledMessageMediaInstance(tx *dbs.Tx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateMediaInstance 创建媒介实例
|
// CreateMediaInstance 创建媒介实例
|
||||||
func (this *MessageMediaInstanceDAO) CreateMediaInstance(tx *dbs.Tx, name string, mediaType string, params maps.Map, description string) (int64, error) {
|
func (this *MessageMediaInstanceDAO) CreateMediaInstance(tx *dbs.Tx, name string, mediaType string, params maps.Map, description string, rateJSON []byte) (int64, error) {
|
||||||
op := NewMessageMediaInstanceOperator()
|
op := NewMessageMediaInstanceOperator()
|
||||||
op.Name = name
|
op.Name = name
|
||||||
op.MediaType = mediaType
|
op.MediaType = mediaType
|
||||||
@@ -96,13 +96,17 @@ func (this *MessageMediaInstanceDAO) CreateMediaInstance(tx *dbs.Tx, name string
|
|||||||
|
|
||||||
op.Description = description
|
op.Description = description
|
||||||
|
|
||||||
|
if len(rateJSON) > 0 {
|
||||||
|
op.Rate = rateJSON
|
||||||
|
}
|
||||||
|
|
||||||
op.IsOn = true
|
op.IsOn = true
|
||||||
op.State = MessageMediaInstanceStateEnabled
|
op.State = MessageMediaInstanceStateEnabled
|
||||||
return this.SaveInt64(tx, op)
|
return this.SaveInt64(tx, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateMediaInstance 修改媒介实例
|
// UpdateMediaInstance 修改媒介实例
|
||||||
func (this *MessageMediaInstanceDAO) UpdateMediaInstance(tx *dbs.Tx, instanceId int64, name string, mediaType string, params maps.Map, description string, isOn bool) error {
|
func (this *MessageMediaInstanceDAO) UpdateMediaInstance(tx *dbs.Tx, instanceId int64, name string, mediaType string, params maps.Map, description string, rateJSON []byte, isOn bool) error {
|
||||||
if instanceId <= 0 {
|
if instanceId <= 0 {
|
||||||
return errors.New("invalid instanceId")
|
return errors.New("invalid instanceId")
|
||||||
}
|
}
|
||||||
@@ -122,6 +126,10 @@ func (this *MessageMediaInstanceDAO) UpdateMediaInstance(tx *dbs.Tx, instanceId
|
|||||||
}
|
}
|
||||||
op.Params = paramsJSON
|
op.Params = paramsJSON
|
||||||
|
|
||||||
|
if len(rateJSON) > 0 {
|
||||||
|
op.Rate = rateJSON
|
||||||
|
}
|
||||||
|
|
||||||
op.Description = description
|
op.Description = description
|
||||||
op.IsOn = isOn
|
op.IsOn = isOn
|
||||||
return this.Save(tx, op)
|
return this.Save(tx, op)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 消息媒介接收人
|
// MessageMediaInstance 消息媒介接收人
|
||||||
type MessageMediaInstance struct {
|
type MessageMediaInstance struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
@@ -8,6 +8,7 @@ type MessageMediaInstance struct {
|
|||||||
MediaType string `field:"mediaType"` // 媒介类型
|
MediaType string `field:"mediaType"` // 媒介类型
|
||||||
Params string `field:"params"` // 媒介参数
|
Params string `field:"params"` // 媒介参数
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
|
Rate string `field:"rate"` // 发送频率
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ type MessageMediaInstanceOperator struct {
|
|||||||
MediaType interface{} // 媒介类型
|
MediaType interface{} // 媒介类型
|
||||||
Params interface{} // 媒介参数
|
Params interface{} // 媒介参数
|
||||||
Description interface{} // 备注
|
Description interface{} // 备注
|
||||||
|
Rate interface{} // 发送频率
|
||||||
State interface{} // 状态
|
State interface{} // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func (this *MessageMediaInstanceService) CreateMessageMediaInstance(ctx context.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instanceId, err := models.SharedMessageMediaInstanceDAO.CreateMediaInstance(tx, req.Name, req.MediaType, params, req.Description)
|
instanceId, err := models.SharedMessageMediaInstanceDAO.CreateMediaInstance(tx, req.Name, req.MediaType, params, req.Description, req.RateJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ func (this *MessageMediaInstanceService) UpdateMessageMediaInstance(ctx context.
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tx = this.NullTx()
|
var tx = this.NullTx()
|
||||||
err = models.SharedMessageMediaInstanceDAO.UpdateMediaInstance(tx, req.MessageMediaInstanceId, req.Name, req.MediaType, params, req.Description, req.IsOn)
|
err = models.SharedMessageMediaInstanceDAO.UpdateMediaInstance(tx, req.MessageMediaInstanceId, req.Name, req.MediaType, params, req.Description, req.RateJSON, req.IsOn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -131,6 +131,7 @@ func (this *MessageMediaInstanceService) ListEnabledMessageMediaInstances(ctx co
|
|||||||
MessageMedia: pbMedia,
|
MessageMedia: pbMedia,
|
||||||
ParamsJSON: []byte(instance.Params),
|
ParamsJSON: []byte(instance.Params),
|
||||||
Description: instance.Description,
|
Description: instance.Description,
|
||||||
|
RateJSON: []byte(instance.Rate),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,5 +179,6 @@ func (this *MessageMediaInstanceService) FindEnabledMessageMediaInstance(ctx con
|
|||||||
MessageMedia: pbMedia,
|
MessageMedia: pbMedia,
|
||||||
ParamsJSON: []byte(instance.Params),
|
ParamsJSON: []byte(instance.Params),
|
||||||
Description: instance.Description,
|
Description: instance.Description,
|
||||||
|
RateJSON: []byte(instance.Rate),
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ func (this *MessageTaskService) FindSendingMessageTasks(ctx context.Context, req
|
|||||||
Type: instance.MediaType,
|
Type: instance.MediaType,
|
||||||
},
|
},
|
||||||
ParamsJSON: []byte(instance.Params),
|
ParamsJSON: []byte(instance.Params),
|
||||||
|
RateJSON: []byte(instance.Rate),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else { // 没有指定既定的接收人
|
} else { // 没有指定既定的接收人
|
||||||
@@ -106,6 +107,7 @@ func (this *MessageTaskService) FindSendingMessageTasks(ctx context.Context, req
|
|||||||
Type: instance.MediaType,
|
Type: instance.MediaType,
|
||||||
},
|
},
|
||||||
ParamsJSON: []byte(instance.Params),
|
ParamsJSON: []byte(instance.Params),
|
||||||
|
RateJSON: []byte(instance.Rate),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,6 +352,7 @@ func (this *MessageTaskService) ListMessageTasksWithStatus(ctx context.Context,
|
|||||||
Type: instance.MediaType,
|
Type: instance.MediaType,
|
||||||
},
|
},
|
||||||
ParamsJSON: []byte(instance.Params),
|
ParamsJSON: []byte(instance.Params),
|
||||||
|
RateJSON: []byte(instance.Rate),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else { // 没有指定既定的接收人
|
} else { // 没有指定既定的接收人
|
||||||
@@ -375,6 +378,7 @@ func (this *MessageTaskService) ListMessageTasksWithStatus(ctx context.Context,
|
|||||||
Type: instance.MediaType,
|
Type: instance.MediaType,
|
||||||
},
|
},
|
||||||
ParamsJSON: []byte(instance.Params),
|
ParamsJSON: []byte(instance.Params),
|
||||||
|
RateJSON: []byte(instance.Rate),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user