package cn.wisenergy.service.impl;

import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkTypeMapper;
import cn.wisenergy.model.app.WorkType;
import cn.wisenergy.service.WorkTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @Authotr:陈奇
 * @QQ1799796883
 */
@Slf4j
@Service
public class WorkTypeServiceImpl implements WorkTypeService {


    @Autowired
    private WorkTypeMapper workTypeMapper;
    @Override
    public List<WorkType> getAll() {
        log.info("WorkTypeServiceImpl[]getAll[]");
        List<WorkType> workTypes = workTypeMapper.getAll();
        if (CollectionUtils.isEmpty(workTypes)) {
            return null;
        }
        return workTypes;
    }

    @Override
    public List<Integer> getIdByReviewer(Integer reviewer) {
        log.info("WorkTypeServiceImpl[]getIdByReviewer[]input.param.reviewer:{}" + reviewer);
        if (null == reviewer) {
            throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
        }
        List<Integer> ids = workTypeMapper.getIdByReviewer(reviewer);
        if (CollectionUtils.isEmpty(ids)) {
            return null;
        }
        return ids;
    }
}
