package com.ibiz.mybatis.external;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;

import com.ibiz.core.repository.CPXHRepository;
import com.ibiz.core.repository.po.CPXH;
import com.ibiz.core.external.filter.CPXHSearchContext;
import com.ibiz.mybatis.external.mapper.T_CPXHMapper;
import com.ibiz.mybatis.external.po.T_CPXHImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ibiz.mybatis.util.helper.QueryBuilder;


/**
 * 关系型数据实体表[T_CPXH] 存储对象
 */
@Repository
@ConditionalOnProperty(prefix = "cpxh", value="store" , havingValue = "sql", matchIfMissing = true)
public class T_CPXHRepositoryImpl extends ServiceImpl<T_CPXHMapper, T_CPXHImpl> implements CPXHRepository {

    @Autowired
    QueryBuilder queryBuilder;

    private boolean isLogicValid = false ;

    @Autowired
	T_CPXHMapper t_CPXHMapper;

    public CPXH createPO(){
        return new T_CPXHImpl();
    }

    public CPXH get(String key){
        return this.getById(key);
    }


    public boolean create(CPXH po){
        return this.save((T_CPXHImpl)po);
    }

    public boolean update(CPXH po){
        return this.updateById((T_CPXHImpl)po);
    }

    public boolean remove(String key){
        return this.removeById(key);
    }

    public Page<CPXH> searchDefault(CPXHSearchContext context){
        QueryWrapper qw=queryBuilder.buildQueryWrapper(context);
        com.baomidou.mybatisplus.extension.plugins.pagination.Page page=queryBuilder.buildPage(context);
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<CPXH> page_datas=t_CPXHMapper.searchDefault(page,context,qw);
        List<CPXH> list_datas=queryBuilder.page2List(page_datas);
        return new PageImpl<CPXH>(list_datas, context.getPageable(), page_datas.getTotal());
    }


    public com.ibiz.core.external.domain.CPXH convert2Domain( CPXH po ,com.ibiz.core.external.domain.CPXH domain){
              if(po == null)
                     return domain ;
              if(domain == null){
                     domain = new com.ibiz.core.external.domain.CPXH();
              }
            //if(po.getGlDirtyFlag())
                domain.setGl(po.getGl());
            //if(po.getBmDirtyFlag())
                domain.setBm(po.getBm());
            //if(po.getHpdsDirtyFlag())
                domain.setHpds(po.getHpds());
            //if(po.getBzDirtyFlag())
                domain.setBz(po.getBz());
            //if(po.getCPXHNameDirtyFlag())
                domain.setCPXHName(po.getCPXHName());
            //if(po.getXcgzjDirtyFlag())
                domain.setXcgzj(po.getXcgzj());
            //if(po.getSsnfDirtyFlag())
                domain.setSsnf(po.getSsnf());
            //if(po.getHdzzlDirtyFlag())
                domain.setHdzzl(po.getHdzzl());
            //if(po.getCreateDateDirtyFlag())
                domain.setCreateDate(po.getCreateDate());
            //if(po.getAblDirtyFlag())
                domain.setAbl(po.getAbl());
            //if(po.getCllxmsDirtyFlag())
                domain.setCllxms(po.getCllxms());
            //if(po.getHdzkDirtyFlag())
                domain.setHdzk(po.getHdzk());
            //if(po.getZbzlDirtyFlag())
                domain.setZbzl(po.getZbzl());
            //if(po.getUpdateDateDirtyFlag())
                domain.setUpdateDate(po.getUpdateDate());
            //if(po.getPpDirtyFlag())
                domain.setPp(po.getPp());
            //if(po.getDycpxhDirtyFlag())
                domain.setDycpxh(po.getDycpxh());
            //if(po.getCreateManDirtyFlag())
                domain.setCreateMan(po.getCreateMan());
            //if(po.getCxdmDirtyFlag())
                domain.setCxdm(po.getCxdm());
            //if(po.getPlDirtyFlag())
                domain.setPl(po.getPl());
            //if(po.getCPXHIdDirtyFlag())
                domain.setCPXHId(po.getCPXHId());
            //if(po.getSccsDirtyFlag())
                domain.setSccs(po.getSccs());
            //if(po.getClsjjzDirtyFlag())
                domain.setClsjjz(po.getClsjjz());
            //if(po.getUpdateManDirtyFlag())
                domain.setUpdateMan(po.getUpdateMan());
            //if(po.getCxDirtyFlag())
                domain.setCx(po.getCx());
              return domain ;
    }

    public CPXH convert2PO(com.ibiz.core.external.domain.CPXH domain , CPXH po){
        if(domain == null)
            return po ;
        if(po==null){
            po = createPO() ;
        }
        if(domain.getGlDirtyFlag())
            po.setGl(domain.getGl());
        if(domain.getBmDirtyFlag())
            po.setBm(domain.getBm());
        if(domain.getHpdsDirtyFlag())
            po.setHpds(domain.getHpds());
        if(domain.getBzDirtyFlag())
            po.setBz(domain.getBz());
        if(domain.getCPXHNameDirtyFlag())
            po.setCPXHName(domain.getCPXHName());
        if(domain.getXcgzjDirtyFlag())
            po.setXcgzj(domain.getXcgzj());
        if(domain.getSsnfDirtyFlag())
            po.setSsnf(domain.getSsnf());
        if(domain.getHdzzlDirtyFlag())
            po.setHdzzl(domain.getHdzzl());
        if(domain.getCreateDateDirtyFlag())
            po.setCreateDate(domain.getCreateDate());
        if(domain.getAblDirtyFlag())
            po.setAbl(domain.getAbl());
        if(domain.getCllxmsDirtyFlag())
            po.setCllxms(domain.getCllxms());
        if(domain.getHdzkDirtyFlag())
            po.setHdzk(domain.getHdzk());
        if(domain.getZbzlDirtyFlag())
            po.setZbzl(domain.getZbzl());
        if(domain.getUpdateDateDirtyFlag())
            po.setUpdateDate(domain.getUpdateDate());
        if(domain.getPpDirtyFlag())
            po.setPp(domain.getPp());
        if(domain.getDycpxhDirtyFlag())
            po.setDycpxh(domain.getDycpxh());
        if(domain.getCreateManDirtyFlag())
            po.setCreateMan(domain.getCreateMan());
        if(domain.getCxdmDirtyFlag())
            po.setCxdm(domain.getCxdm());
        if(domain.getPlDirtyFlag())
            po.setPl(domain.getPl());
        if(domain.getCPXHIdDirtyFlag())
            po.setCPXHId(domain.getCPXHId());
        if(domain.getSccsDirtyFlag())
            po.setSccs(domain.getSccs());
        if(domain.getClsjjzDirtyFlag())
            po.setClsjjz(domain.getClsjjz());
        if(domain.getUpdateManDirtyFlag())
            po.setUpdateMan(domain.getUpdateMan());
        if(domain.getCxDirtyFlag())
            po.setCx(domain.getCx());

        return po ;
    }
}
