package cygx

import (
	"hongze/hz_crm_api/models/system"
	"strconv"
	"strings"
)

// GetAdminActivityPermission 活动查看权限SQL预处理
func GetAdminActivityPermission(adminInfo *system.Admin, condition string) (conditionPermission string, err error) {
	adminList, err := system.GetAdminListByGroupId(adminInfo.GroupId)
	if err != nil {
		return
	}
	adminIdArr := make([]string, 0)
	for _, v := range adminList {
		adminIdArr = append(adminIdArr, strconv.Itoa(v.AdminId))
	}
	var adminidStr string
	adminidStr = strings.Join(adminIdArr, ",")
	conditionPermission = ` OR ( visible_range = 1 AND art.admin_id IN (` + adminidStr + `) ` + condition + `) `
	//conditionPermission += ` OR (art.activity_type_id = 7 AND  visible_range != 1  ` + condition + `) `
	return
}
