daoSubClass.ftl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package ${daoPackage};
  2. import java.util.List;
  3. import org.jeecgframework.minidao.annotation.Param;
  4. import org.jeecgframework.minidao.annotation.ResultType;
  5. import org.jeecgframework.minidao.annotation.Sql;
  6. import org.jeecgframework.minidao.pojo.MiniDaoPage;
  7. import org.springframework.stereotype.Repository;
  8. import ${domainPackage}.${className}Entity;
  9. /**
  10. * 描述:${codeName}
  11. * @author:${author}
  12. * @since:${nowDate}
  13. * @version:1.0
  14. */
  15. @Repository
  16. public interface ${className}Dao{
  17. /**
  18. * 查询返回Java对象
  19. * @param id
  20. * @return
  21. */
  22. @Sql("SELECT * FROM ${tableName} WHERE ID = :id")
  23. ${className}Entity get(@Param("id") String id);
  24. /**
  25. * 修改数据
  26. * @param ${lowerName}
  27. * @return
  28. */
  29. int update(@Param("${lowerName}") ${className}Entity ${lowerName});
  30. /**
  31. * 插入数据
  32. * @param act
  33. */
  34. void insert(@Param("${lowerName}") ${className}Entity ${lowerName});
  35. /**
  36. * 通用分页方法,支持(oracle、mysql、SqlServer、postgresql)
  37. * @param ${lowerName}
  38. * @param page
  39. * @param rows
  40. * @return
  41. */
  42. @ResultType(${className}Entity.class)
  43. public MiniDaoPage<${className}Entity> getAll(@Param("${lowerName}") ${className}Entity ${lowerName},@Param("page") int page,@Param("rows") int rows);
  44. @Sql("DELETE from ${tableName} WHERE ID = :${lowerName}.id")
  45. public void delete(@Param("${lowerName}") ${className}Entity ${lowerName});
  46. @Sql("select * from ${tableName} WHERE ${foreignKeyTable} = :${foreignKey}")
  47. List<${className}Entity> getBy${foreignKeyUpper}(@Param("${foreignKey}") String ${foreignKey});
  48. @Sql("update ${tableName} set DELFLAG = 1, DEL_DT = now() where ${foreignKeyTable} = :${foreignKey}")
  49. void delBy${foreignKeyUpper}(@Param("${foreignKey}") String ${foreignKey});
  50. @Sql("select count(id) from ${tableName} WHERE ${foreignKeyTable} = :${foreignKey}")
  51. int getCountBy${foreignKeyUpper}(@Param("${foreignKey}") String ${foreignKey});
  52. @Sql("delete from ${tableName} WHERE ${foreignKeyTable} = :${foreignKey}")
  53. void deleteBy${foreignKeyUpper}(@Param("${foreignKey}") String ${foreignKey});
  54. }