package cn.skcks.matrix.v2.orm.mybatis.dynamic.mapper;

import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;

import cn.skcks.matrix.v2.orm.mybatis.dynamic.model.LocationRecord;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;

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 LocationRecordMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<LocationRecord>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    BasicColumn[] selectList = BasicColumn.columnList(LocationRecordDynamicSqlSupport.id, LocationRecordDynamicSqlSupport.callbackTime, LocationRecordDynamicSqlSupport.locationTime, LocationRecordDynamicSqlSupport.locationType, LocationRecordDynamicSqlSupport.latitude, LocationRecordDynamicSqlSupport.longitude, LocationRecordDynamicSqlSupport.accuracy, LocationRecordDynamicSqlSupport.altitude, LocationRecordDynamicSqlSupport.bearing, LocationRecordDynamicSqlSupport.speed, LocationRecordDynamicSqlSupport.country, LocationRecordDynamicSqlSupport.province, LocationRecordDynamicSqlSupport.city, LocationRecordDynamicSqlSupport.district, LocationRecordDynamicSqlSupport.street, LocationRecordDynamicSqlSupport.streetNumber, LocationRecordDynamicSqlSupport.cityCode, LocationRecordDynamicSqlSupport.adCode, LocationRecordDynamicSqlSupport.address, LocationRecordDynamicSqlSupport.description, LocationRecordDynamicSqlSupport.userId);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="LocationRecordResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="callback_time", property="callbackTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="location_time", property="locationTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="location_type", property="locationType", jdbcType=JdbcType.INTEGER),
        @Result(column="latitude", property="latitude", jdbcType=JdbcType.DOUBLE),
        @Result(column="longitude", property="longitude", jdbcType=JdbcType.DOUBLE),
        @Result(column="accuracy", property="accuracy", jdbcType=JdbcType.DOUBLE),
        @Result(column="altitude", property="altitude", jdbcType=JdbcType.DOUBLE),
        @Result(column="bearing", property="bearing", jdbcType=JdbcType.DOUBLE),
        @Result(column="speed", property="speed", jdbcType=JdbcType.DOUBLE),
        @Result(column="country", property="country", jdbcType=JdbcType.VARCHAR),
        @Result(column="province", property="province", jdbcType=JdbcType.VARCHAR),
        @Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
        @Result(column="district", property="district", jdbcType=JdbcType.VARCHAR),
        @Result(column="street", property="street", jdbcType=JdbcType.VARCHAR),
        @Result(column="street_number", property="streetNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="ad_code", property="adCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT)
    })
    List<LocationRecord> selectMany(SelectStatementProvider selectStatement);

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    default int insert(LocationRecord row) {
        return MyBatis3Utils.insert(this::insert, row, LocationRecordDynamicSqlSupport.locationRecord, c ->
            c.map(LocationRecordDynamicSqlSupport.id).toProperty("id")
            .map(LocationRecordDynamicSqlSupport.callbackTime).toProperty("callbackTime")
            .map(LocationRecordDynamicSqlSupport.locationTime).toProperty("locationTime")
            .map(LocationRecordDynamicSqlSupport.locationType).toProperty("locationType")
            .map(LocationRecordDynamicSqlSupport.latitude).toProperty("latitude")
            .map(LocationRecordDynamicSqlSupport.longitude).toProperty("longitude")
            .map(LocationRecordDynamicSqlSupport.accuracy).toProperty("accuracy")
            .map(LocationRecordDynamicSqlSupport.altitude).toProperty("altitude")
            .map(LocationRecordDynamicSqlSupport.bearing).toProperty("bearing")
            .map(LocationRecordDynamicSqlSupport.speed).toProperty("speed")
            .map(LocationRecordDynamicSqlSupport.country).toProperty("country")
            .map(LocationRecordDynamicSqlSupport.province).toProperty("province")
            .map(LocationRecordDynamicSqlSupport.city).toProperty("city")
            .map(LocationRecordDynamicSqlSupport.district).toProperty("district")
            .map(LocationRecordDynamicSqlSupport.street).toProperty("street")
            .map(LocationRecordDynamicSqlSupport.streetNumber).toProperty("streetNumber")
            .map(LocationRecordDynamicSqlSupport.cityCode).toProperty("cityCode")
            .map(LocationRecordDynamicSqlSupport.adCode).toProperty("adCode")
            .map(LocationRecordDynamicSqlSupport.address).toProperty("address")
            .map(LocationRecordDynamicSqlSupport.description).toProperty("description")
            .map(LocationRecordDynamicSqlSupport.userId).toProperty("userId")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    default int insertMultiple(Collection<LocationRecord> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, LocationRecordDynamicSqlSupport.locationRecord, c ->
            c.map(LocationRecordDynamicSqlSupport.id).toProperty("id")
            .map(LocationRecordDynamicSqlSupport.callbackTime).toProperty("callbackTime")
            .map(LocationRecordDynamicSqlSupport.locationTime).toProperty("locationTime")
            .map(LocationRecordDynamicSqlSupport.locationType).toProperty("locationType")
            .map(LocationRecordDynamicSqlSupport.latitude).toProperty("latitude")
            .map(LocationRecordDynamicSqlSupport.longitude).toProperty("longitude")
            .map(LocationRecordDynamicSqlSupport.accuracy).toProperty("accuracy")
            .map(LocationRecordDynamicSqlSupport.altitude).toProperty("altitude")
            .map(LocationRecordDynamicSqlSupport.bearing).toProperty("bearing")
            .map(LocationRecordDynamicSqlSupport.speed).toProperty("speed")
            .map(LocationRecordDynamicSqlSupport.country).toProperty("country")
            .map(LocationRecordDynamicSqlSupport.province).toProperty("province")
            .map(LocationRecordDynamicSqlSupport.city).toProperty("city")
            .map(LocationRecordDynamicSqlSupport.district).toProperty("district")
            .map(LocationRecordDynamicSqlSupport.street).toProperty("street")
            .map(LocationRecordDynamicSqlSupport.streetNumber).toProperty("streetNumber")
            .map(LocationRecordDynamicSqlSupport.cityCode).toProperty("cityCode")
            .map(LocationRecordDynamicSqlSupport.adCode).toProperty("adCode")
            .map(LocationRecordDynamicSqlSupport.address).toProperty("address")
            .map(LocationRecordDynamicSqlSupport.description).toProperty("description")
            .map(LocationRecordDynamicSqlSupport.userId).toProperty("userId")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    default int insertSelective(LocationRecord row) {
        return MyBatis3Utils.insert(this::insert, row, LocationRecordDynamicSqlSupport.locationRecord, c ->
            c.map(LocationRecordDynamicSqlSupport.id).toPropertyWhenPresent("id", row::getId)
            .map(LocationRecordDynamicSqlSupport.callbackTime).toPropertyWhenPresent("callbackTime", row::getCallbackTime)
            .map(LocationRecordDynamicSqlSupport.locationTime).toPropertyWhenPresent("locationTime", row::getLocationTime)
            .map(LocationRecordDynamicSqlSupport.locationType).toPropertyWhenPresent("locationType", row::getLocationType)
            .map(LocationRecordDynamicSqlSupport.latitude).toPropertyWhenPresent("latitude", row::getLatitude)
            .map(LocationRecordDynamicSqlSupport.longitude).toPropertyWhenPresent("longitude", row::getLongitude)
            .map(LocationRecordDynamicSqlSupport.accuracy).toPropertyWhenPresent("accuracy", row::getAccuracy)
            .map(LocationRecordDynamicSqlSupport.altitude).toPropertyWhenPresent("altitude", row::getAltitude)
            .map(LocationRecordDynamicSqlSupport.bearing).toPropertyWhenPresent("bearing", row::getBearing)
            .map(LocationRecordDynamicSqlSupport.speed).toPropertyWhenPresent("speed", row::getSpeed)
            .map(LocationRecordDynamicSqlSupport.country).toPropertyWhenPresent("country", row::getCountry)
            .map(LocationRecordDynamicSqlSupport.province).toPropertyWhenPresent("province", row::getProvince)
            .map(LocationRecordDynamicSqlSupport.city).toPropertyWhenPresent("city", row::getCity)
            .map(LocationRecordDynamicSqlSupport.district).toPropertyWhenPresent("district", row::getDistrict)
            .map(LocationRecordDynamicSqlSupport.street).toPropertyWhenPresent("street", row::getStreet)
            .map(LocationRecordDynamicSqlSupport.streetNumber).toPropertyWhenPresent("streetNumber", row::getStreetNumber)
            .map(LocationRecordDynamicSqlSupport.cityCode).toPropertyWhenPresent("cityCode", row::getCityCode)
            .map(LocationRecordDynamicSqlSupport.adCode).toPropertyWhenPresent("adCode", row::getAdCode)
            .map(LocationRecordDynamicSqlSupport.address).toPropertyWhenPresent("address", row::getAddress)
            .map(LocationRecordDynamicSqlSupport.description).toPropertyWhenPresent("description", row::getDescription)
            .map(LocationRecordDynamicSqlSupport.userId).toPropertyWhenPresent("userId", row::getUserId)
        );
    }

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    static UpdateDSL<UpdateModel> updateAllColumns(LocationRecord row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(LocationRecordDynamicSqlSupport.id).equalTo(row::getId)
                .set(LocationRecordDynamicSqlSupport.callbackTime).equalTo(row::getCallbackTime)
                .set(LocationRecordDynamicSqlSupport.locationTime).equalTo(row::getLocationTime)
                .set(LocationRecordDynamicSqlSupport.locationType).equalTo(row::getLocationType)
                .set(LocationRecordDynamicSqlSupport.latitude).equalTo(row::getLatitude)
                .set(LocationRecordDynamicSqlSupport.longitude).equalTo(row::getLongitude)
                .set(LocationRecordDynamicSqlSupport.accuracy).equalTo(row::getAccuracy)
                .set(LocationRecordDynamicSqlSupport.altitude).equalTo(row::getAltitude)
                .set(LocationRecordDynamicSqlSupport.bearing).equalTo(row::getBearing)
                .set(LocationRecordDynamicSqlSupport.speed).equalTo(row::getSpeed)
                .set(LocationRecordDynamicSqlSupport.country).equalTo(row::getCountry)
                .set(LocationRecordDynamicSqlSupport.province).equalTo(row::getProvince)
                .set(LocationRecordDynamicSqlSupport.city).equalTo(row::getCity)
                .set(LocationRecordDynamicSqlSupport.district).equalTo(row::getDistrict)
                .set(LocationRecordDynamicSqlSupport.street).equalTo(row::getStreet)
                .set(LocationRecordDynamicSqlSupport.streetNumber).equalTo(row::getStreetNumber)
                .set(LocationRecordDynamicSqlSupport.cityCode).equalTo(row::getCityCode)
                .set(LocationRecordDynamicSqlSupport.adCode).equalTo(row::getAdCode)
                .set(LocationRecordDynamicSqlSupport.address).equalTo(row::getAddress)
                .set(LocationRecordDynamicSqlSupport.description).equalTo(row::getDescription)
                .set(LocationRecordDynamicSqlSupport.userId).equalTo(row::getUserId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(LocationRecord row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(LocationRecordDynamicSqlSupport.id).equalToWhenPresent(row::getId)
                .set(LocationRecordDynamicSqlSupport.callbackTime).equalToWhenPresent(row::getCallbackTime)
                .set(LocationRecordDynamicSqlSupport.locationTime).equalToWhenPresent(row::getLocationTime)
                .set(LocationRecordDynamicSqlSupport.locationType).equalToWhenPresent(row::getLocationType)
                .set(LocationRecordDynamicSqlSupport.latitude).equalToWhenPresent(row::getLatitude)
                .set(LocationRecordDynamicSqlSupport.longitude).equalToWhenPresent(row::getLongitude)
                .set(LocationRecordDynamicSqlSupport.accuracy).equalToWhenPresent(row::getAccuracy)
                .set(LocationRecordDynamicSqlSupport.altitude).equalToWhenPresent(row::getAltitude)
                .set(LocationRecordDynamicSqlSupport.bearing).equalToWhenPresent(row::getBearing)
                .set(LocationRecordDynamicSqlSupport.speed).equalToWhenPresent(row::getSpeed)
                .set(LocationRecordDynamicSqlSupport.country).equalToWhenPresent(row::getCountry)
                .set(LocationRecordDynamicSqlSupport.province).equalToWhenPresent(row::getProvince)
                .set(LocationRecordDynamicSqlSupport.city).equalToWhenPresent(row::getCity)
                .set(LocationRecordDynamicSqlSupport.district).equalToWhenPresent(row::getDistrict)
                .set(LocationRecordDynamicSqlSupport.street).equalToWhenPresent(row::getStreet)
                .set(LocationRecordDynamicSqlSupport.streetNumber).equalToWhenPresent(row::getStreetNumber)
                .set(LocationRecordDynamicSqlSupport.cityCode).equalToWhenPresent(row::getCityCode)
                .set(LocationRecordDynamicSqlSupport.adCode).equalToWhenPresent(row::getAdCode)
                .set(LocationRecordDynamicSqlSupport.address).equalToWhenPresent(row::getAddress)
                .set(LocationRecordDynamicSqlSupport.description).equalToWhenPresent(row::getDescription)
                .set(LocationRecordDynamicSqlSupport.userId).equalToWhenPresent(row::getUserId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    default int updateByPrimaryKey(LocationRecord row) {
        return update(c ->
            c.set(LocationRecordDynamicSqlSupport.callbackTime).equalTo(row::getCallbackTime)
            .set(LocationRecordDynamicSqlSupport.locationTime).equalTo(row::getLocationTime)
            .set(LocationRecordDynamicSqlSupport.locationType).equalTo(row::getLocationType)
            .set(LocationRecordDynamicSqlSupport.latitude).equalTo(row::getLatitude)
            .set(LocationRecordDynamicSqlSupport.longitude).equalTo(row::getLongitude)
            .set(LocationRecordDynamicSqlSupport.accuracy).equalTo(row::getAccuracy)
            .set(LocationRecordDynamicSqlSupport.altitude).equalTo(row::getAltitude)
            .set(LocationRecordDynamicSqlSupport.bearing).equalTo(row::getBearing)
            .set(LocationRecordDynamicSqlSupport.speed).equalTo(row::getSpeed)
            .set(LocationRecordDynamicSqlSupport.country).equalTo(row::getCountry)
            .set(LocationRecordDynamicSqlSupport.province).equalTo(row::getProvince)
            .set(LocationRecordDynamicSqlSupport.city).equalTo(row::getCity)
            .set(LocationRecordDynamicSqlSupport.district).equalTo(row::getDistrict)
            .set(LocationRecordDynamicSqlSupport.street).equalTo(row::getStreet)
            .set(LocationRecordDynamicSqlSupport.streetNumber).equalTo(row::getStreetNumber)
            .set(LocationRecordDynamicSqlSupport.cityCode).equalTo(row::getCityCode)
            .set(LocationRecordDynamicSqlSupport.adCode).equalTo(row::getAdCode)
            .set(LocationRecordDynamicSqlSupport.address).equalTo(row::getAddress)
            .set(LocationRecordDynamicSqlSupport.description).equalTo(row::getDescription)
            .set(LocationRecordDynamicSqlSupport.userId).equalTo(row::getUserId)
            .where(LocationRecordDynamicSqlSupport.id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: location_record")
    default int updateByPrimaryKeySelective(LocationRecord row) {
        return update(c ->
            c.set(LocationRecordDynamicSqlSupport.callbackTime).equalToWhenPresent(row::getCallbackTime)
            .set(LocationRecordDynamicSqlSupport.locationTime).equalToWhenPresent(row::getLocationTime)
            .set(LocationRecordDynamicSqlSupport.locationType).equalToWhenPresent(row::getLocationType)
            .set(LocationRecordDynamicSqlSupport.latitude).equalToWhenPresent(row::getLatitude)
            .set(LocationRecordDynamicSqlSupport.longitude).equalToWhenPresent(row::getLongitude)
            .set(LocationRecordDynamicSqlSupport.accuracy).equalToWhenPresent(row::getAccuracy)
            .set(LocationRecordDynamicSqlSupport.altitude).equalToWhenPresent(row::getAltitude)
            .set(LocationRecordDynamicSqlSupport.bearing).equalToWhenPresent(row::getBearing)
            .set(LocationRecordDynamicSqlSupport.speed).equalToWhenPresent(row::getSpeed)
            .set(LocationRecordDynamicSqlSupport.country).equalToWhenPresent(row::getCountry)
            .set(LocationRecordDynamicSqlSupport.province).equalToWhenPresent(row::getProvince)
            .set(LocationRecordDynamicSqlSupport.city).equalToWhenPresent(row::getCity)
            .set(LocationRecordDynamicSqlSupport.district).equalToWhenPresent(row::getDistrict)
            .set(LocationRecordDynamicSqlSupport.street).equalToWhenPresent(row::getStreet)
            .set(LocationRecordDynamicSqlSupport.streetNumber).equalToWhenPresent(row::getStreetNumber)
            .set(LocationRecordDynamicSqlSupport.cityCode).equalToWhenPresent(row::getCityCode)
            .set(LocationRecordDynamicSqlSupport.adCode).equalToWhenPresent(row::getAdCode)
            .set(LocationRecordDynamicSqlSupport.address).equalToWhenPresent(row::getAddress)
            .set(LocationRecordDynamicSqlSupport.description).equalToWhenPresent(row::getDescription)
            .set(LocationRecordDynamicSqlSupport.userId).equalToWhenPresent(row::getUserId)
            .where(LocationRecordDynamicSqlSupport.id, isEqualTo(row::getId))
        );
    }
}
