rdluck преди 4 години
родител
ревизия
f9ba46b05d
променени са 3 файла, в които са добавени 42 реда и са изтрити 16 реда
  1. 40 16
      controllers/video.go
  2. 1 0
      models/video.go
  3. 1 0
      utils/config.go

+ 40 - 16
controllers/video.go

@@ -7,7 +7,7 @@ import (
 	"time"
 )
 
-//报告
+//视频
 type VideoController struct {
 	BaseAuthController
 }
@@ -67,6 +67,25 @@ func (this *VideoController) List() {
 		return
 	}
 
+	status := 0
+	company, err := models.GetCompanyById(user.CompanyId)
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取报告详情失败"
+			br.ErrMsg = "获取用户管理企业信息失败,Err:" + err.Error()
+			return
+		} else {
+			status = 1
+		}
+	}
+	if company == nil {
+		status = 1
+	} else {
+		if company.CompanyType == 3 || company.CompanyType == 4 {
+			status = 1
+		}
+	}
+
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	keyWord := this.GetString("KeyWord")
@@ -116,25 +135,30 @@ func (this *VideoController) List() {
 		condition += ` AND a.publish_time >=? `
 		pars = append(pars, publishDate)
 	}
+	total := 0
+	resp := new(models.VideoListResp)
+	if status == 0 {
+		total, err = models.GetVideoListCount(condition, pars)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
+			return
+		}
 
-	total, err := models.GetVideoListCount(condition, pars)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
-		return
-	}
-
-	list, err := models.GetVideoList(condition, pars, startSize, pageSize)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取数据失败,Err:" + err.Error()
-		return
+		list, err := models.GetVideoList(condition, pars, startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp.List = list
+	} else {
+		list := make([]*models.VideoList, 0)
+		resp.List = list
 	}
-
 	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(models.VideoListResp)
-	resp.List = list
 	resp.Paging = page
+	resp.Status = status
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 1 - 0
models/video.go

@@ -74,4 +74,5 @@ func GetVideoList(condition string, pars []interface{}, startSize, pageSize int)
 type VideoListResp struct {
 	Paging *paging.PagingItem
 	List   []*VideoList
+	Status int `description:"权限状态:0:有权限,1:无权限"`
 }

+ 1 - 0
utils/config.go

@@ -56,3 +56,4 @@ func init() {
 
 //http://webapi.brilliantstart.cn/api/
 //http://webapi.brilliantstart.cn/swagger/
+//http://139.196.122.219:8603/swagger/