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

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

import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
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 WvpProxyDeviceMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<WvpProxyDevice>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    BasicColumn[] selectList = BasicColumn.columnList(id, deviceCode, gbDeviceId, gbDeviceChannelId, name, address);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="WvpProxyDeviceResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="device_code", property="deviceCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="gb_device_id", property="gbDeviceId", jdbcType=JdbcType.VARCHAR),
        @Result(column="gb_device_channel_id", property="gbDeviceChannelId", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR)
    })
    List<WvpProxyDevice> selectMany(SelectStatementProvider selectStatement);

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    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_device")
    default int insert(WvpProxyDevice row) {
        return MyBatis3Utils.insert(this::insert, row, wvpProxyDevice, c ->
            c.map(id).toProperty("id")
            .map(deviceCode).toProperty("deviceCode")
            .map(gbDeviceId).toProperty("gbDeviceId")
            .map(gbDeviceChannelId).toProperty("gbDeviceChannelId")
            .map(name).toProperty("name")
            .map(address).toProperty("address")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    default int insertMultiple(Collection<WvpProxyDevice> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, wvpProxyDevice, c ->
            c.map(id).toProperty("id")
            .map(deviceCode).toProperty("deviceCode")
            .map(gbDeviceId).toProperty("gbDeviceId")
            .map(gbDeviceChannelId).toProperty("gbDeviceChannelId")
            .map(name).toProperty("name")
            .map(address).toProperty("address")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    default int insertSelective(WvpProxyDevice row) {
        return MyBatis3Utils.insert(this::insert, row, wvpProxyDevice, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(deviceCode).toPropertyWhenPresent("deviceCode", row::getDeviceCode)
            .map(gbDeviceId).toPropertyWhenPresent("gbDeviceId", row::getGbDeviceId)
            .map(gbDeviceChannelId).toPropertyWhenPresent("gbDeviceChannelId", row::getGbDeviceChannelId)
            .map(name).toPropertyWhenPresent("name", row::getName)
            .map(address).toPropertyWhenPresent("address", row::getAddress)
        );
    }

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    static UpdateDSL<UpdateModel> updateAllColumns(WvpProxyDevice row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(deviceCode).equalTo(row::getDeviceCode)
                .set(gbDeviceId).equalTo(row::getGbDeviceId)
                .set(gbDeviceChannelId).equalTo(row::getGbDeviceChannelId)
                .set(name).equalTo(row::getName)
                .set(address).equalTo(row::getAddress);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(WvpProxyDevice row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(deviceCode).equalToWhenPresent(row::getDeviceCode)
                .set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId)
                .set(gbDeviceChannelId).equalToWhenPresent(row::getGbDeviceChannelId)
                .set(name).equalToWhenPresent(row::getName)
                .set(address).equalToWhenPresent(row::getAddress);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    default int updateByPrimaryKey(WvpProxyDevice row) {
        return update(c ->
            c.set(deviceCode).equalTo(row::getDeviceCode)
            .set(gbDeviceId).equalTo(row::getGbDeviceId)
            .set(gbDeviceChannelId).equalTo(row::getGbDeviceChannelId)
            .set(name).equalTo(row::getName)
            .set(address).equalTo(row::getAddress)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
    default int updateByPrimaryKeySelective(WvpProxyDevice row) {
        return update(c ->
            c.set(deviceCode).equalToWhenPresent(row::getDeviceCode)
            .set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId)
            .set(gbDeviceChannelId).equalToWhenPresent(row::getGbDeviceChannelId)
            .set(name).equalToWhenPresent(row::getName)
            .set(address).equalToWhenPresent(row::getAddress)
            .where(id, isEqualTo(row::getId))
        );
    }
}