/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.base.entity.Source;
import com.tofly.base.mapper.SourceMapper;
import com.tofly.base.service.SourceService;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.oauth.util.SecurityUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 系统资源配置信息表
 *
 * @author admin
 * @date Thu Oct 10 00:00:00 CST 2019
 */
@Service("sourceService")
public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> implements SourceService {
    @Autowired
    private SourceService sourceService;

    @Override
    public List<Map> getSourceByUser() {
        return baseMapper.getSourceByUser(SecurityUtils.getUserId());
    }

    @Override
    public List<Map> listSources(Long departmentId) {
        return baseMapper.listSources(departmentId);
    }

    @Override
    public ResultRespone selectAllSource() {
        List<Source> sources = sourceService.list();

        return null;

    }

    @Override
    public ResultRespone selectSourceById( Long id,String cval,String name) {
        QueryWrapper<Source> wrapperOne = new QueryWrapper<>();
        wrapperOne.eq("PID",id);
        if (cval != null){
            wrapperOne.like("CVAL",cval);
        }
        if (name != null){
            wrapperOne.like("NAME",name);
        }
        return ResultRespone.success(baseMapper.selectList(wrapperOne));
    }
}
