Ver Fonte

envitem setvalue append commandType

gaoyagang há 9 meses atrás
pai
commit
665715f5a7
2 ficheiros alterados com 17 adições e 9 exclusões
  1. 12 5
      envitem/func.go
  2. 5 4
      envitem/types.go

+ 12 - 5
envitem/func.go

@@ -403,14 +403,21 @@ func (e *EnvItem) IncreAdjust(expire time.Duration) (int64, error) {
 	return intCmd.Val(), nil
 }
 
-func (e *EnvItem) SetValue(o, v string) error {
+func (e *EnvItem) SetValue(o, v string, ct ...int64) error {
 	ts := time.Now().Unix()
+
+	var commandType int64
+	if len(ct) > 0 {
+		commandType = ct[0]
+	}
+
 	data := make(SetCurrentsReq, 1)
 	data[0] = SetCurrentReq{
-		ProjectId: e.ProjectId,
-		Item:      e.Item,
-		OldValue:  o,
-		NewValue:  v,
+		ProjectId:   e.ProjectId,
+		Item:        e.Item,
+		OldValue:    o,
+		NewValue:    v,
+		CommandType: commandType,
 	}
 
 	sign := data.Sign(plcItemSecret, ts)

+ 5 - 4
envitem/types.go

@@ -52,10 +52,11 @@ type (
 	}
 
 	SetCurrentReq struct {
-		ProjectId int64  `json:"project_id"`
-		Item      string `json:"item"`
-		OldValue  string `json:"old_value"`
-		NewValue  string `json:"new_value"`
+		ProjectId   int64  `json:"project_id"`
+		Item        string `json:"item"`
+		OldValue    string `json:"old_value"`
+		NewValue    string `json:"new_value"`
+		CommandType int64  `json:"command_type"`
 	}
 
 	SetCurrentsReq []SetCurrentReq