package com.hai.dao;

import com.hai.entity.SecRole;
import com.hai.entity.SecRoleExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 
 * 代码由工具生成,请勿修改!!!
 * 如果需要扩展请在其父类进行扩展
 * 
 **/
@Repository
public interface SecRoleMapper extends SecRoleMapperExt {
    @SelectProvider(type=SecRoleSqlProvider.class, method="countByExample")
    long countByExample(SecRoleExample example);

    @DeleteProvider(type=SecRoleSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecRoleExample example);

    @Delete({
        "delete from sec_role",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into sec_role (role_name, role_desc, ",
        "role_type, enable_status, ",
        "primary_role, templet_type, ",
        "company_id, temp_role_id, ",
        "create_time, update_time)",
        "values (#{roleName,jdbcType=VARCHAR}, #{roleDesc,jdbcType=VARCHAR}, ",
        "#{roleType,jdbcType=INTEGER}, #{enableStatus,jdbcType=INTEGER}, ",
        "#{primaryRole,jdbcType=INTEGER}, #{templetType,jdbcType=INTEGER}, ",
        "#{companyId,jdbcType=BIGINT}, #{tempRoleId,jdbcType=BIGINT}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(SecRole record);

    @InsertProvider(type=SecRoleSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(SecRole record);

    @SelectProvider(type=SecRoleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="role_name", property="roleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_desc", property="roleDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_type", property="roleType", jdbcType=JdbcType.INTEGER),
        @Result(column="enable_status", property="enableStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="primary_role", property="primaryRole", jdbcType=JdbcType.INTEGER),
        @Result(column="templet_type", property="templetType", jdbcType=JdbcType.INTEGER),
        @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
        @Result(column="temp_role_id", property="tempRoleId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<SecRole> selectByExample(SecRoleExample example);

    @Select({
        "select",
        "id, role_name, role_desc, role_type, enable_status, primary_role, templet_type, ",
        "company_id, temp_role_id, create_time, update_time",
        "from sec_role",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="role_name", property="roleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_desc", property="roleDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_type", property="roleType", jdbcType=JdbcType.INTEGER),
        @Result(column="enable_status", property="enableStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="primary_role", property="primaryRole", jdbcType=JdbcType.INTEGER),
        @Result(column="templet_type", property="templetType", jdbcType=JdbcType.INTEGER),
        @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
        @Result(column="temp_role_id", property="tempRoleId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    SecRole selectByPrimaryKey(Long id);

    @UpdateProvider(type=SecRoleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecRole record, @Param("example") SecRoleExample example);

    @UpdateProvider(type=SecRoleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecRole record, @Param("example") SecRoleExample example);

    @UpdateProvider(type=SecRoleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecRole record);

    @Update({
        "update sec_role",
        "set role_name = #{roleName,jdbcType=VARCHAR},",
          "role_desc = #{roleDesc,jdbcType=VARCHAR},",
          "role_type = #{roleType,jdbcType=INTEGER},",
          "enable_status = #{enableStatus,jdbcType=INTEGER},",
          "primary_role = #{primaryRole,jdbcType=INTEGER},",
          "templet_type = #{templetType,jdbcType=INTEGER},",
          "company_id = #{companyId,jdbcType=BIGINT},",
          "temp_role_id = #{tempRoleId,jdbcType=BIGINT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(SecRole record);
}
