1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package company
- import (
- "encoding/json"
- "errors"
- "eta/eta_api/utils"
- "github.com/beego/beego/v2/client/orm"
- )
- const (
- ConfAreaCodeListKey = "area_code_list"
- ConfEnAuthRoleKey = "en_auth_role"
- )
- type CrmConfig struct {
- 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
- }
- func GetConfigDetailByCode(configCode string) (item CrmConfig, err error) {
- o := orm.NewOrm()
- sql := ` SELECT config_value FROM crm_config WHERE config_code=? `
- err = o.Raw(sql, configCode).QueryRow(&item)
- return
- }
- type ConfEnAuthRole struct {
- RoleCode string `description:"角色编码"`
- RoleName string `description:"角色名称"`
- SyncCrm bool `description:"是否同步CRM"`
- }
- type ConfigClassifyId struct {
- Debug int `json:"debug"`
- Release int `json:"release"`
- }
- 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
- }
|