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.SYXBJRepository;
import com.ibiz.core.repository.po.SYXBJ;
import com.ibiz.core.external.filter.SYXBJSearchContext;
import com.ibiz.mybatis.external.mapper.T_SYXBJMapper;
import com.ibiz.mybatis.external.po.T_SYXBJImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ibiz.mybatis.util.helper.QueryBuilder;


/**
 * 关系型数据实体表[T_SYXBJ] 存储对象
 */
@Repository
@ConditionalOnProperty(prefix = "syxbj", value="store" , havingValue = "sql", matchIfMissing = true)
public class T_SYXBJRepositoryImpl extends ServiceImpl<T_SYXBJMapper, T_SYXBJImpl> implements SYXBJRepository {

    @Autowired
    QueryBuilder queryBuilder;

    private boolean isLogicValid = false ;

    @Autowired
	T_SYXBJMapper t_SYXBJMapper;

    public SYXBJ createPO(){
        return new T_SYXBJImpl();
    }

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


    public boolean create(SYXBJ po){
        return this.save((T_SYXBJImpl)po);
    }

    public boolean update(SYXBJ po){
        return this.updateById((T_SYXBJImpl)po);
    }

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

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


    public com.ibiz.core.external.domain.SYXBJ convert2Domain( SYXBJ po ,com.ibiz.core.external.domain.SYXBJ domain){
              if(po == null)
                     return domain ;
              if(domain == null){
                     domain = new com.ibiz.core.external.domain.SYXBJ();
              }
            //if(po.getSYXBJNameDirtyFlag())
                domain.setSYXBJName(po.getSYXBJName());
            //if(po.getFlDirtyFlag())
                domain.setFl(po.getFl());
            //if(po.getUpdateManDirtyFlag())
                domain.setUpdateMan(po.getUpdateMan());
            //if(po.getPtfhxsDirtyFlag())
                domain.setPtfhxs(po.getPtfhxs());
            //if(po.getCreateDateDirtyFlag())
                domain.setCreateDate(po.getCreateDate());
            //if(po.getUpdateDateDirtyFlag())
                domain.setUpdateDate(po.getUpdateDate());
            //if(po.getJzbfDirtyFlag())
                domain.setJzbf(po.getJzbf());
            //if(po.getCreateManDirtyFlag())
                domain.setCreateMan(po.getCreateMan());
            //if(po.getTkmcDirtyFlag())
                domain.setTkmc(po.getTkmc());
            //if(po.getMdDirtyFlag())
                domain.setMd(po.getMd());
            //if(po.getTkdmDirtyFlag())
                domain.setTkdm(po.getTkdm());
            //if(po.getSjbfDirtyFlag())
                domain.setSjbf(po.getSjbf());
            //if(po.getSYXBJIdDirtyFlag())
                domain.setSYXBJId(po.getSYXBJId());
              return domain ;
    }

    public SYXBJ convert2PO(com.ibiz.core.external.domain.SYXBJ domain , SYXBJ po){
        if(domain == null)
            return po ;
        if(po==null){
            po = createPO() ;
        }
        if(domain.getSYXBJNameDirtyFlag())
            po.setSYXBJName(domain.getSYXBJName());
        if(domain.getFlDirtyFlag())
            po.setFl(domain.getFl());
        if(domain.getUpdateManDirtyFlag())
            po.setUpdateMan(domain.getUpdateMan());
        if(domain.getPtfhxsDirtyFlag())
            po.setPtfhxs(domain.getPtfhxs());
        if(domain.getCreateDateDirtyFlag())
            po.setCreateDate(domain.getCreateDate());
        if(domain.getUpdateDateDirtyFlag())
            po.setUpdateDate(domain.getUpdateDate());
        if(domain.getJzbfDirtyFlag())
            po.setJzbf(domain.getJzbf());
        if(domain.getCreateManDirtyFlag())
            po.setCreateMan(domain.getCreateMan());
        if(domain.getTkmcDirtyFlag())
            po.setTkmc(domain.getTkmc());
        if(domain.getMdDirtyFlag())
            po.setMd(domain.getMd());
        if(domain.getTkdmDirtyFlag())
            po.setTkdm(domain.getTkdm());
        if(domain.getSjbfDirtyFlag())
            po.setSjbf(domain.getSjbf());
        if(domain.getSYXBJIdDirtyFlag())
            po.setSYXBJId(domain.getSYXBJId());

        return po ;
    }
}
