package shop.alien.store.service.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import shop.alien.entity.store.StoreImg;
import shop.alien.entity.store.vo.StoreQualificationInfoVo;
import shop.alien.mapper.StoreQualificationMapper;
import shop.alien.store.service.StoreQualificationService;

import java.util.ArrayList;
import java.util.List;

/**
 * 门店资质信息服务实现类
 *
 * @author system
 * @since 2025-01-01
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class StoreQualificationServiceImpl implements StoreQualificationService {
    
    private final StoreQualificationMapper storeQualificationMapper;
    
    @Override
    public StoreQualificationInfoVo getStoreQualificationInfo(Integer storeId) {
        log.info("StoreQualificationServiceImpl.getStoreQualificationInfo?storeId={}", storeId);
        if (storeId == null) {
            log.warn("门店ID为空");
            return new StoreQualificationInfoVo();
        }
        
        StoreQualificationInfoVo result = new StoreQualificationInfoVo();
        
        // 查询营业执照（img_type = 14）
        List<StoreImg> businessLicenseList = storeQualificationMapper.selectStoreImgsByType(storeId, 14);
        result.setBusinessLicenseList(businessLicenseList != null ? businessLicenseList : new ArrayList<>());
        
        // 查询其他资质证明图片（img_type = 35）
        List<StoreImg> otherQualificationList = storeQualificationMapper.selectStoreImgsByType(storeId, 35);
        result.setOtherQualificationList(otherQualificationList != null ? otherQualificationList : new ArrayList<>());
        
        log.info("查询门店资质信息完成 - 营业执照: {}条, 其他资质证明图片: {}条", 
                result.getBusinessLicenseList().size(), 
                result.getOtherQualificationList().size());
        
        return result;
    }
}
