package gate_command import ( "git.getensh.com/common/gopkgs/database" "property-device/errors" dbmodel "property-device/model" "property-device/utils/gate_utils" "time" ) type SaiboHttpv1Commander struct { command bool GateInfo *dbmodel.TGate } func (p *SaiboHttpv1Commander) Open() error { now := time.Now() tgc := &dbmodel.TGateCommand{ CreatedAt: now, UpdatedAt: now, DeviceId: p.GateInfo.ID, //Param: req.CmdParams, Desc: gate_utils.CommandCodeMap[gate_utils.OpenCommand], Status: gate_utils.CommandStatusWait, ResultStatus: 0, ResultStatusDesc: "", Code: gate_utils.OpenCommand, } err := tgc.Insert(database.DB()) if err != nil { return errors.DataBaseError } p.command = true return nil } func (p *SaiboHttpv1Commander) Reboot() error { now := time.Now() tgc := &dbmodel.TGateCommand{ CreatedAt: now, UpdatedAt: now, DeviceId: p.GateInfo.ID, //Param: req.CmdParams, Desc: gate_utils.CommandCodeMap[gate_utils.RebootCommand], Status: gate_utils.CommandStatusWait, ResultStatus: 0, ResultStatusDesc: "", Code: gate_utils.RebootCommand, } err := tgc.Insert(database.DB()) if err != nil { return errors.DataBaseError } p.command = true return nil } func (p *SaiboHttpv1Commander) Command() bool { return p.command }