package net.wicp.tams.app.duckula.controller.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import net.wicp.tams.app.duckula.controller.bean.models.CommonVersion;
import net.wicp.tams.app.duckula.controller.bean.models.CommonVersionExample;

public interface CommonVersionMapper extends BaseMapper<CommonVersion> {

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	long countByExample(CommonVersionExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	int deleteByExample(CommonVersionExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	@Delete({ "delete from common_version", "where id = #{id,jdbcType=BIGINT}" })
	int deleteByPrimaryKey(Long id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	@Insert({ "insert into common_version (id, main_version, ", "main_path, data_version, ", "data_path, image_group, ",
			"author, update_time, ", "readme)", "values (#{id,jdbcType=BIGINT}, #{mainVersion,jdbcType=VARCHAR}, ",
			"#{mainPath,jdbcType=VARCHAR}, #{dataVersion,jdbcType=VARCHAR}, ",
			"#{dataPath,jdbcType=VARCHAR}, #{imageGroup,jdbcType=VARCHAR}, ",
			"#{author,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ", "#{readme,jdbcType=VARCHAR})" })
	int insert(CommonVersion record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	int insertSelective(CommonVersion record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	List<CommonVersion> selectByExample(CommonVersionExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	@Select({ "select", "id, main_version, main_path, data_version, data_path, image_group, author, update_time, ",
			"readme", "from common_version", "where id = #{id,jdbcType=BIGINT}" })
	@ResultMap("net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper.BaseResultMap")
	CommonVersion selectByPrimaryKey(Long id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	int updateByExampleSelective(@Param("record") CommonVersion record, @Param("example") CommonVersionExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	int updateByExample(@Param("record") CommonVersion record, @Param("example") CommonVersionExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	int updateByPrimaryKeySelective(CommonVersion record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table common_version
	 * @mbg.generated
	 */
	@Update({ "update common_version", "set main_version = #{mainVersion,jdbcType=VARCHAR},",
			"main_path = #{mainPath,jdbcType=VARCHAR},", "data_version = #{dataVersion,jdbcType=VARCHAR},",
			"data_path = #{dataPath,jdbcType=VARCHAR},", "image_group = #{imageGroup,jdbcType=VARCHAR},",
			"author = #{author,jdbcType=VARCHAR},", "update_time = #{updateTime,jdbcType=TIMESTAMP},",
			"readme = #{readme,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}" })
	int updateByPrimaryKey(CommonVersion record);

	//得到最大的版本
	@Select({ "select", "id, main_version, main_path, data_version, data_path, image, author, update_time, ", "readme",
		"from common_version", "order by id desc limit 0,1" })
	@ResultMap("net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper.BaseResultMap")
	CommonVersion selectByMaxKey();
}