12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package company
- import (
- "encoding/json"
- "errors"
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "time"
- )
- const (
- ConfAreaCodeListKey = "area_code_list" // 手机号区号列表
- ConfEnAuthRoleKey = "en_auth_role" // 英文权限角色配置Key
- )
- type CrmConfig struct {
- ConfigId int `gorm:"primaryKey;column:config_id;type:int(11);not null"`
- ConfigCode string `gorm:"column:config_code;type:varchar(50);default:''"` // 配置编码
- ConfigValue string `gorm:"column:config_value;type:text"` // 配置值
- Remark string `gorm:"column:remark;type:varchar(255);default:''"` // 备注信息
- CreateTime time.Time `gorm:"column:create_time;type:datetime"` // 创建时间
- }
- func GetConfigDetailByCode(configCode string) (item CrmConfig, err error) {
- sql := ` SELECT config_value FROM crm_config WHERE config_code=? `
- err = global.DEFAULT_DmSQL.Raw(sql, configCode).First(&item).Error
- 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
- }
|