From d83f5863d6c675d6aed09cfe7bfdaadc0c6221d9 Mon Sep 17 00:00:00 2001 From: 554325746@qq.com <554325746@qq.com> Date: 星期五, 05 七月 2019 18:32:05 +0800 Subject: [PATCH] fix enable and add update dbtable enable value --- models/localconfig.go | 71 +++++++---------------------------- 1 files changed, 15 insertions(+), 56 deletions(-) diff --git a/models/localconfig.go b/models/localconfig.go index 09e9197..bc602fa 100644 --- a/models/localconfig.go +++ b/models/localconfig.go @@ -1,58 +1,17 @@ package models -type LocalConfig struct { - ID int `json:"-"` - Alarm_ip string `json:"alarm_ip,omitempty" example:"192.168.1.182"` - Alarm_port int `json:"alarm_port,omitempty" example:"22122"` - Web_pic_ip string `json:"web_pic_ip,omitempty" example:""` - Web_pic_port int `json:"web_pic_port,omitempty" example:"22122"` - Es_pic_ip string `json:"es_pic_ip,omitempty" example:""` - Es_pic_port int `json:"es_pic_port,omitempty" example:"22122"` - Cut_max_duration int `json:"cut_max_duration,omitempty" example:"20"` - Cut_min_duration int `json:"cut_min_duration,omitempty" example:"5"` - Dev_id string `json:"dev_id,omitempty" example:"鍒嗘瀽璁惧id"` - Dev_name string `json:"dev_name,omitempty" example:"鍒嗘瀽璁惧鍚嶇О"` - Dev_type int `json:"dev_type,omitempty" example:"1"` - Reserved string `json:"dev_type,omitempty" example:"1"` -} - -// 璁剧疆User鐨勮〃鍚嶄负`profiles` -func (LocalConfig) TableName() string { - return "local_configs" -} - -func (loCon *LocalConfig) FindAreaSliece() (config []LocalConfig, err error) { - if err := db.Table(loCon.TableName()).Find(&config).Error; err != nil { - return nil, err - } - return config, nil -} - -/*func (loCon *LocalConfig) Create() (err error){ - tx := db.Table(loCon.TableName()).Begin() - if tx.Error != nil { - return err - } - fmt.Println(loCon) - if err := tx.Create(&loCon).Error; err != nil { - tx.Rollback() - return err - } - return tx.Commit().Error -}*/ - -func (loCon *LocalConfig) Select()(err error) { - if err = db.Table(loCon.TableName()).First(&loCon).Error; err != nil{ - if err.Error() == "record not found"{ loCon = nil; return nil } - return err - } - return nil -} - -func (loCon *LocalConfig) Update() error{ - if err := db.Save(&loCon).Error; err != nil { - return err - } - return nil -} - +//type LocalConfig struct { +// ID int `json:"-"` +// Alarm_ip string `json:"alarm_ip,omitempty" example:"192.168.1.182"` +// Alarm_port int `json:"alarm_port,omitempty" example:"22122"` +// Web_pic_ip string `json:"web_pic_ip,omitempty" example:""` +// Web_pic_port int `json:"web_pic_port,omitempty" example:"22122"` +// Es_pic_ip string `json:"es_pic_ip,omitempty" example:""` +// Es_pic_port int `json:"es_pic_port,omitempty" example:"22122"` +// Cut_max_duration int `json:"cut_max_duration,omitempty" example:"20"` +// Cut_min_duration int `json:"cut_min_duration,omitempty" example:"5"` +// Dev_id string `json:"dev_id,omitempty" example:"鍒嗘瀽璁惧id"` +// Dev_name string `json:"dev_name,omitempty" example:"鍒嗘瀽璁惧鍚嶇О"` +// Dev_type int `json:"dev_type,omitempty" example:"1"` +// Reserved string `json:"dev_type,omitempty" example:"1"` +//} \ No newline at end of file -- Gitblit v1.8.0