12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package Account
- import (
- "ERP_ams/conf"
- "ERP_ams/logs"
- "fmt"
- "github.com/astaxie/beego/cache"
- _ "github.com/astaxie/beego/cache/redis"
- "github.com/beego/beego/v2/adapter/orm"
- menulibs "gogs.baozhida.cn/zoie/ERP_libs/Menu"
- "gogs.baozhida.cn/zoie/ERP_libs/lib"
- )
- 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
- }
|