package cn.superdesk.uniorder.service.marketing.department.impl;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.marketing.department.UnifiedArea;
import cn.superdesk.uniorder.dao.entity.marketing.department.UnifiedAreaCity;
import cn.superdesk.uniorder.dao.mapper.marketing.department.UnifiedAreaCityMapper;
import cn.superdesk.uniorder.dao.mapper.marketing.department.UnifiedAreaCityMapperEx;
import cn.superdesk.uniorder.dao.mapper.marketing.department.UnifiedAreaMapper;
import cn.superdesk.uniorder.dao.mapper.marketing.department.UnifiedAreaMapperEx;
import cn.superdesk.uniorder.dto.vo._function.select.SelectOptionCity;
import cn.superdesk.uniorder.dto.vo.marketing.department.UnifiedAreaVo;
import cn.superdesk.uniorder.dto.vo.marketing.department.UnifiedAreaWeb;
import cn.superdesk.uniorder.service.marketing.department.UnifiedAreaService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;

@Service
public class UnifiedAreaServiceImpl implements UnifiedAreaService {


    @Autowired
    private UnifiedAreaMapper   unifiedAreaMapper;
    @Autowired
    private UnifiedAreaMapperEx unifiedAreaMapperEx;

    @Autowired
    private UnifiedAreaCityMapper   unifiedAreaCityMapper;
    @Autowired
    private UnifiedAreaCityMapperEx unifiedAreaCityMapperEx;

    @Override
    public PageInfo<UnifiedArea> findByPaging(Map<String, Object> params, Integer pageNo, Integer pageSize) {

        return null;
    }

    @Transactional
    @Override
    public void deleteObj(Long id) {

        unifiedAreaMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(UnifiedArea t) {

        return unifiedAreaMapper.updateByPrimaryKeySelective(t);
    }

    @Override
    public UnifiedArea findById(Long id) {

        return unifiedAreaMapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertSelective(UnifiedArea t) {

        return unifiedAreaMapper.insertSelective(t);
    }

    @Override
    public List<UnifiedArea> findAll(Map<String, Object> queryMap) {

        return unifiedAreaMapperEx.findAll(queryMap);
    }

    @Override
    public R<List<UnifiedAreaVo>> getDataByPage(Map<String, Object> params, int pageNo, int pageSize) {

        PageHelper.startPage(pageNo, pageSize);

        List<UnifiedAreaVo> ls = unifiedAreaMapperEx.getData(params);

        PageInfo<UnifiedAreaVo> page = new PageInfo<UnifiedAreaVo>(ls);
        PageHelper.clearPage();
        return new R<List<UnifiedAreaVo>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), ls);

    }

    @Override
    public List<SelectOptionCity> getCitySelect(Map<String, Object> params) {

        return unifiedAreaMapperEx.getCitySelect(params);
    }


    @Override
    public List<UnifiedAreaCity> findAllCity(Map<String, Object> queryMap) {

        return unifiedAreaCityMapperEx.findAll(queryMap);
    }

    @Override
    public List<UnifiedAreaWeb> getweb(Map<String, Object> params) {

        return unifiedAreaMapperEx.getWebData(params);
    }

}
