package com.diaoyun.zion.chinafrica.service.impl;

import com.diaoyun.zion.chinafrica.dao.TbCfStoreDao;
import com.diaoyun.zion.chinafrica.entity.TbCfPlatformEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity;
import com.diaoyun.zion.chinafrica.service.TbCfStoreService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.util.IdUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

import static com.github.pagehelper.page.PageMethod.startPage;

/**
 * 店铺管理Service实现类
 *
 * @author lipengjun
 * @date 2019-09-05 16:51:07
 */
@Service("tbCfStoreService")
public class TbCfStoreServiceImpl implements TbCfStoreService {
    @Autowired
    private TbCfStoreDao tbCfStoreDao;

    @Override
    public TbCfStoreEntity queryObject(String storeId) {
        return tbCfStoreDao.queryObject(storeId);
    }

    @Override
    public List<TbCfStoreEntity> queryList(Map<String, Object> map) {
        return tbCfStoreDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return tbCfStoreDao.queryTotal(map);
    }

    @Override
    public int save(TbCfStoreEntity tbCfStore) {
        tbCfStore.setStoreId(IdUtil.createIdbyUUID());
        return tbCfStoreDao.save(tbCfStore);
    }

    @Override
    public int update(TbCfStoreEntity tbCfStore) {
        return tbCfStoreDao.update(tbCfStore);
    }

    @Override
    public int delete(String storeId) {
        return tbCfStoreDao.delete(storeId);
    }

    @Override
    public int deleteBatch(String[] storeIds) {
        return tbCfStoreDao.deleteBatch(storeIds);
    }

    @Override
    public Result getStoreStationList(Integer pageNum, Integer pageSize) {
        Result<PageInfo> result = new Result<>();
        startPage(pageNum,pageSize);
        List<TbCfStoreEntity> tbCfStoreList=tbCfStoreDao.getStoreStationList();
        PageInfo<TbCfStoreEntity> pageInfo = new PageInfo<>(tbCfStoreList);
        result.setData(pageInfo);
        return result;
    }
}
