123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package controllers
- import (
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/services"
- "hongze/hongze_clpt/utils"
- )
- // 产品内测
- type ProductInteriorController struct {
- BaseAuthController
- }
- // @Title 列表
- // @Description 列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
- // @router /list [get]
- func (this *ProductInteriorController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- resp := new(models.GetCygxProductInteriorResp)
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- condition += ` AND art.status = 1 `
- total, err := models.GetCygxProductInteriorCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- condition += " ORDER BY art.publish_time DESC , art.product_interior_id DESC "
- list, err := models.GetCygxProductInteriorList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range list {
- v.PublishTime = utils.TimeRemoveHms(v.PublishTime)
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 详情
- // @Description 获取详情接口
- // @Param ProductInteriorId query int true "ID"
- // @Success Ret=200 {object} cygx.GetCygxProductInteriorDetailResp
- // @router /detail [get]
- func (this *ProductInteriorController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- resp := new(models.GetCygxProductInteriorDetailResp)
- productInteriorId, _ := this.GetInt("ProductInteriorId")
- if productInteriorId < 1 {
- br.Msg = "请输入详情ID"
- return
- }
- detail, err := models.GetCygxProductInteriorDetail(productInteriorId)
- if err != nil {
- br.Msg = "详情不存在"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- //未设置全部可见的只能给弘则内部查看
- if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
- resp.IsShow = true
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 || !resp.IsShow {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail.PublishTime = utils.TimeRemoveHms2(detail.PublishTime)
- detail.ShareImg = utils.PRODUCT_INTERIOR_SHARE_IMG
- resp.Detail = detail
- detail.BodySlice = services.GetProductInteriorUrlBody(detail.Body)
- resp.Disclaimers = utils.DISCLAIMERS_PRODUCT_INTERIOR // 免责声明
- go services.AddCygxProductInteriorHistory(user, productInteriorId)
- go services.ProductInteriorHistoryUserRmind(user, productInteriorId)
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|