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

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6851854+08:00", comments="Source Table: yx..sys_role_resource")
    default int deleteByPrimaryKey(String roleid_, String resid_) {
        return delete(c -> 
            c.where(roleid, isEqualTo(roleid_))
            .and(resid, isEqualTo(resid_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6851854+08:00", comments="Source Table: yx..sys_role_resource")
    default int insert(SysRoleResource row) {
        return MyBatis3Utils.insert(this::insert, row, sysRoleResource, c ->
            c.map(roleid).toProperty("roleid")
            .map(resid).toProperty("resid")
            .map(id).toProperty("id")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6851854+08:00", comments="Source Table: yx..sys_role_resource")
    default int insertMultiple(Collection<SysRoleResource> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, sysRoleResource, c ->
            c.map(roleid).toProperty("roleid")
            .map(resid).toProperty("resid")
            .map(id).toProperty("id")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6851854+08:00", comments="Source Table: yx..sys_role_resource")
    default int insertSelective(SysRoleResource row) {
        return MyBatis3Utils.insert(this::insert, row, sysRoleResource, c ->
            c.map(roleid).toPropertyWhenPresent("roleid", row::getRoleid)
            .map(resid).toPropertyWhenPresent("resid", row::getResid)
            .map(id).toPropertyWhenPresent("id", row::getId)
        );
    }

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6861845+08:00", comments="Source Table: yx..sys_role_resource")
    default Optional<SysRoleResource> selectByPrimaryKey(String roleid_, String resid_) {
        return selectOne(c ->
            c.where(roleid, isEqualTo(roleid_))
            .and(resid, isEqualTo(resid_))
        );
    }

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6861845+08:00", comments="Source Table: yx..sys_role_resource")
    static UpdateDSL<UpdateModel> updateAllColumns(SysRoleResource row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(roleid).equalTo(row::getRoleid)
                .set(resid).equalTo(row::getResid)
                .set(id).equalTo(row::getId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6861845+08:00", comments="Source Table: yx..sys_role_resource")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(SysRoleResource row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(roleid).equalToWhenPresent(row::getRoleid)
                .set(resid).equalToWhenPresent(row::getResid)
                .set(id).equalToWhenPresent(row::getId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6861845+08:00", comments="Source Table: yx..sys_role_resource")
    default int updateByPrimaryKey(SysRoleResource row) {
        return update(c ->
            c.set(id).equalTo(row::getId)
            .where(roleid, isEqualTo(row::getRoleid))
            .and(resid, isEqualTo(row::getResid))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.6861845+08:00", comments="Source Table: yx..sys_role_resource")
    default int updateByPrimaryKeySelective(SysRoleResource row) {
        return update(c ->
            c.set(id).equalToWhenPresent(row::getId)
            .where(roleid, isEqualTo(row::getRoleid))
            .and(resid, isEqualTo(row::getResid))
        );
    }
}