package com.zjrs.zwnw.sxgl.blo.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.mohrss.leaf.core.framework.domain.blo.impl.BLOImpl;
import com.zjrs.zwnw.sxgl.blo.DictBLO;
import com.zjrs.zwnw.sxgl.dto.CllbDTO;
import com.zjrs.zwnw.sxgl.dto.DictDTO;
import com.zjrs.zwnw.sxgl.entity.DictMapper;
import com.zjrs.zwnw.sxgl.entity.SxpzxxMapper;
import com.zjrs.zwnw.sxgl.po.Aa10PO;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DictBLOimpl extends BLOImpl implements DictBLO {
    @Resource
    DictMapper dictMapper;
    @Resource
    SxpzxxMapper sxpzxxMapper;

    @Override
    public Map<String, List> getDicts(DictDTO dto) {

        String[] arr = dto.getDictArr();
        Map<String, List> dictMap = new HashMap<>();

        for (int i = 0; i < arr.length; i++) {
            List keyList = new ArrayList();
            QueryWrapper<Aa10PO> queryWrapper = new QueryWrapper<Aa10PO>();
            List<Aa10PO> itemList = dictMapper.selectList(queryWrapper);
            for (int j = 0; j < itemList.size(); j++) {
                Map<String, Object> keyVlueMap = new HashMap<>();
                Aa10PO aa10Po = itemList.get(j);
                keyVlueMap.put("code", aa10Po.getAaa102());
                keyVlueMap.put("detail", aa10Po.getAaa103());
                keyList.add(keyVlueMap);
            }
            dictMap.put(arr[i], keyList);
        }
        return dictMap;
    }

    @Override
    public List<CllbDTO> getCllb(String ssbmmc) {
        List<CllbDTO> cllbList = dictMapper.getCllb(ssbmmc);
        CllbDTO cllbDTO = new CllbDTO();
        cllbDTO.setCode("0");
        cllbList.add(0, cllbDTO);
        return cllbList;
    }

    @Override
    public List<CllbDTO> getOpers(String ssbmmc) {
        List<CllbDTO> cllbList = dictMapper.getOpers(ssbmmc);
        CllbDTO cllbDTO = new CllbDTO();
        return cllbList;
    }
}
