liuxiaolong
2019-06-15 1efc7ae174f57e6a0a96ccfe4efadc9390589b5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package models
 
import (
    "time"
)
 
type VSSLocalSettingTbl struct {
    ID int `json:"ID,omitempty" gorm:"primary_key" `
    ServerIp string `json:"ServerIp,omitempty" example:"SIP服务器IP" gorm:"column:ServerIp"`
    ServerPort int `json:"ServerPort,omitempty" example:"21231" gorm:"column:ServerPort"`
    ServerId string `json:"ServerId,omitempty" example:"SIP服务器Id" gorm:"column:ServerId"`
    UserAuthId string `json:"UserAuthId,omitempty" example:"SIP用户认证ID" gorm:"column:UserAuthId"`
    Password string `json:"Password,omitempty" example:"密码" gorm:"column:Password"`
    UpdateTime time.Time `json:"-" gorm:"column:UpdateTime"`
}
 
func (VSSLocalSettingTbl)TableName() string {
    return  "VSSLocalSettingTbl"
}
 
 
func (vst *VSSLocalSettingTbl) Select() (err error) {
    if err = db.Table("VSSLocalSettingTbl").First(&vst).Error; err != nil {
        if err.Error() == "record not found"{ vst = nil; return nil }
        return err
    }
    return nil
}
 
/*func (vst *VSSLocalSettingTbl) Insert() (err error) {
    tx := db.Table("VSSLocalSettingTbl").Begin()
    if tx.Error != nil {
        return err
    }
    fmt.Println(vst)
    if err := tx.Create(&vst).Error; err != nil {
        tx.Rollback()
        return err
    }
    return tx.Commit().Error
}*/
 
func (vst *VSSLocalSettingTbl) Update() error {  // cid int
    // find record by id
    vst.UpdateTime = time.Now()
    if err := db.Save(&vst).Error; err != nil {
        return err
    }
    return nil
}