package com.zt.plat.module.base.dal.mysql.tmpltp;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscDatBsnPageReqVO;
import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscDatBsnDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 业务实例字段值 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface TmplInscDatBsnMapper extends BaseMapperX<TmplInscDatBsnDO> {

    default PageResult<TmplInscDatBsnDO> selectPage(TmplInscDatBsnPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TmplInscDatBsnDO>()
                .eqIfPresent(TmplInscDatBsnDO::getBsnId, reqVO.getBsnId())
                .eqIfPresent(TmplInscDatBsnDO::getInscFldId, reqVO.getInscFldId())
                .eqIfPresent(TmplInscDatBsnDO::getFldVal, reqVO.getFldVal())
                .betweenIfPresent(TmplInscDatBsnDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TmplInscDatBsnDO::getId));
    }
    //物理删除
    @Delete({
            "<script>",
            "DELETE FROM bse_tmpl_insc_dat_bsn",
            "WHERE bsn_id IN",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    int physicalDeleteByBsnIds(@Param("ids") List<String> ids);
}
