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

import static jj.tech.paolu.repository.mybatis.dao.support.SysResourceDynamicSqlSupport.*;
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.SysResource;
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 SysResourceMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<SysResource>, CommonUpdateMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7041797+08:00", comments="Source Table: yx..sys_resource")
    BasicColumn[] selectList = BasicColumn.columnList(id, parent_id, level, name, types, url, icon, ishide, description);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7031795+08:00", comments="Source Table: yx..sys_resource")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SysResourceResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="parent_id", property="parent_id", jdbcType=JdbcType.VARCHAR),
        @Result(column="level", property="level", jdbcType=JdbcType.SMALLINT),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="types", property="types", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="icon", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="ishide", property="ishide", jdbcType=JdbcType.TINYINT),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR)
    })
    List<SysResource> selectMany(SelectStatementProvider selectStatement);

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7031795+08:00", comments="Source Table: yx..sys_resource")
    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.7031795+08:00", comments="Source Table: yx..sys_resource")
    default int insert(SysResource row) {
        return MyBatis3Utils.insert(this::insert, row, sysResource, c ->
            c.map(id).toProperty("id")
            .map(parent_id).toProperty("parent_id")
            .map(level).toProperty("level")
            .map(name).toProperty("name")
            .map(types).toProperty("types")
            .map(url).toProperty("url")
            .map(icon).toProperty("icon")
            .map(ishide).toProperty("ishide")
            .map(description).toProperty("description")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7031795+08:00", comments="Source Table: yx..sys_resource")
    default int insertMultiple(Collection<SysResource> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, sysResource, c ->
            c.map(id).toProperty("id")
            .map(parent_id).toProperty("parent_id")
            .map(level).toProperty("level")
            .map(name).toProperty("name")
            .map(types).toProperty("types")
            .map(url).toProperty("url")
            .map(icon).toProperty("icon")
            .map(ishide).toProperty("ishide")
            .map(description).toProperty("description")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7041797+08:00", comments="Source Table: yx..sys_resource")
    default int insertSelective(SysResource row) {
        return MyBatis3Utils.insert(this::insert, row, sysResource, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(parent_id).toPropertyWhenPresent("parent_id", row::getParent_id)
            .map(level).toPropertyWhenPresent("level", row::getLevel)
            .map(name).toPropertyWhenPresent("name", row::getName)
            .map(types).toPropertyWhenPresent("types", row::getTypes)
            .map(url).toPropertyWhenPresent("url", row::getUrl)
            .map(icon).toPropertyWhenPresent("icon", row::getIcon)
            .map(ishide).toPropertyWhenPresent("ishide", row::getIshide)
            .map(description).toPropertyWhenPresent("description", row::getDescription)
        );
    }

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7041797+08:00", comments="Source Table: yx..sys_resource")
    static UpdateDSL<UpdateModel> updateAllColumns(SysResource row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(parent_id).equalTo(row::getParent_id)
                .set(level).equalTo(row::getLevel)
                .set(name).equalTo(row::getName)
                .set(types).equalTo(row::getTypes)
                .set(url).equalTo(row::getUrl)
                .set(icon).equalTo(row::getIcon)
                .set(ishide).equalTo(row::getIshide)
                .set(description).equalTo(row::getDescription);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7041797+08:00", comments="Source Table: yx..sys_resource")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(SysResource row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(parent_id).equalToWhenPresent(row::getParent_id)
                .set(level).equalToWhenPresent(row::getLevel)
                .set(name).equalToWhenPresent(row::getName)
                .set(types).equalToWhenPresent(row::getTypes)
                .set(url).equalToWhenPresent(row::getUrl)
                .set(icon).equalToWhenPresent(row::getIcon)
                .set(ishide).equalToWhenPresent(row::getIshide)
                .set(description).equalToWhenPresent(row::getDescription);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7041797+08:00", comments="Source Table: yx..sys_resource")
    default int updateByPrimaryKey(SysResource row) {
        return update(c ->
            c.set(parent_id).equalTo(row::getParent_id)
            .set(level).equalTo(row::getLevel)
            .set(name).equalTo(row::getName)
            .set(types).equalTo(row::getTypes)
            .set(url).equalTo(row::getUrl)
            .set(icon).equalTo(row::getIcon)
            .set(ishide).equalTo(row::getIshide)
            .set(description).equalTo(row::getDescription)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7041797+08:00", comments="Source Table: yx..sys_resource")
    default int updateByPrimaryKeySelective(SysResource row) {
        return update(c ->
            c.set(parent_id).equalToWhenPresent(row::getParent_id)
            .set(level).equalToWhenPresent(row::getLevel)
            .set(name).equalToWhenPresent(row::getName)
            .set(types).equalToWhenPresent(row::getTypes)
            .set(url).equalToWhenPresent(row::getUrl)
            .set(icon).equalToWhenPresent(row::getIcon)
            .set(ishide).equalToWhenPresent(row::getIshide)
            .set(description).equalToWhenPresent(row::getDescription)
            .where(id, isEqualTo(row::getId))
        );
    }
}