ExcludeQueryWrapper.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.gyee.viewticket.comm.base;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
  4. import java.util.Collection;
  5. public class ExcludeQueryWrapper <T> extends QueryWrapper<T> {
  6. @Override
  7. public QueryWrapper<T> eq(boolean condition, String column, Object val) {
  8. condition = !ObjectUtils.isEmpty(val);
  9. return super.eq(condition, column, val);
  10. }
  11. @Override
  12. public QueryWrapper<T> in(boolean condition, String column, Collection<?> val) {
  13. condition = !(null == val || val.size() <= 0);
  14. // condition = !ObjectUtils.isEmpty(val);
  15. return super.in(condition, column, val);
  16. }
  17. @Override
  18. public QueryWrapper<T> ne(boolean condition, String column, Object val) {
  19. condition = !ObjectUtils.isEmpty(val);
  20. return super.ne(condition, column, val);
  21. }
  22. @Override
  23. public QueryWrapper<T> gt(boolean condition, String column, Object val) {
  24. condition = !ObjectUtils.isEmpty(val);
  25. return super.gt(condition, column, val);
  26. }
  27. @Override
  28. public QueryWrapper<T> ge(boolean condition, String column, Object val) {
  29. condition = !ObjectUtils.isEmpty(val);
  30. return super.ge(condition, column, val);
  31. }
  32. @Override
  33. public QueryWrapper<T> lt(boolean condition, String column, Object val) {
  34. condition = !ObjectUtils.isEmpty(val);
  35. return super.lt(condition, column, val);
  36. }
  37. @Override
  38. public QueryWrapper<T> le(boolean condition, String column, Object val) {
  39. condition = !ObjectUtils.isEmpty(val);
  40. return super.le(condition, column, val);
  41. }
  42. @Override
  43. public QueryWrapper<T> like(boolean condition, String column, Object val) {
  44. condition = !ObjectUtils.isEmpty(val);
  45. return super.like(condition, column, val);
  46. }
  47. @Override
  48. public QueryWrapper<T> notLike(boolean condition, String column, Object val) {
  49. condition = !ObjectUtils.isEmpty(val);
  50. return super.notLike(condition, column, val);
  51. }
  52. @Override
  53. public QueryWrapper<T> likeLeft(boolean condition, String column, Object val) {
  54. condition = !ObjectUtils.isEmpty(val);
  55. return super.likeLeft(condition, column, val);
  56. }
  57. @Override
  58. public QueryWrapper<T> likeRight(boolean condition, String column, Object val) {
  59. condition = !ObjectUtils.isEmpty(val);
  60. return super.likeRight(condition, column, val);
  61. }
  62. @Override
  63. public QueryWrapper<T> between(boolean condition, String column, Object val1, Object val2) {
  64. if (ObjectUtils.isEmpty(val1) && ObjectUtils.isEmpty(val2)) {
  65. condition = false;
  66. } else if (ObjectUtils.isEmpty(val1)) {
  67. return super.lt(true, column, val2);
  68. } else if (ObjectUtils.isEmpty(val2)) {
  69. return super.ge(true, column, val1);
  70. }
  71. return super.between(condition, column, val1, val2);
  72. }
  73. @Override
  74. public QueryWrapper<T> notBetween(boolean condition, String column, Object val1, Object val2) {
  75. if (ObjectUtils.isEmpty(val1) && ObjectUtils.isEmpty(val2)) {
  76. condition = false;
  77. } else if (ObjectUtils.isEmpty(val1)) {
  78. return super.lt(true, column, val2);
  79. } else if (ObjectUtils.isEmpty(val2)) {
  80. return super.ge(true, column, val1);
  81. }
  82. return super.notBetween(condition, column, val1, val2);
  83. }
  84. }