package com.bootdo.blog.dao;

import com.bootdo.blog.domain.BCommentsDO;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
 * 
 * 
 * @author chglee
 * @email 1992lcg@163.com
 * @date 2017-09-10 19:27:42
 */
@Mapper
public interface BCommentsMapper {

	@Select("select `id`, `created`, `title`, `author`, `author_id`, `owner_id`, `email`, `url`, `ip`, `agent`, `content`, `type`, `status`, `parent` from b_comments where id = #{id}")
	BCommentsDO get(Long id);
	
	@Select("<script>" +
	"select * from b_comments " + 
			"<where>" + 
		  		  "<if test=\"id != null and id != ''\">"+ "and id = #{id} " + "</if>" + 
		  		  "<if test=\"created != null and created != ''\">"+ "and created = #{created} " + "</if>" + 
		  		  "<if test=\"title != null and title != ''\">"+ "and title = #{title} " + "</if>" + 
		  		  "<if test=\"author != null and author != ''\">"+ "and author = #{author} " + "</if>" + 
		  		  "<if test=\"authorId != null and authorId != ''\">"+ "and author_id = #{authorId} " + "</if>" + 
		  		  "<if test=\"ownerId != null and ownerId != ''\">"+ "and owner_id = #{ownerId} " + "</if>" + 
		  		  "<if test=\"email != null and email != ''\">"+ "and email = #{email} " + "</if>" + 
		  		  "<if test=\"url != null and url != ''\">"+ "and url = #{url} " + "</if>" + 
		  		  "<if test=\"ip != null and ip != ''\">"+ "and ip = #{ip} " + "</if>" + 
		  		  "<if test=\"agent != null and agent != ''\">"+ "and agent = #{agent} " + "</if>" + 
		  		  "<if test=\"content != null and content != ''\">"+ "and content = #{content} " + "</if>" + 
		  		  "<if test=\"type != null and type != ''\">"+ "and type = #{type} " + "</if>" + 
		  		  "<if test=\"status != null and status != ''\">"+ "and status = #{status} " + "</if>" + 
		  		  "<if test=\"parent != null and parent != ''\">"+ "and parent = #{parent} " + "</if>" + 
		  			"</where>"+ 
			" <choose>" + 
	            "<when test=\"sort != null and sort.trim() != ''\">" + 
	                "order by ${sort} ${order}" + 
	            "</when>" + 
				"<otherwise>" + 
	                "order by id desc" + 
				"</otherwise>" + 
	        "</choose>"+
			"<if test=\"offset != null and limit != null\">"+
			"limit #{offset}, #{limit}" + 
			"</if>"+
			"</script>")
	List<BCommentsDO> list(Map<String,Object> map);
	
	@Select("<script>" +
	"select count(*) from b_comments " + 
			"<where>" + 
		  		  "<if test=\"id != null and id != ''\">"+ "and id = #{id} " + "</if>" + 
		  		  "<if test=\"created != null and created != ''\">"+ "and created = #{created} " + "</if>" + 
		  		  "<if test=\"title != null and title != ''\">"+ "and title = #{title} " + "</if>" + 
		  		  "<if test=\"author != null and author != ''\">"+ "and author = #{author} " + "</if>" + 
		  		  "<if test=\"authorId != null and authorId != ''\">"+ "and author_id = #{authorId} " + "</if>" + 
		  		  "<if test=\"ownerId != null and ownerId != ''\">"+ "and owner_id = #{ownerId} " + "</if>" + 
		  		  "<if test=\"email != null and email != ''\">"+ "and email = #{email} " + "</if>" + 
		  		  "<if test=\"url != null and url != ''\">"+ "and url = #{url} " + "</if>" + 
		  		  "<if test=\"ip != null and ip != ''\">"+ "and ip = #{ip} " + "</if>" + 
		  		  "<if test=\"agent != null and agent != ''\">"+ "and agent = #{agent} " + "</if>" + 
		  		  "<if test=\"content != null and content != ''\">"+ "and content = #{content} " + "</if>" + 
		  		  "<if test=\"type != null and type != ''\">"+ "and type = #{type} " + "</if>" + 
		  		  "<if test=\"status != null and status != ''\">"+ "and status = #{status} " + "</if>" + 
		  		  "<if test=\"parent != null and parent != ''\">"+ "and parent = #{parent} " + "</if>" + 
		  			"</where>"+ 
			"</script>")
	int count(Map<String,Object> map);
	
	@Insert("insert into b_comments (`created`, `title`, `author`, `author_id`, `owner_id`, `email`, `url`, `ip`, `agent`, `content`, `type`, `status`, `parent`)"
	+ "values (#{created}, #{title}, #{author}, #{authorId}, #{ownerId}, #{email}, #{url}, #{ip}, #{agent}, #{content}, #{type}, #{status}, #{parent})")
	int save(BCommentsDO bComments);
	
	@Update("<script>"+ 
			"update b_comments " + 
					"<set>" + 
		            "<if test=\"id != null\">`id` = #{id}, </if>" + 
                    "<if test=\"created != null\">`created` = #{created}, </if>" + 
                    "<if test=\"title != null\">`title` = #{title}, </if>" + 
                    "<if test=\"author != null\">`author` = #{author}, </if>" + 
                    "<if test=\"authorId != null\">`author_id` = #{authorId}, </if>" + 
                    "<if test=\"ownerId != null\">`owner_id` = #{ownerId}, </if>" + 
                    "<if test=\"email != null\">`email` = #{email}, </if>" + 
                    "<if test=\"url != null\">`url` = #{url}, </if>" + 
                    "<if test=\"ip != null\">`ip` = #{ip}, </if>" + 
                    "<if test=\"agent != null\">`agent` = #{agent}, </if>" + 
                    "<if test=\"content != null\">`content` = #{content}, </if>" + 
                    "<if test=\"type != null\">`type` = #{type}, </if>" + 
                    "<if test=\"status != null\">`status` = #{status}, </if>" + 
                    "<if test=\"parent != null\">`parent` = #{parent}, </if>" + 
          					"</set>" + 
					"where id = #{id}"+
			"</script>")
	int update(BCommentsDO bComments);
	
	@Delete("delete from b_comments where id =#{id}")
	int remove(Integer id);
	
	@Delete("<script>"+ 
			"delete from b_comments where id in " + 
					"<foreach item=\"id\" collection=\"array\" open=\"(\" separator=\",\" close=\")\">" + 
						"#{id}" + 
					"</foreach>"+
			"</script>")
	int batchRemove(Integer[] ids);
}
最近下载更多
shuangfu  LV25 2024年5月7日
大白兔奶糖  LV2 2023年7月11日
森sdfgf  LV8 2023年6月14日
啥也不会ddd  LV1 2023年5月25日
an1127  LV3 2023年4月4日
lyws1986  LV17 2023年3月28日
liaozhenlei  LV8 2022年9月3日
刘亦菲9527  LV15 2022年7月21日
LLLLLL_77  LV2 2022年6月16日
1529860026  LV24 2022年6月1日
最近浏览更多
bluerstar  LV1 2024年10月23日
颜菜菜  LV2 2024年6月19日
计科一班  LV7 2024年6月19日
f22m1a2b2  LV17 2024年5月31日
shuangfu  LV25 2024年5月7日
wushui  LV1 2024年3月9日
zcwmmd  LV20 2024年1月4日
WBelong  LV8 2023年12月27日
fff2003  LV9 2023年12月21日
3334004690  LV10 2023年11月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友