1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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
- }
|