12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package company
- import (
- "encoding/json"
- "errors"
- "github.com/beego/beego/v2/client/orm"
- "hongze/hz_crm_api/utils"
- )
- const (
- ConfAreaCodeListKey = "area_code_list"
- )
- type CrmConfig struct {
- ConfigCode string `description:"详情Code"`
- ConfigValue string `description:"详情"`
- }
- func GetConfigValueByCode(configCode string) (total int, err error) {
- o := orm.NewOrm()
- sql := ` SELECT config_value FROM crm_config WHERE config_code=? `
- err = o.Raw(sql, configCode).QueryRow(&total)
- return
- }
- func CrmConfigUpdate(newValue, configCode string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE crm_config SET config_value=? WHERE config_code= ?`
- _, err = o.Raw(sql, newValue, configCode).Exec()
- return
- }
- type ConfigClassifyId struct {
- Debug int `json:"debug"`
- Release int `json:"release"`
- }
- func GetConfigDetailByCode(configCode string) (item CrmConfig, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * FROM crm_config WHERE config_code=? `
- err = o.Raw(sql, configCode).QueryRow(&item)
- return
- }
- func GetReportClassifyIdByConfigKey(configKey string) (classifyId int, err error) {
-
- conf, e := GetConfigDetailByCode(configKey)
- if e != nil {
- err = errors.New("获取配置的id失败, Err: " + e.Error())
- return
- }
- if conf.ConfigValue == "" {
- err = errors.New("ID配置有误")
- return
- }
- type TwoWeekIdConf struct {
- Debug []int
- Release []int
- }
- classifyIdConf := new(ConfigClassifyId)
- if e = json.Unmarshal([]byte(conf.ConfigValue), &classifyIdConf); e != nil {
- err = errors.New("解析ID配置失败, Err: " + e.Error())
- return
- }
- if utils.RunMode == "debug" {
- classifyId = classifyIdConf.Debug
- } else {
- classifyId = classifyIdConf.Release
- }
- return
- }
|