package com.iamberry.wechat.service.agentInfo;

import com.iamberry.wechat.core.entity.agentInfo.AgentConfig;
import com.iamberry.wechat.core.entity.agentInfo.AgentTooth;
import com.iamberry.wechat.face.agentInfo.AgentInfoService;
import com.iamberry.wechat.service.mapper.AgentInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liuzhiwei on 2017/10/11.
 */
@Service
public class AgentInfoServiceImpl implements AgentInfoService {

    @Autowired
    private AgentInfoMapper agentInfoMapper;

    @Override
    public List<AgentConfig> listAgentConfig(AgentConfig config) {
        return agentInfoMapper.listAgentConfig(config);
    }

    @Override
    public Integer listAgentConfigCount(AgentConfig config) {
        int count = agentInfoMapper.listAgentConfigCount(config);
        return	count = count % config.getPage().getPageSize() == 0? count/config.getPage().getPageSize():(count/config.getPage().getPageSize())+1;
    }

    @Override
    public List<AgentTooth> listAgentTooth(AgentTooth agentTooth) {
        return agentInfoMapper.listAgentTooth(agentTooth);
    }

    @Override
    public Integer addAgentConfigList(List<AgentConfig> list) {
        return agentInfoMapper.addAgentConfigList(list);
    }

    @Override
    public Integer updateAgentConfig(AgentConfig config) {
        return agentInfoMapper.updateAgentConfig(config);
    }

    @Override
    public AgentTooth getAgentTooth(AgentTooth agentTooth) {
        return agentInfoMapper.getAgentTooth(agentTooth);
    }

    @Override
    public AgentConfig getAgentConfig(AgentConfig config) {
        return agentInfoMapper.getAgentConfig(config);
    }

    @Override
    public Integer updateAgentTooth(AgentTooth agentTooth) {
        return agentInfoMapper.updateAgentTooth(agentTooth);
    }

    @Override
    public Integer updateAgentOpenId(AgentTooth agentTooth) {
        return agentInfoMapper.updateAgentOpenId(agentTooth);
    }

    @Override
    public List<AgentTooth> selectAllAgentinfo(AgentTooth agentTooth) {
        return agentInfoMapper.selectAllAgentinfo(agentTooth);
    }

    @Override
    public Integer selectAllAgentinfoCount(AgentTooth agentTooth) {
        int count = agentInfoMapper.selectAllAgentinfoCount(agentTooth);
        return	count = count % agentTooth.getPage().getPageSize() == 0? count/agentTooth.getPage().getPageSize():(count/agentTooth.getPage().getPageSize())+1;
    }

    @Override
    public Integer addAgentinfo(AgentTooth agentTooth) {
        return agentInfoMapper.addAgentinfo(agentTooth);
    }
}
