zhangzengfei
2023-09-04 e8e536d1cb52d2126c8c7ce2ba1c7a76f7208678
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
package models
 
type SysInit struct {
    InitPwd      bool   `gorm:"column:initPwd;default:false" json:"initPwd"` //是否已配置过登录密码
    InitUsername string `gorm:"column:initUsername" json:"initUsername"`     //初始化的用户名
    NetName      string `gorm:"column:netName" json:"netName"`               //网络名称
    UserType     string `gorm:"column:userType" json:"userType"`             //个人:personal  公司: company
    PhoneNum     string `gorm:"column:phoneNum" json:"phoneNum"`             //手机号码
    Name         string `gorm:"column:name" json:"name"`                     //姓名或公司名称
    ProvinceId   string `gorm:"column:provinceId" json:"provinceId"`         //省
    CityId       string `gorm:"column:cityId" json:"cityId"`                 //市
    CountyId     string `gorm:"column:countyId" json:"countyId"`             //县
    Email        string `gorm:"column:email" json:"email"`                   //邮箱
    InitTime     string `gorm:"column:initTime" json:"initTime"`             //初始化时间
}
 
func (SysInit) TableName() string {
    return "sys_init"
}
 
func (ds *SysInit) Insert() bool {
    result := db.Table(ds.TableName()).Create(&ds)
    if result.Error == nil && result.RowsAffected > 0 {
        return true
    }
    return false
}
 
func (ds *SysInit) Update() bool {
    result := db.Table(ds.TableName()).Update(&ds)
    if result.Error == nil && result.RowsAffected > 0 {
        return true
    }
    return false
}
 
func (ds *SysInit) Select() (int64, error) {
    result := db.Table(ds.TableName()).First(&ds)
    return result.RowsAffected, result.Error
}
 
func (ds *SysInit) DeleteById() bool {
    result := db.Exec("delete from " + ds.TableName() + "")
    if result.Error == nil && result.RowsAffected > 0 {
        return true
    }
    return false
}