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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7081804+08:00", comments="Source Table: yx..sys_menu")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SysMenuResult", 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.INTEGER),
        @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="is_open", property="is_open", jdbcType=JdbcType.INTEGER),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER)
    })
    List<SysMenu> selectMany(SelectStatementProvider selectStatement);

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.7081804+08:00", comments="Source Table: yx..sys_menu")
    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.7081804+08:00", comments="Source Table: yx..sys_menu")
    default int insert(SysMenu row) {
        return MyBatis3Utils.insert(this::insert, row, sysMenu, 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(is_open).toProperty("is_open")
            .map(description).toProperty("description")
            .map(sort).toProperty("sort")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.709184+08:00", comments="Source Table: yx..sys_menu")
    default int insertMultiple(Collection<SysMenu> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, sysMenu, 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(is_open).toProperty("is_open")
            .map(description).toProperty("description")
            .map(sort).toProperty("sort")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.709184+08:00", comments="Source Table: yx..sys_menu")
    default int insertSelective(SysMenu row) {
        return MyBatis3Utils.insert(this::insert, row, sysMenu, 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(is_open).toPropertyWhenPresent("is_open", row::getIs_open)
            .map(description).toPropertyWhenPresent("description", row::getDescription)
            .map(sort).toPropertyWhenPresent("sort", row::getSort)
        );
    }

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

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

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

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

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

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.709184+08:00", comments="Source Table: yx..sys_menu")
    static UpdateDSL<UpdateModel> updateAllColumns(SysMenu 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(is_open).equalTo(row::getIs_open)
                .set(description).equalTo(row::getDescription)
                .set(sort).equalTo(row::getSort);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.709184+08:00", comments="Source Table: yx..sys_menu")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(SysMenu 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(is_open).equalToWhenPresent(row::getIs_open)
                .set(description).equalToWhenPresent(row::getDescription)
                .set(sort).equalToWhenPresent(row::getSort);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.709184+08:00", comments="Source Table: yx..sys_menu")
    default int updateByPrimaryKey(SysMenu 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(is_open).equalTo(row::getIs_open)
            .set(description).equalTo(row::getDescription)
            .set(sort).equalTo(row::getSort)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2024-09-27T03:01:29.709184+08:00", comments="Source Table: yx..sys_menu")
    default int updateByPrimaryKeySelective(SysMenu 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(is_open).equalToWhenPresent(row::getIs_open)
            .set(description).equalToWhenPresent(row::getDescription)
            .set(sort).equalToWhenPresent(row::getSort)
            .where(id, isEqualTo(row::getId))
        );
    }
}