package com.mobvista.apptag.service.impl;

import com.mobvista.apptag.entity.Feat;
import com.mobvista.apptag.mapper.FeatDao;
import com.mobvista.apptag.service.FeatService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wangjf
 */

@Service("featService")
public class FeatServiceImpl implements FeatService {

    @Autowired
    private FeatDao featDao;

    @Override
    public Map<String, String> getMap() {
        Map<String, String> map = new HashMap<>();
        List<Feat> feats = featDao.listAll();
        for (Feat feat : feats) {
            if (StringUtils.isNotBlank(feat.getSecondTag())) {
                map.put(feat.getSecondId(), feat.getSecondTag());
            } else {
                map.put(feat.getSecondId(), feat.getFirstTag());
            }
        }
        return map;
    }
}