package com.diagbot.facade;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.entity.DictionaryInfo;
import com.diagbot.enums.IsDeleteEnum;
import com.diagbot.service.impl.DictionaryInfoServiceImpl;
import com.diagbot.util.EntityUtil;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author:zhoutg
 * @time: 2018/11/23 11:37
 */
@Component
public class DictionaryFacade extends DictionaryInfoServiceImpl {

    /**
     * 返回字典信息
     *
     * @return
     */
    public Map<Long, List<DictionaryInfo>> getList() {
        Map<Long, List<DictionaryInfo>> data = new LinkedHashMap<>();
        List<DictionaryInfo> list = this.list(new QueryWrapper<DictionaryInfo>()
                .in("return_type", new Long[]{0L, 1L})
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .orderByAsc("group_type", "order_no"));
        return EntityUtil.makeEntityListMap(list, "groupType");
    }
}
