package cn.superdesk.uniorder.service.invoice.customer.invoiced.impl;


import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.invoice.customer.invoiced.InvoiceInvoicedBackCollectionOperationLog;
import cn.superdesk.uniorder.dao.entity.invoice.customer.invoiced.InvoiceInvoicedBackCollectionOperationLogExample;
import cn.superdesk.uniorder.dao.mapper.invoice.customer.invoiced.InvoiceInvoicedBackCollectionOperationLogMapper;
import cn.superdesk.uniorder.dto.param.invoice.customer.invoiced.InvoiceInvoicedBackCollectionOperationLogQueryCriteria;
import cn.superdesk.uniorder.service.invoice.customer.invoiced.InvoiceInvoicedBackCollectionOperationLogService;
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-07-28 15:28:43
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-07-28 15:28:43
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Service
public class InvoiceInvoicedBackCollectionOperationLogServiceImpl implements InvoiceInvoicedBackCollectionOperationLogService {

    @Autowired
    private InvoiceInvoicedBackCollectionOperationLogMapper invoiceInvoicedBackCollectionOperationLogMapper;


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

    @Override
    public int insertSelective(InvoiceInvoicedBackCollectionOperationLog entity) {
        return invoiceInvoicedBackCollectionOperationLogMapper.insertSelective(entity);
    }

    @Override
    public int updateByPrimaryKeySelective(InvoiceInvoicedBackCollectionOperationLog entity) {
        return invoiceInvoicedBackCollectionOperationLogMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public void deleteObj(Long id) {
    }

    @Override
    public InvoiceInvoicedBackCollectionOperationLog findById(Long id) {
        return invoiceInvoicedBackCollectionOperationLogMapper.selectByPrimaryKey(id);
    }

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

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

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


    public void addInvoiceInvoicedBackCollectionOperationLog(InvoiceInvoicedBackCollectionOperationLog entity) {
        invoiceInvoicedBackCollectionOperationLogMapper.insertSelective(entity);
    }

    public void updateInvoiceInvoicedBackCollectionOperationLog(InvoiceInvoicedBackCollectionOperationLog entity) {
        InvoiceInvoicedBackCollectionOperationLog originEntity = invoiceInvoicedBackCollectionOperationLogMapper.selectByPrimaryKey(entity.getId());
//		AssertUtil.notNull(originEntity);
        AnBeanUtils.copy(entity, originEntity);
        invoiceInvoicedBackCollectionOperationLogMapper.updateByPrimaryKey(originEntity);
    }

    public void deleteInvoiceInvoicedBackCollectionOperationLog(Long id) {
        invoiceInvoicedBackCollectionOperationLogMapper.deleteByPrimaryKey(id);
    }

    public InvoiceInvoicedBackCollectionOperationLog findInvoiceInvoicedBackCollectionOperationLogById(Long id) {
        InvoiceInvoicedBackCollectionOperationLog entity = invoiceInvoicedBackCollectionOperationLogMapper.selectByPrimaryKey(id);
//		AssertUtil.notNull(entity);
        return entity;
    }

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


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


        // 样例 保留
//		InvoiceInvoicedBackCollectionOperationLog invoiceInvoicedBackCollectionOperationLogConditions = BeanUtils.mapToBean(conditions,InvoiceInvoicedBackCollectionOperationLog.class);


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

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

    }

    public R<List<InvoiceInvoicedBackCollectionOperationLog>> pageQueryGenericParam(InvoiceInvoicedBackCollectionOperationLogQueryCriteria queryCriteria) {

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

        if (null != queryCriteria && null != queryCriteria.getInvoiceInvoicedId()) {
            criteria.andInvoiceInvoicedIdEqualTo(queryCriteria.getInvoiceInvoicedId());
        }

        if (null != queryCriteria && null != queryCriteria.getInvoiceNumber()) {
            criteria.andInvoiceNumberEqualTo(queryCriteria.getInvoiceNumber());
        }

        example.setOrderByClause("create_time DESC");

        PageHelper.startPage(queryCriteria.getPageNumber(), queryCriteria.getPageSize());
        List<InvoiceInvoicedBackCollectionOperationLog>     resultList = invoiceInvoicedBackCollectionOperationLogMapper.selectByExample(example);
        PageInfo<InvoiceInvoicedBackCollectionOperationLog> page       = new PageInfo<InvoiceInvoicedBackCollectionOperationLog>(resultList);
        PageHelper.clearPage();

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

    }


}
