package com.skr.mdm.api.common.service.impl;

import com.skr.mdm.api.common.service.MdmEquipmentService;
import com.skr.mdm.bean.qo.BaseDaoQO;
import com.skr.mdm.bean.qo.EquipmentIssuedQO;
import com.skr.mdm.dao.DeviceEquipmentDao;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author nfq
 * @date 2022-07-18 18:09
 */
@Service
public class MdmEquipmentServiceImpl implements MdmEquipmentService {

    @Autowired
    private DeviceEquipmentDao equipmentDao;

    @Override
    public ResponseResult listEquipmentIssuedVO(EquipmentIssuedQO equipmentIssuedQO, LoginAdminDTO loginAdminDTO) {
        if (equipmentIssuedQO.getQueryType().equals(1) || CollectionUtils.isNotEmpty(equipmentIssuedQO.getCandidateIdList())) {
            BaseDaoQO baseDaoQO = BaseDaoQO.builder()
                    .adminId(loginAdminDTO.getId())
                    .departmentIdList(equipmentIssuedQO.getCandidateIdList())
                    .deviceModel(equipmentIssuedQO.getDeviceModel())
                    .searchType(equipmentIssuedQO.getSearchType())
                    .searchValue(equipmentIssuedQO.getSearchValue())
                    .build();
            return ResponseResult.success(equipmentDao.listEquipmentIssuedVO(baseDaoQO));
        }
        if (equipmentIssuedQO.getQueryType().equals(2) && CollectionUtils.isNotEmpty(equipmentIssuedQO.getCandidateIdList())) {
            return ResponseResult.success();
        }
        return ResponseResult.success();
    }
}