64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package annouser
|
|
|
|
import (
|
|
"91porn-server/common"
|
|
"91porn-server/common/localcache"
|
|
"91porn-server/models/v/adsmod"
|
|
"91porn-server/models/v/annoumod"
|
|
"fmt"
|
|
"time"
|
|
|
|
"91porn-server/common/log"
|
|
)
|
|
|
|
// GetAnnouList 获取指定类型的公告
|
|
func GetAnnouList(t int) (out *Annou, err error) {
|
|
log.Info(fmt.Sprintf("[Params-%s]", "GetAnnouList"), log.Any("type", t))
|
|
cfg, ok := localcache.C.Get(adsmod.GetAnnounceByTypeList)
|
|
if ok {
|
|
return cfg.(*Annou), nil
|
|
}
|
|
if out, err = getAnnouList(); err != nil {
|
|
log.Error(fmt.Sprintf("[HTTP-%s]==> request fail error:%v:", "GetAnnouList", err), log.Any("type", t))
|
|
return
|
|
}
|
|
common.Go(func() {
|
|
localcache.C.Set(adsmod.GetAnnounceByTypeList, out, 10*time.Minute)
|
|
})
|
|
return
|
|
}
|
|
|
|
// AnnouList 公告列表
|
|
func AnnouList() (out []*Annou, err error) {
|
|
log.Info(fmt.Sprintf("[Params-%s]", "GetAnnouList"))
|
|
cfg, ok := localcache.C.Get(adsmod.GetAnnounceList)
|
|
if ok {
|
|
return cfg.([]*Annou), nil
|
|
}
|
|
if out, err = annouList(); err != nil {
|
|
log.Error(fmt.Sprintf("[HTTP-%s]==> request fail error:%v:", "GetAnnouList", err))
|
|
return
|
|
}
|
|
common.Go(func() {
|
|
localcache.C.Set(adsmod.GetAnnounceList, out, 5*time.Minute)
|
|
})
|
|
return
|
|
}
|
|
|
|
// MsgAnnouList 消息模块公告列表
|
|
func MsgAnnouList(req annoumod.MsgListReq) (out *MsgAnnousResp, err error) {
|
|
log.Info(fmt.Sprintf("[Params-%s]", "MsgAnnouList"))
|
|
cfg, ok := localcache.C.Get(adsmod.GetMsgAnnounceList)
|
|
if ok {
|
|
return cfg.(*MsgAnnousResp), nil
|
|
}
|
|
if out, err = annouLists(req.PageNumber, req.PageSize); err != nil {
|
|
log.Error(fmt.Sprintf("[HTTP-%s]==> request fail error:%v:", "MsgAnnouList", err))
|
|
return
|
|
}
|
|
common.Go(func() {
|
|
localcache.C.Set(adsmod.GetMsgAnnounceList, out, 10*time.Minute)
|
|
})
|
|
return
|
|
}
|