package cn.superdesk.uniorder.service.organisation.impl;

import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.organisation.SysCliqueXInvoice;
import cn.superdesk.uniorder.dao.entity.organisation.SysCliqueXInvoiceExample;
import cn.superdesk.uniorder.dao.mapper.organisation.SysCliqueXInvoiceMapper;
import cn.superdesk.uniorder.service.organisation.SysCliqueXInvoiceService;
import com.github.pagehelper.PageHelper;
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;

/**
 * @Description:
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-05-13 19:10:28
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-05-13 19:10:28
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Service
public class SysCliqueXInvoiceServiceImpl implements SysCliqueXInvoiceService {

    @Autowired
    private SysCliqueXInvoiceMapper sysCliqueXInvoiceMapper;


    /****************************************** extends BaseService 部分 start ******************************************/

    @Override
    public int insertSelective(SysCliqueXInvoice entity) {
        return sysCliqueXInvoiceMapper.insertSelective(entity);
    }

    @Override
    public int updateByPrimaryKeySelective(SysCliqueXInvoice entity) {
        return sysCliqueXInvoiceMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public void deleteObj(Long id) {
    }

    @Override
    public SysCliqueXInvoice findById(Long id) {
        return sysCliqueXInvoiceMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<SysCliqueXInvoice> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {
        return null;
    }

    @Override
    public List<SysCliqueXInvoice> findAll(Map<String, Object> queryMap) {
        return null;
    }

    /****************************************** extends BaseService 部分   end ******************************************/


    public void addSysCliqueXInvoice(SysCliqueXInvoice entity) {
        sysCliqueXInvoiceMapper.insertSelective(entity);
    }

    public void updateSysCliqueXInvoice(SysCliqueXInvoice entity) {
        SysCliqueXInvoice originEntity = sysCliqueXInvoiceMapper.selectByPrimaryKey(entity.getId());
//		AssertUtil.notNull(originEntity);
        AnBeanUtils.copy(entity, originEntity);
        sysCliqueXInvoiceMapper.updateByPrimaryKey(originEntity);
    }

    public void deleteSysCliqueXInvoice(Long id) {
        sysCliqueXInvoiceMapper.deleteByPrimaryKey(id);
    }

    public SysCliqueXInvoice findSysCliqueXInvoiceById(Long id) {
        SysCliqueXInvoice entity = sysCliqueXInvoiceMapper.selectByPrimaryKey(id);
//		AssertUtil.notNull(entity);
        return entity;
    }

    public R<List<SysCliqueXInvoice>> pageQuery(Map<String, Object> conditions, int pageNun, int pageSize) {

        // 样例 保留
//		SysCliqueXInvoice sysCliqueXInvoiceConditions = BeanUtils.mapToBean(conditions,SysCliqueXInvoice.class);

        SysCliqueXInvoiceExample          example  = new SysCliqueXInvoiceExample();
        SysCliqueXInvoiceExample.Criteria criteria = example.createCriteria();

        PageHelper.startPage(pageNun, pageSize);
        List<SysCliqueXInvoice>     resultList = sysCliqueXInvoiceMapper.selectByExample(example);
        PageInfo<SysCliqueXInvoice> page       = new PageInfo<SysCliqueXInvoice>(resultList);
        PageHelper.clearPage();

        return new R<List<SysCliqueXInvoice>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), resultList);

    }

}