123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package controllers
- import (
- "eta/eta_mini_ht_api/common/contants"
- "eta/eta_mini_ht_api/common/utils/page"
- stringUtils "eta/eta_mini_ht_api/common/utils/string"
- "strings"
- )
- type ListController struct {
- BaseController
- PageInfo page.PageInfo
- }
- const (
- video = "video"
- audio = "audio"
- productVideo = "video"
- productAudio = "audio"
- productReport = "report"
- productPackage = "package"
- )
- func (l *ListController) Prepare() {
- pageSize, _ := l.GetInt("pageSize")
- currentIndex, _ := l.GetInt("currentIndex")
- LatestId, _ := l.GetInt64("latestId")
- total, _ := l.GetInt64("total")
- if pageSize <= 0 {
- pageSize = contants.PageSizeDefault
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- if LatestId < 0 {
- LatestId = 0
- }
- l.PageInfo = page.PageInfo{
- LatestId: LatestId,
- Current: currentIndex,
- PageSize: pageSize,
- Total: total,
- }
- }
- func (l *ListController) TransPermissionIds(permissionIds string) (permissionIdList []int, err error) {
- if strings.HasPrefix(permissionIds, ",") {
- permissionIds = permissionIds[1:len(permissionIds)]
- }
- if strings.HasSuffix(permissionIds, ",") {
- permissionIds = permissionIds[0 : len(permissionIds)-1]
- }
- if permissionIds == "" {
- permissionIdList = []int{}
- } else {
- permissionIdList, err = stringUtils.StringToIntSlice(strings.Split(permissionIds, ","))
- }
- return
- }
- func (l *ListController) CheckMediaType(mediaType string) bool {
- if mediaType == video || mediaType == audio {
- return true
- }
- return false
- }
- func (l *ListController) CheckProductType(productType string) bool {
- if productType == productReport || productType == productPackage || productType == productVideo || productType == productAudio {
- return true
- }
- return false
- }
- //func (l *ListController) Finish() {
- // l.PageInfo.Reset()
- // runMode := web.BConfig.RunMode
- // if l.Data["json"] == nil {
- // logger.Warn("apiRequest:[异常提醒:%v 接口:URI:%v;无返回值]", runMode, l.Ctx.Input.URI())
- // return
- // }
- // baseRes := l.Data["json"].(BaseResponse)
- // if !baseRes.Success {
- // logger.Info("apiRequest:[异常提醒:%v接口:URI:%v;ErrMsg:&v;Msg:%v]", l.Ctx.Input.URI(), baseRes.ErrMsg, baseRes.Msg)
- // } else {
- // if baseRes.Data == nil {
- // logger.Warn("apiRequest:[异常提醒:%v 接口:URI:%v;无返回值]", runMode, l.Ctx.Input.URI())
- // return
- // } else {
- // logger.Info("apiRequest:[uri:%s, resData:%s, ip:%s]", l.Ctx.Input.URI(), baseRes.Data)
- // }
- // }
- //}
|