/*
 * @description: 管理员数据处理
 * @Author: CP
 * @Date: 2020-08-20 17:08:38
 * @FilePath: \construction_management\services\manager_service.go
 */
package services

import (
	"go.mod/dao"
	"go.mod/datasource"
	"go.mod/models"
)

//定义管理员Service接口
type ManagerService interface {
	GetAll() []models.CmManager
	CountAll() int64
	Get(id int) *models.CmManager
	Update(data *models.CmManager, columns []string) error
	Create(data *models.CmManager) error
}

//返回service操作类
type managerService struct {
	dao *dao.ManagerDao
}

//创建管理员service
func NewManagerService() ManagerService {
	return &managerService{
		dao: dao.NewManagerDao(datasource.InstanceDbMaster()),
	}
}

//实现getall接口
func (s *managerService) GetAll() []models.CmManager {
	return s.dao.GetAll()
}

func (s *managerService) CountAll() int64 {
	return s.dao.CountAll()
}

func (s *managerService) Get(id int) *models.CmManager {
	return s.dao.Get(id)
}
func (s *managerService) Update(data *models.CmManager, columns []string) error {
	return s.dao.Update(data, columns)
}
func (s *managerService) Create(data *models.CmManager) error {
	return s.dao.Create(data)
}
