package cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.mapper;

import static cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.mapper.WvpProxyDockingDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;

import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
import jakarta.annotation.Generated;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonDeleteMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface WvpProxyDockingMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<WvpProxyDocking>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    BasicColumn[] selectList = BasicColumn.columnList(id, gbDeviceId, ip, port);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="WvpProxyDockingResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="gb_device_id", property="gbDeviceId", jdbcType=JdbcType.VARCHAR),
        @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR),
        @Result(column="port", property="port", jdbcType=JdbcType.VARCHAR)
    })
    List<WvpProxyDocking> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("WvpProxyDockingResult")
    Optional<WvpProxyDocking> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, wvpProxyDocking, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, wvpProxyDocking, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int insert(WvpProxyDocking row) {
        return MyBatis3Utils.insert(this::insert, row, wvpProxyDocking, c ->
            c.map(id).toProperty("id")
            .map(gbDeviceId).toProperty("gbDeviceId")
            .map(ip).toProperty("ip")
            .map(port).toProperty("port")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int insertMultiple(Collection<WvpProxyDocking> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, wvpProxyDocking, c ->
            c.map(id).toProperty("id")
            .map(gbDeviceId).toProperty("gbDeviceId")
            .map(ip).toProperty("ip")
            .map(port).toProperty("port")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int insertSelective(WvpProxyDocking row) {
        return MyBatis3Utils.insert(this::insert, row, wvpProxyDocking, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(gbDeviceId).toPropertyWhenPresent("gbDeviceId", row::getGbDeviceId)
            .map(ip).toPropertyWhenPresent("ip", row::getIp)
            .map(port).toPropertyWhenPresent("port", row::getPort)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default Optional<WvpProxyDocking> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, wvpProxyDocking, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default List<WvpProxyDocking> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, wvpProxyDocking, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default List<WvpProxyDocking> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, wvpProxyDocking, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default Optional<WvpProxyDocking> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, wvpProxyDocking, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    static UpdateDSL<UpdateModel> updateAllColumns(WvpProxyDocking row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(gbDeviceId).equalTo(row::getGbDeviceId)
                .set(ip).equalTo(row::getIp)
                .set(port).equalTo(row::getPort);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(WvpProxyDocking row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId)
                .set(ip).equalToWhenPresent(row::getIp)
                .set(port).equalToWhenPresent(row::getPort);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int updateByPrimaryKey(WvpProxyDocking row) {
        return update(c ->
            c.set(gbDeviceId).equalTo(row::getGbDeviceId)
            .set(ip).equalTo(row::getIp)
            .set(port).equalTo(row::getPort)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_docking")
    default int updateByPrimaryKeySelective(WvpProxyDocking row) {
        return update(c ->
            c.set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId)
            .set(ip).equalToWhenPresent(row::getIp)
            .set(port).equalToWhenPresent(row::getPort)
            .where(id, isEqualTo(row::getId))
        );
    }
}