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

import static jj.tech.paolu.repository.mybatis.dao.support.SysAdminRoleDynamicSqlSupport.*;
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.SysAdminRole;
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 SysAdminRoleMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<SysAdminRole>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6771824+08:00", comments="Source Table: yx..sys_admin_role")
    BasicColumn[] selectList = BasicColumn.columnList(id, admin_id, role_id);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6761835+08:00", comments="Source Table: yx..sys_admin_role")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SysAdminRoleResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="admin_id", property="admin_id", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_id", property="role_id", jdbcType=JdbcType.INTEGER)
    })
    List<SysAdminRole> selectMany(SelectStatementProvider selectStatement);

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6761835+08:00", comments="Source Table: yx..sys_admin_role")
    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.6761835+08:00", comments="Source Table: yx..sys_admin_role")
    default int insert(SysAdminRole row) {
        return MyBatis3Utils.insert(this::insert, row, sysAdminRole, c ->
            c.map(id).toProperty("id")
            .map(admin_id).toProperty("admin_id")
            .map(role_id).toProperty("role_id")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6761835+08:00", comments="Source Table: yx..sys_admin_role")
    default int insertMultiple(Collection<SysAdminRole> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, sysAdminRole, c ->
            c.map(id).toProperty("id")
            .map(admin_id).toProperty("admin_id")
            .map(role_id).toProperty("role_id")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6761835+08:00", comments="Source Table: yx..sys_admin_role")
    default int insertSelective(SysAdminRole row) {
        return MyBatis3Utils.insert(this::insert, row, sysAdminRole, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(admin_id).toPropertyWhenPresent("admin_id", row::getAdmin_id)
            .map(role_id).toPropertyWhenPresent("role_id", row::getRole_id)
        );
    }

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6771824+08:00", comments="Source Table: yx..sys_admin_role")
    static UpdateDSL<UpdateModel> updateAllColumns(SysAdminRole row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(admin_id).equalTo(row::getAdmin_id)
                .set(role_id).equalTo(row::getRole_id);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6771824+08:00", comments="Source Table: yx..sys_admin_role")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(SysAdminRole row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(admin_id).equalToWhenPresent(row::getAdmin_id)
                .set(role_id).equalToWhenPresent(row::getRole_id);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6771824+08:00", comments="Source Table: yx..sys_admin_role")
    default int updateByPrimaryKey(SysAdminRole row) {
        return update(c ->
            c.set(admin_id).equalTo(row::getAdmin_id)
            .set(role_id).equalTo(row::getRole_id)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6771824+08:00", comments="Source Table: yx..sys_admin_role")
    default int updateByPrimaryKeySelective(SysAdminRole row) {
        return update(c ->
            c.set(admin_id).equalToWhenPresent(row::getAdmin_id)
            .set(role_id).equalToWhenPresent(row::getRole_id)
            .where(id, isEqualTo(row::getId))
        );
    }
}