package com.bonus.canteen.core.drp.service;

import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.drp.constant.DrpSupplierStatusEnum;
import com.bonus.canteen.core.drp.dto.AndroidSearchMaterialDTO;
import com.bonus.canteen.core.drp.mapper.DrpInventoryMapper;
import com.bonus.canteen.core.drp.mapper.DrpSupplierMapper;
import com.bonus.canteen.core.drp.vo.AndroidSearchMaterialVO;
import com.bonus.canteen.core.drp.vo.DrpListSupplierVO;
import com.bonus.common.houqin.constant.DelFlagEnum;
import lombok.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class AndroidInventoryService {
   @Generated
   private static final Logger log = LoggerFactory.getLogger(AndroidInventoryService.class);

   @Autowired
   @Lazy
   private DrpInventoryMapper drpInventoryMapper;
   @Autowired
   @Lazy
   private DrpSupplierMapper drpSupplierMapper;

   public List<AndroidSearchMaterialVO> searchMaterial(AndroidSearchMaterialDTO content) {
      String materialName = ObjectUtil.isNull(content.getMaterialName()) ? "" : content.getMaterialName();
      return this.drpInventoryMapper.selectAndroidMaterialList(content, materialName.toUpperCase(), materialName.toLowerCase(), DelFlagEnum.DEL_FALSE.key());
   }

   public List<DrpListSupplierVO> androidListSupplier(Long areaId) {
      return this.drpSupplierMapper.selectSupplierListAndroid(DrpSupplierStatusEnum.NORMAL.key(), areaId, DelFlagEnum.DEL_FALSE.key());
   }

}
