package jj.tech.paolu.repository.mybatis.dao;

import static jj.tech.paolu.repository.mybatis.dao.support.SysConfigDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;

import jakarta.annotation.Generated;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import jj.tech.paolu.repository.mybatis.entity.SysConfig;
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 SysConfigMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<SysConfig>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    BasicColumn[] selectList = BasicColumn.columnList(id, subgroup, k, val, admin_id, adminname, edittime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SysConfigResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="subgroup", property="subgroup", jdbcType=JdbcType.VARCHAR),
        @Result(column="k", property="k", jdbcType=JdbcType.VARCHAR),
        @Result(column="val", property="val", jdbcType=JdbcType.VARCHAR),
        @Result(column="admin_id", property="admin_id", jdbcType=JdbcType.VARCHAR),
        @Result(column="adminname", property="adminname", jdbcType=JdbcType.VARCHAR),
        @Result(column="edittime", property="edittime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<SysConfig> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("SysConfigResult")
    Optional<SysConfig> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, sysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, sysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    default int deleteByPrimaryKey(String id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    default int insert(SysConfig row) {
        return MyBatis3Utils.insert(this::insert, row, sysConfig, c ->
            c.map(id).toProperty("id")
            .map(subgroup).toProperty("subgroup")
            .map(k).toProperty("k")
            .map(val).toProperty("val")
            .map(admin_id).toProperty("admin_id")
            .map(adminname).toProperty("adminname")
            .map(edittime).toProperty("edittime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    default int insertMultiple(Collection<SysConfig> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, sysConfig, c ->
            c.map(id).toProperty("id")
            .map(subgroup).toProperty("subgroup")
            .map(k).toProperty("k")
            .map(val).toProperty("val")
            .map(admin_id).toProperty("admin_id")
            .map(adminname).toProperty("adminname")
            .map(edittime).toProperty("edittime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6791817+08:00", comments="Source Table: yx..sys_config")
    default int insertSelective(SysConfig row) {
        return MyBatis3Utils.insert(this::insert, row, sysConfig, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(subgroup).toPropertyWhenPresent("subgroup", row::getSubgroup)
            .map(k).toPropertyWhenPresent("k", row::getK)
            .map(val).toPropertyWhenPresent("val", row::getVal)
            .map(admin_id).toPropertyWhenPresent("admin_id", row::getAdmin_id)
            .map(adminname).toPropertyWhenPresent("adminname", row::getAdminname)
            .map(edittime).toPropertyWhenPresent("edittime", row::getEdittime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default Optional<SysConfig> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, sysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default List<SysConfig> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, sysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default List<SysConfig> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, sysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default Optional<SysConfig> selectByPrimaryKey(String id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, sysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    static UpdateDSL<UpdateModel> updateAllColumns(SysConfig row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(subgroup).equalTo(row::getSubgroup)
                .set(k).equalTo(row::getK)
                .set(val).equalTo(row::getVal)
                .set(admin_id).equalTo(row::getAdmin_id)
                .set(adminname).equalTo(row::getAdminname)
                .set(edittime).equalTo(row::getEdittime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(SysConfig row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(subgroup).equalToWhenPresent(row::getSubgroup)
                .set(k).equalToWhenPresent(row::getK)
                .set(val).equalToWhenPresent(row::getVal)
                .set(admin_id).equalToWhenPresent(row::getAdmin_id)
                .set(adminname).equalToWhenPresent(row::getAdminname)
                .set(edittime).equalToWhenPresent(row::getEdittime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default int updateByPrimaryKey(SysConfig row) {
        return update(c ->
            c.set(subgroup).equalTo(row::getSubgroup)
            .set(k).equalTo(row::getK)
            .set(val).equalTo(row::getVal)
            .set(admin_id).equalTo(row::getAdmin_id)
            .set(adminname).equalTo(row::getAdminname)
            .set(edittime).equalTo(row::getEdittime)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6801823+08:00", comments="Source Table: yx..sys_config")
    default int updateByPrimaryKeySelective(SysConfig row) {
        return update(c ->
            c.set(subgroup).equalToWhenPresent(row::getSubgroup)
            .set(k).equalToWhenPresent(row::getK)
            .set(val).equalToWhenPresent(row::getVal)
            .set(admin_id).equalToWhenPresent(row::getAdmin_id)
            .set(adminname).equalToWhenPresent(row::getAdminname)
            .set(edittime).equalToWhenPresent(row::getEdittime)
            .where(id, isEqualTo(row::getId))
        );
    }
}