-
Notifications
You must be signed in to change notification settings - Fork 2
/
imp_params.go
51 lines (43 loc) · 1.18 KB
/
imp_params.go
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
51
package dao
import (
"database/sql"
"fmt"
"github.com/xfyun/xns/models"
"github.com/xfyun/xns/resource"
)
type paramsDao struct {
*baseDao
}
func NewParamDao(db *sql.DB)ParamsEnums{
return ¶msDao{baseDao:newBaseDao(db,&models.CustomParamEnum{},ChannelParams,TableParamValueEnums)}
}
func (p *paramsDao) Create(enum *models.CustomParamEnum) (err error) {
createBase(&enum.Base)
return p.insertOnly(enum)
}
func (p *paramsDao) Delete(paraName, paramValue string) (err error) {
return p.deleteOnly(newCond().eq("param_name", paraName).and().eq("value", paramValue).String())
}
func (p *paramsDao) GetValues(paramName string) (res []*models.CustomParamEnum, err error) {
err = p.queryByCond(newCond().eq("param_name", paramName).String(), &res)
return
}
func (p *paramsDao) GetParamList() (rs []*models.CustomParamEnum, err error) {
err = p.queryAll(&rs)
return
}
func (p *paramsDao) Init() error {
for _, param := range resource.Params {
err := p.Create(&models.CustomParamEnum{
Base: models.Base{
Description: param.Desc,
},
ParamName: param.Name,
Value: param.Value,
})
if err != nil{
return fmt.Errorf("init create param error")
}
}
return nil
}