package com.iamberry.wechat.service.channel;

import com.github.pagehelper.PageHelper;
import com.iamberry.wechat.core.entity.channel.ChannelAdmin;
import com.iamberry.wechat.core.entity.order.Order;
import com.iamberry.wechat.core.entity.page.PageRequest;
import com.iamberry.wechat.core.entity.page.PagedResult;
import com.iamberry.wechat.face.channel.ChannelAdminService;
import com.iamberry.wechat.service.mapper.ChannelAdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import util.PageUtil;

import java.util.List;

/**
 *  渠道管理员接口
 * @author xm
 * @Date 2018-08-02
 */
@Service
public class ChannelAdminServiceImpl  implements ChannelAdminService {
    @Autowired
    private ChannelAdminMapper channelAdminMapper;
    /**
     * 获取集合
     * @param  channelAdmin
     * @return List
     */
    @Override
    public List<ChannelAdmin> getChannelAdminList(ChannelAdmin  channelAdmin){
        return  channelAdminMapper.getChannelAdminList(channelAdmin);
    }

    @Override
    public PagedResult<Order> listOrderPage(PageRequest<Order> pageRequest) {
        PageHelper.startPage(pageRequest.getPageNO(), pageRequest.getPageSize(), pageRequest.isPageTotal());
        List<Order> detedctList = channelAdminMapper.listOrderPage(pageRequest.getData());
         return PageUtil.getPage(detedctList);
    }

    /**
     * 查询单条数据
     * @param  id
     * @return  channelAdmin
     */
    @Override
    public  ChannelAdmin  getChannelAdminById(Integer  id){
        return  channelAdminMapper.getChannelAdminById(id);
    }

    @Override
    public Integer listOrderCount(Order order) {
        return  channelAdminMapper.listOrderCount(order);
    }

    /**
     * 增加数据
     * @param  channelAdmin
     * @return Integer
     */
    @Override
    public  Integer  save(ChannelAdmin  channelAdmin){
        return  channelAdminMapper.save(channelAdmin);
    }
    /**
     * 修改数据
     * @param  channelAdmin
     * @return Integer
     */
    @Override
    public  Integer  update(ChannelAdmin  channelAdmin){
        return  channelAdminMapper.update(channelAdmin);
    }
    /**
     * 删除数据
     * @param  id
     * @return Integer
     */
    @Override
    public  Integer  delete(Integer  id){
        return  channelAdminMapper.delete(id);
    }
    /**
     * 增加数据 <集合>
     * @param  channelAdminList
     * @return Integer
     */
    @Override
    public  Integer  saveList(List<ChannelAdmin>  channelAdminList){
        return  channelAdminMapper.saveList(channelAdminList);
    }
    /**
     * 删除数据 <集合>
     * @param  ids
     * @return Integer
     */
    @Override
    public  Integer  deleteList(Integer[]  ids){
        return  channelAdminMapper.deleteList(ids);
    }
}