完善自我更新逻辑
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type MqttTopic struct {
|
||||
Project string
|
||||
DeptId string
|
||||
Domain string
|
||||
DeviceType string
|
||||
DeviceID string
|
||||
@@ -21,7 +21,7 @@ func FromStringToMqttTopic(topic string) *MqttTopic {
|
||||
parts = append(parts, "")
|
||||
}
|
||||
return &MqttTopic{
|
||||
Project: parts[0],
|
||||
DeptId: parts[0],
|
||||
Domain: parts[1],
|
||||
DeviceType: parts[2],
|
||||
DeviceID: parts[3],
|
||||
@@ -38,7 +38,7 @@ func (m *MqttTopic) ToString() string {
|
||||
return s
|
||||
}
|
||||
return strings.Join([]string{
|
||||
toVal(m.Project),
|
||||
toVal(m.DeptId),
|
||||
toVal(m.Domain),
|
||||
toVal(m.DeviceType),
|
||||
toVal(m.DeviceID),
|
||||
@@ -48,7 +48,7 @@ func (m *MqttTopic) ToString() string {
|
||||
|
||||
// 严格生成 topic,不允许 "+" 或空
|
||||
func (m *MqttTopic) Build() (string, error) {
|
||||
parts := []string{m.Project, m.Domain, m.DeviceType, m.DeviceID, m.Resource}
|
||||
parts := []string{m.DeptId, m.Domain, m.DeviceType, m.DeviceID, m.Resource}
|
||||
for _, p := range parts {
|
||||
if p == "" || p == "+" {
|
||||
return "", errors.New("cannot build strict topic, wildcard exists")
|
||||
|
||||
Reference in New Issue
Block a user