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

import static jj.tech.paolu.repository.mybatis.dao.support.SysAdminDynamicSqlSupport.*;
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.SysAdmin;
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 SysAdminMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<SysAdmin>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6891846+08:00", comments="Source Table: yx..sys_admin")
    BasicColumn[] selectList = BasicColumn.columnList(id, org_id, type, realname, username, password, islock);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6881839+08:00", comments="Source Table: yx..sys_admin")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SysAdminResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="org_id", property="org_id", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="realname", property="realname", jdbcType=JdbcType.VARCHAR),
        @Result(column="username", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="islock", property="islock", jdbcType=JdbcType.INTEGER)
    })
    List<SysAdmin> selectMany(SelectStatementProvider selectStatement);

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6881839+08:00", comments="Source Table: yx..sys_admin")
    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.6881839+08:00", comments="Source Table: yx..sys_admin")
    default int insert(SysAdmin row) {
        return MyBatis3Utils.insert(this::insert, row, sysAdmin, c ->
            c.map(id).toProperty("id")
            .map(org_id).toProperty("org_id")
            .map(type).toProperty("type")
            .map(realname).toProperty("realname")
            .map(username).toProperty("username")
            .map(password).toProperty("password")
            .map(islock).toProperty("islock")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6881839+08:00", comments="Source Table: yx..sys_admin")
    default int insertMultiple(Collection<SysAdmin> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, sysAdmin, c ->
            c.map(id).toProperty("id")
            .map(org_id).toProperty("org_id")
            .map(type).toProperty("type")
            .map(realname).toProperty("realname")
            .map(username).toProperty("username")
            .map(password).toProperty("password")
            .map(islock).toProperty("islock")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6881839+08:00", comments="Source Table: yx..sys_admin")
    default int insertSelective(SysAdmin row) {
        return MyBatis3Utils.insert(this::insert, row, sysAdmin, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(org_id).toPropertyWhenPresent("org_id", row::getOrg_id)
            .map(type).toPropertyWhenPresent("type", row::getType)
            .map(realname).toPropertyWhenPresent("realname", row::getRealname)
            .map(username).toPropertyWhenPresent("username", row::getUsername)
            .map(password).toPropertyWhenPresent("password", row::getPassword)
            .map(islock).toPropertyWhenPresent("islock", row::getIslock)
        );
    }

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6891846+08:00", comments="Source Table: yx..sys_admin")
    static UpdateDSL<UpdateModel> updateAllColumns(SysAdmin row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(org_id).equalTo(row::getOrg_id)
                .set(type).equalTo(row::getType)
                .set(realname).equalTo(row::getRealname)
                .set(username).equalTo(row::getUsername)
                .set(password).equalTo(row::getPassword)
                .set(islock).equalTo(row::getIslock);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6891846+08:00", comments="Source Table: yx..sys_admin")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(SysAdmin row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(org_id).equalToWhenPresent(row::getOrg_id)
                .set(type).equalToWhenPresent(row::getType)
                .set(realname).equalToWhenPresent(row::getRealname)
                .set(username).equalToWhenPresent(row::getUsername)
                .set(password).equalToWhenPresent(row::getPassword)
                .set(islock).equalToWhenPresent(row::getIslock);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6891846+08:00", comments="Source Table: yx..sys_admin")
    default int updateByPrimaryKey(SysAdmin row) {
        return update(c ->
            c.set(org_id).equalTo(row::getOrg_id)
            .set(type).equalTo(row::getType)
            .set(realname).equalTo(row::getRealname)
            .set(username).equalTo(row::getUsername)
            .set(password).equalTo(row::getPassword)
            .set(islock).equalTo(row::getIslock)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6891846+08:00", comments="Source Table: yx..sys_admin")
    default int updateByPrimaryKeySelective(SysAdmin row) {
        return update(c ->
            c.set(org_id).equalToWhenPresent(row::getOrg_id)
            .set(type).equalToWhenPresent(row::getType)
            .set(realname).equalToWhenPresent(row::getRealname)
            .set(username).equalToWhenPresent(row::getUsername)
            .set(password).equalToWhenPresent(row::getPassword)
            .set(islock).equalToWhenPresent(row::getIslock)
            .where(id, isEqualTo(row::getId))
        );
    }
}