package Account import ( "ERP_ams/conf" "ERP_ams/logs" "fmt" menulibs "git.baozhida.cn/ERP_libs/Menu" "git.baozhida.cn/ERP_libs/lib" "github.com/astaxie/beego/cache" _ "github.com/astaxie/beego/cache/redis" "github.com/beego/beego/v2/adapter/orm" ) var RedisCache_API cache.Cache func init() { orm.RegisterModel(new(menulibs.Menu)) orm.RegisterModel(new(menulibs.API)) var err error apiConfig := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`, "redis_ERP_AMS_API", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password) fmt.Println(apiConfig) RedisCache_API, err = cache.NewCache("redis", apiConfig) if err != nil || RedisCache_API == nil { errMsg := "failed to init redis api" logs.Error(errMsg, err) panic(errMsg) } } // 获取列表 func Read_API_List_ByPower(T_power_id string, Menu_Bind string) (maps []menulibs.API) { if len(Menu_Bind) == 0 { return } o := orm.NewOrm() APIDao := menulibs.NewAPI(o, RedisCache_API) maps, err := APIDao.Read_API_List_ByPower(T_power_id, Menu_Bind) if err != nil { logs.Error(lib.FuncName(), err) return } return maps }