modify dao for open_source_projects

This commit is contained in:
ronger 2016-11-17 19:07:47 +08:00
parent f589be8e74
commit e508eb3e64
1 changed files with 56 additions and 56 deletions

View File

@ -1,57 +1,57 @@
package com.ossean.databaseDest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.ossean.model.OpenSourceProject;
import com.ossean.model.Taggings;
public interface DBDest {
//删除open_source_projects表中对应id的数据
@Delete("delete from ${table} where id=#{id}")
public void deleteOpenSourceProjectsItem(@Param("table") String table, @Param("id") int id);
//查找open_source_projects表对应id的记录
@Select("select * from ${table} where id=#{id}")
public OpenSourceProject selectOpenSourceProjectsItem(@Param("table") String table, @Param("id") int id);
/**
* 下面是transferProjects程序的函数
*/
//向open_source_projects表中插入对象数据
@Insert("insert into ${table} (id,name,description,"
+ "url,language,category,"
+ "source,created_time,updated_time,"
+ "tags,tags_for_search,synonyms,update_mark) values (#{model.id},#{model.name},#{model.description},"
+ "#{model.url},,#{model.language},"
+ "#{model.category},#{model.source},"
+ "#{model.created_time},#{model.updated_time},#{model.tags},"
+ "#{model.tags_for_search},#{model.synonyms},#{model.update_mark})")
public void insertOsp(@Param("table") String table, @Param("model") OpenSourceProject model);
//查找刚刚插入open_source_projects表中的记录id
@Select("select id from ${table} where name=#{model.name} order by id desc limit 1")
public int getAutoIncrementOspId(@Param("table") String table, @Param("model") OpenSourceProject model);
//插入tag
@Insert("insert ignore into ${table} (name) values (#{name})")
public void insertTag(@Param("table") String table, @Param("name") String name);
//根据tag name查找id
@Select("select id from ${table} where name=#{name}")
public int selectTagIdByName(@Param("table") String table, @Param("name") String name);
//插入tagging
@Insert("insert ignore into ${table} (tag_id,taggable_id,taggable_type,context,created_at,disagree_num) values (#{model.tag_id},#{model.taggable_id},#{model.taggable_type},#{model.context},#{model.created_at},#{model.disagree_num})")
public void insertTagging(@Param("table") String table, @Param("model") Taggings model);
//删除对应ospId的匹配结果
@Delete("delete from ${table} where osp_id = ${ospId}")
public void deleteMatchResult(@Param("ospId") int ospId, @Param("table") String table);
package com.ossean.databaseDest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.ossean.model.OpenSourceProject;
import com.ossean.model.Taggings;
public interface DBDest {
//删除open_source_projects表中对应id的数据
@Delete("delete from ${table} where id=#{id}")
public void deleteOpenSourceProjectsItem(@Param("table") String table, @Param("id") int id);
//查找open_source_projects表对应id的记录
@Select("select * from ${table} where id=#{id}")
public OpenSourceProject selectOpenSourceProjectsItem(@Param("table") String table, @Param("id") int id);
/**
* 下面是transferProjects程序的函数
*/
//向open_source_projects表中插入对象数据
@Insert("insert into ${table} (id,name,description,"
+ "url,url_md5,language,category,homepage,license"
+ "source,created_time,updated_time,extracted_time"
+ "tags,tags_for_search,synonyms,update_mark) values (#{model.id},#{model.name},#{model.description},"
+ "#{model.url},#{model.url_md5},#{model.language},"
+ "#{model.category},#{model.homepage},#{model.license},#{model.source},"
+ "#{model.created_time},#{model.updated_time},#{model.extracted_time},#{model.tags},"
+ "#{model.tags_for_search},#{model.synonyms},#{model.update_mark})")
public void insertOsp(@Param("table") String table, @Param("model") OpenSourceProject model);
//查找刚刚插入open_source_projects表中的记录id
@Select("select id from ${table} where name=#{model.name} order by id desc limit 1")
public int getAutoIncrementOspId(@Param("table") String table, @Param("model") OpenSourceProject model);
//插入tag
@Insert("insert ignore into ${table} (name) values (#{name})")
public void insertTag(@Param("table") String table, @Param("name") String name);
//根据tag name查找id
@Select("select id from ${table} where name=#{name}")
public int selectTagIdByName(@Param("table") String table, @Param("name") String name);
//插入tagging
@Insert("insert ignore into ${table} (tag_id,taggable_id,taggable_type,context,created_at,disagree_num) values (#{model.tag_id},#{model.taggable_id},#{model.taggable_type},#{model.context},#{model.created_at},#{model.disagree_num})")
public void insertTagging(@Param("table") String table, @Param("model") Taggings model);
//删除对应ospId的匹配结果
@Delete("delete from ${table} where osp_id = ${ospId}")
public void deleteMatchResult(@Param("ospId") int ospId, @Param("table") String table);
}