CrudDao.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
  3. */
  4. package com.jeeplus.common.persistence;
  5. import java.util.List;
  6. import org.apache.ibatis.annotations.Param;
  7. /**
  8. * DAO支持类实现
  9. * @author jeeplus
  10. * @version 2014-05-16
  11. * @param <T>
  12. */
  13. public interface CrudDao<T> extends BaseDao {
  14. /**
  15. * 获取单条数据
  16. * @param id
  17. * @return
  18. */
  19. public T get(String id);
  20. /**
  21. * 获取单条数据
  22. * @param entity
  23. * @return
  24. */
  25. public T get(T entity);
  26. /**
  27. * 根据实体名称和字段名称和字段值获取唯一记录
  28. *
  29. * @param <T>
  30. * @param entityClass
  31. * @param propertyName
  32. * @param value
  33. * @return
  34. */
  35. public T findUniqueByProperty(@Param(value="propertyName")String propertyName, @Param(value="value")Object value);
  36. /**
  37. * 查询数据列表,如果需要分页,请设置分页对象,如:entity.setPage(new Page<T>());
  38. * @param entity
  39. * @return
  40. */
  41. public List<T> findList(T entity);
  42. /**
  43. * 查询数据列表,针对普通用户,普通用户只能查看自己的记录
  44. * @param entity
  45. * @return
  46. */
  47. public List<T> findListByUser(T entity);
  48. /**
  49. * 查询所有数据列表
  50. * @param entity
  51. * @return
  52. */
  53. public List<T> findAllList(T entity);
  54. /**
  55. * 查询所有数据列表
  56. * @see public List<T> findAllList(T entity)
  57. * @return
  58. */
  59. @Deprecated
  60. public List<T> findAllList();
  61. /**
  62. * 插入数据
  63. * @param entity
  64. * @return
  65. */
  66. public int insert(T entity);
  67. /**
  68. * 更新数据
  69. * @param entity
  70. * @return
  71. */
  72. public int update(T entity);
  73. /**
  74. * 删除数据(物理删除,从数据库中彻底删除)
  75. * @param id
  76. * @see public int delete(T entity)
  77. * @return
  78. */
  79. @Deprecated
  80. public int delete(String id);
  81. /**
  82. * 删除数据(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
  83. * @param id
  84. * @see public int delete(T entity)
  85. * @return
  86. */
  87. @Deprecated
  88. public int deleteByLogic(String id);
  89. /**
  90. * 删除数据(物理删除,从数据库中彻底删除)
  91. * @param entity
  92. * @return
  93. */
  94. public int delete(T entity);
  95. /**
  96. * 删除数据(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
  97. * @param entity
  98. * @return
  99. */
  100. public int deleteByLogic(T entity);
  101. }