package com.hfkj.dao;

import com.hfkj.entity.CmsCategory;
import com.hfkj.entity.CmsCategoryExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

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

    @DeleteProvider(type= CmsCategorySqlProvider.class, method="deleteByExample")
    int deleteByExample(CmsCategoryExample example);

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

    @Insert({
        "insert into cms_category (parent_id, `name`, ",
        "code, sort, cover_img, ",
        "`status`, remark, ",
        "ext_1, ext_2, ext_3)",
        "values (#{parentId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
        "#{code,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{coverImg,jdbcType=VARCHAR}, ",
        "#{status,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, ",
        "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(CmsCategory record);

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

    @SelectProvider(type= CmsCategorySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
        @Result(column="parent_id", property="parentId", jdbcType= JdbcType.BIGINT),
        @Result(column="name", property="name", jdbcType= JdbcType.VARCHAR),
        @Result(column="code", property="code", jdbcType= JdbcType.VARCHAR),
        @Result(column="sort", property="sort", jdbcType= JdbcType.INTEGER),
        @Result(column="cover_img", property="coverImg", jdbcType= JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType= JdbcType.INTEGER),
        @Result(column="remark", property="remark", jdbcType= JdbcType.VARCHAR),
        @Result(column="ext_1", property="ext1", jdbcType= JdbcType.VARCHAR),
        @Result(column="ext_2", property="ext2", jdbcType= JdbcType.VARCHAR),
        @Result(column="ext_3", property="ext3", jdbcType= JdbcType.VARCHAR)
    })
    List<CmsCategory> selectByExample(CmsCategoryExample example);

    @Select({
        "select",
        "id, parent_id, `name`, code, sort, cover_img, `status`, remark, ext_1, ext_2, ",
        "ext_3",
        "from cms_category",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
        @Result(column="parent_id", property="parentId", jdbcType= JdbcType.BIGINT),
        @Result(column="name", property="name", jdbcType= JdbcType.VARCHAR),
        @Result(column="code", property="code", jdbcType= JdbcType.VARCHAR),
        @Result(column="sort", property="sort", jdbcType= JdbcType.INTEGER),
        @Result(column="cover_img", property="coverImg", jdbcType= JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType= JdbcType.INTEGER),
        @Result(column="remark", property="remark", jdbcType= JdbcType.VARCHAR),
        @Result(column="ext_1", property="ext1", jdbcType= JdbcType.VARCHAR),
        @Result(column="ext_2", property="ext2", jdbcType= JdbcType.VARCHAR),
        @Result(column="ext_3", property="ext3", jdbcType= JdbcType.VARCHAR)
    })
    CmsCategory selectByPrimaryKey(Long id);

    @UpdateProvider(type= CmsCategorySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") CmsCategory record, @Param("example") CmsCategoryExample example);

    @UpdateProvider(type= CmsCategorySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") CmsCategory record, @Param("example") CmsCategoryExample example);

    @UpdateProvider(type= CmsCategorySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CmsCategory record);

    @Update({
        "update cms_category",
        "set parent_id = #{parentId,jdbcType=BIGINT},",
          "`name` = #{name,jdbcType=VARCHAR},",
          "code = #{code,jdbcType=VARCHAR},",
          "sort = #{sort,jdbcType=INTEGER},",
          "cover_img = #{coverImg,jdbcType=VARCHAR},",
          "`status` = #{status,jdbcType=INTEGER},",
          "remark = #{remark,jdbcType=VARCHAR},",
          "ext_1 = #{ext1,jdbcType=VARCHAR},",
          "ext_2 = #{ext2,jdbcType=VARCHAR},",
          "ext_3 = #{ext3,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CmsCategory record);
}
