package crm

import (
	"hongze/fms_api/global"
	"time"
)

// SysGroup 系统分组表
type SysGroup struct {
	GroupId      int       `gorm:"primaryKey;column:group_id;type:int(11);not null" json:"group_id"`
	DepartmentId int       `gorm:"index:idx_department_id;column:department_id;type:int(11)" json:"department_id"` // 部门id
	GroupName    string    `gorm:"column:group_name;type:varchar(255);default:''" json:"group_name"`               // 分组名称
	CreateTime   time.Time `gorm:"column:create_time;type:datetime" json:"create_time"`
	ParentId     int       `gorm:"column:parent_id;type:int(11);default:0" json:"parent_id"`
}

func (m *SysGroup) TableName() string {
	return "sys_group"
}

type SysGroupListReq struct {
	SellerType int    `json:"seller_type" form:"seller_type" description:"销售类型:1ficc销售,2权益销售"`
}

func (m *SysGroup) List(condition string, pars []interface{}) (list []*SysGroup, err error) {
	list = make([]*SysGroup, 0)
	err = global.MYSQL["report"].Model(m).
		Where(condition, pars...).
		Find(&list).Error
	return
}

func (m *SysGroup) Count(condition string, pars []interface{}) (total int64, err error) {
	err = global.MYSQL["report"].Model(m).
		Where(condition, pars...).
		Count(&total).Error
	return
}

type AllSellerResp struct {
	FiccSeller []*SellerAdminWithGroupTeam
	RaiSeller []*SellerAdminWithGroupTeam
}