package com.diagbot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diagbot.dto.RespDTO;
import com.diagbot.entity.ServiceFilter;
import com.diagbot.mapper.ServiceFilterMapper;
import com.diagbot.service.ServiceFilterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @Description: 产品服务过滤
 * @Author: ztg
 * @Date: 2018/9/18 14:39
 */
@Service
public class ServiceFilterServiceImpl extends ServiceImpl<ServiceFilterMapper, ServiceFilter> implements ServiceFilterService {

    @Autowired
    ServiceFilterMapper serviceFilterMapper;


    /**
     * 获取需要appkey和secret的服务信息
     * @return
     */
    @Override
    public RespDTO<List<ServiceFilter>> getAll() {
        List<ServiceFilter> list = serviceFilterMapper.getAll();
        return RespDTO.onSuc(list);
    }


    public RespDTO<List<String>> getPermissonUrl(String appkey, String secret) {
        List<ServiceFilter> list = serviceFilterMapper.getAll();
        List<String> service = new ArrayList<>();
        for(ServiceFilter bean : list) {
            service.add(bean.getName());
        }
        return RespDTO.onSuc(service);
    }

}
