12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package controllers
- import (
- "eta/eta_mini_api/models"
- "eta/eta_mini_api/utils"
- )
- type BannerController struct {
- BaseAuthController
- }
- // @Title List
- // @Description create users
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.BaseResponse
- // @router /list [get]
- func (this *BannerController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- if currentIndex <= 0 {
- currentIndex = 1
- }
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- startSize := utils.StartIndex(currentIndex, pageSize)
- banners, err := models.GetBannerList(startSize, pageSize)
- if err != nil {
- br.Msg = "获取banner列表失败"
- br.ErrMsg = "获取banner列表失败,系统异常,Err:" + err.Error()
- return
- }
- br.Data = banners
- br.Msg = "获取banner列表成功"
- br.Success = true
- br.Ret = 200
- }
- // @Title Detail
- // @Description banner详情
- // @Param BannerId query int true "bannerId"
- // @Success 200 {object} models.BaseResponse
- // @router /detail [get]
- func (this *BannerController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- bannerId, _ := this.GetInt("BannerId")
- banners, err := models.GetBannerById(bannerId)
- if err != nil {
- br.Msg = "获取banner详情失败"
- br.ErrMsg = "获取banner详情失败,系统异常,Err:" + err.Error()
- return
- }
- br.Data = banners
- br.Msg = "获取banner列表成功"
- br.Success = true
- br.Ret = 200
- }
|