package system

import (
	"server/dao"
	"server/model/system/request"
)

//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateSysDictionaryDetail
//@description: 创建字典详情数据
//@param: sysDictionaryDetail model.SysDictionaryDetail
//@return: err error

type DictionaryDetailService struct{}

func (dictionaryDetailService *DictionaryDetailService) CreateSysDictionaryDetail(sysDictionaryDetail dao.SysDictionaryDetail) error {
	return sysDictionaryDetail.CreateSysDictionaryDetail()
}

//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteSysDictionaryDetail
//@description: 删除字典详情数据
//@param: sysDictionaryDetail model.SysDictionaryDetail
//@return: err error

func (dictionaryDetailService *DictionaryDetailService) DeleteSysDictionaryDetail(sysDictionaryDetail dao.SysDictionaryDetail) error {
	return sysDictionaryDetail.DeleteSysDictionaryDetail()
}

//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateSysDictionaryDetail
//@description: 更新字典详情数据
//@param: sysDictionaryDetail *model.SysDictionaryDetail
//@return: err error

func (dictionaryDetailService *DictionaryDetailService) UpdateSysDictionaryDetail(sysDictionaryDetail *dao.SysDictionaryDetail) error {
	return sysDictionaryDetail.UpdateSysDictionaryDetail()
}

//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSysDictionaryDetail
//@description: 根据id获取字典详情单条数据
//@param: id uint
//@return: sysDictionaryDetail system.SysDictionaryDetail, err error

func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetail(id uint) (dao.SysDictionaryDetail, error) {
	return dao.GetSysDictionaryDetailById(id)
}

//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSysDictionaryDetailInfoList
//@description: 分页获取字典详情列表
//@param: info request.SysDictionaryDetailSearch
//@return: list interface{}, total int64, err error

func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (list interface{}, total int64, err error) {
	limit := info.PageSize
	offset := info.PageSize * (info.Page - 1)
	return info.SysDictionaryDetail.GetSysDictionaryDetailInfoList(limit, offset)
}

// GetDictionaryList 按照字典id获取字典全部内容的方法
func (dictionaryDetailService *DictionaryDetailService) GetDictionaryList(dictionaryID uint) ([]dao.SysDictionaryDetail, error) {
	return dao.GetDictionaryListByDictionaryId(dictionaryID)
}

// GetDictionaryListByType 按照字典type获取字典全部内容的方法
func (dictionaryDetailService *DictionaryDetailService) GetDictionaryListByType(t string) ([]dao.SysDictionaryDetail, error) {
	return dao.GetDictionaryListByType(t)
}

// GetDictionaryInfoByValue 按照字典id+字典内容value获取单条字典内容
func (dictionaryDetailService *DictionaryDetailService) GetDictionaryInfoByValue(dictionaryID uint, value uint) (dao.SysDictionaryDetail, error) {
	return dao.GetDictionaryInfoByValue(dictionaryID, value)
}

// GetDictionaryInfoByTypeValue 按照字典type+字典内容value获取单条字典内容
func (dictionaryDetailService *DictionaryDetailService) GetDictionaryInfoByTypeValue(t string, value uint) (dao.SysDictionaryDetail, error) {
	return dao.GetDictionaryInfoByTypeValue(t, value)
}
