package course

import (
	"spaceofcheng/services/models/model"
	"spaceofcheng/services/service"

	"github.com/astaxie/beego"
)

// GetTagsList 获取标签列表
func (s *CourseServ) GetTagsList(orgid string, page, pageSize int) (map[string]interface{}, error) {
	if pageSize == 0 {
		pageSize = service.PAGENUM
	}
	if page == 0 {
		page = 1
	}
	tags, err := s.dao.GetTagsList(orgid, page, pageSize)
	if err != nil {
		beego.Error(err)
		return nil, err
	}
	total, err := s.dao.GetTagsCount(orgid)
	if err != nil {
		beego.Error(err)
		return nil, err
	}

	return map[string]interface{}{
		"list":     tags,
		"pagesize": pageSize,
		"pagenum":  total,
		"page":     page,
	}, err
}

// GetCourseTags 获取课程标签
func (s *CourseServ) GetCourseTags(orgid string) ([]model.TdCourseTag, error) {
	tags, err := s.dao.GetTagsList(orgid, 0, 10000)
	return tags, err
}
