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" ) 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) Finish() { l.PageInfo.Reset() }