package com.bonus.core.nutrition.common.service;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.core.customer.api.CustCasualApi;
import com.bonus.core.nutrition.common.mapper.HealthCustMedicalReportMapper;
import com.bonus.core.nutrition.common.vo.HealthCustMedicalReportVO;
import com.bonus.i18n.I18n;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.invoke.SerializedLambda;
import java.util.Iterator;
import java.util.List;

@Service
public class HealthCustMedicalReportService {
   @Autowired
   private CustCasualApi custCasualApi;
   @Resource
   private HealthCustMedicalReportMapper healthCustMedicalReportMapper;

   public List<HealthCustMedicalReportVO> listMedicalReport(String openid, Integer sourceType) {
      Long custId = this.custCasualApi.getCustIdByOpenidAndSourceType(openid, sourceType);
      if (ObjectUtil.isEmpty(custId)) {
         throw new ServiceException(I18n.getMessage("nutrition.no-cust", new Object[0]));
      } else {
         List<HealthCustMedicalReportVO> reportVOList = this.healthCustMedicalReportMapper.listMedicalReport(custId);
         return reportVOList;
      }
   }
}
