package com.donglan.ahxf.ahxfmeetregisterwindow.service;


import com.donglan.ahxf.ahxfmeetregisterwindow.dao.DictDao;
import com.donglan.ahxf.ahxfmeetregisterwindow.entity.Dict;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shj
 * @date 2019-12-30 10:44
 */
@Service
public class DictService {

    @Autowired
    private DictDao dictDao;

    public List<Dict> findByIdLikeAndIsDelete(String codeType, Integer isDelete){
        if(StringUtils.isEmpty(codeType))
            throw new RuntimeException("Dict.findByIdLikeAndIsDelete参数错误");
        return dictDao.findByIdLikeAndIsDelete(codeType,isDelete);
    }

    public List<Dict> findByIdLikeAndParentIdIsNullAndIsDeleteOrderByValue(String codeType,Integer isDelete){
        if(StringUtils.isEmpty(codeType))
            throw new RuntimeException("Dict.findByIdLikeAndParentIdIsNullAndIsDeleteOrderByValue参数错误");
        return dictDao.findByIdLikeAndParentIdIsNullAndIsDeleteOrderByValue(codeType,isDelete);
    }

    public List<Dict> findByIdLikeAndParentIdAndIsDelete(String codeType,String parentId,Integer isDelete){
        if(StringUtils.isEmpty(parentId))
            throw new RuntimeException("Dict.findByParentIdAndIsDelete参数错误");
        return dictDao.findByIdLikeAndParentIdAndIsDelete(codeType,parentId,isDelete);
    }

    public List<Dict> findAllByIdAndParentValueIsNull(String id){
        return dictDao.findAllByIdAndParentIdIsNullOrderByOrderNum(id);
    }

    public Dict findByIdAndValueAndIsDelete(String codeType,String value,Integer isDelete){
        return dictDao.findByIdAndValueAndIsDelete(codeType,value,isDelete);
    }
}
