TableField.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * Copyright (c) 2011-2020, hubin (jobob@qq.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. * <p>
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.baomidou.mybatisplus.annotation;
  17. import java.lang.annotation.Documented;
  18. import java.lang.annotation.ElementType;
  19. import java.lang.annotation.Retention;
  20. import java.lang.annotation.RetentionPolicy;
  21. import java.lang.annotation.Target;
  22. /**
  23. * <p>
  24. * 表字段标识
  25. * </p>
  26. *
  27. * @author hubin sjy tantan
  28. * @since 2016-09-09
  29. */
  30. @Documented
  31. @Retention(RetentionPolicy.RUNTIME)
  32. @Target(ElementType.FIELD)
  33. public @interface TableField {
  34. /**
  35. * <p>
  36. * 字段值(驼峰命名方式,该值可无)
  37. * </p>
  38. */
  39. String value() default "";
  40. /**
  41. * <p>
  42. * 当该Field为类对象时, 可使用#{对象.属性}来映射到数据表.
  43. * </p>
  44. * <p>
  45. * 支持:@TableField(el = "role, jdbcType=BIGINT)<br>
  46. * 支持:@TableField(el = "role, typeHandler=com.baomidou.springcloud.typehandler.PhoneTypeHandler")
  47. * </p>
  48. */
  49. String el() default "";
  50. /**
  51. * <p>
  52. * 是否为数据库表字段
  53. * </p>
  54. * <p>
  55. * 默认 true 存在,false 不存在
  56. * </p>
  57. */
  58. boolean exist() default true;
  59. /**
  60. * <p>
  61. * 字段 where 实体查询比较条件
  62. * </p>
  63. * <p>
  64. * 默认 `=` 等值
  65. * </p>
  66. */
  67. String condition() default SqlCondition.EQUAL;
  68. /**
  69. * <p>
  70. * 字段 update set 部分注入, 该注解优于 el 注解使用
  71. * </p>
  72. * <p>
  73. * 例如:@TableField(.. , update="%s+1") 其中 %s 会填充为字段
  74. * 输出 SQL 为:update 表 set 字段=字段+1 where ...
  75. * </p>
  76. * <p>
  77. * 例如:@TableField(.. , update="now()") 使用数据库时间
  78. * 输出 SQL 为:update 表 set 字段=now() where ...
  79. * </p>
  80. */
  81. String update() default "";
  82. /**
  83. * <p>
  84. * 字段验证策略
  85. * </p>
  86. * <p>
  87. * 默认 非 null 判断
  88. * </p>
  89. */
  90. FieldStrategy strategy() default FieldStrategy.NOT_NULL;
  91. /**
  92. * <p>
  93. * 字段自动填充策略
  94. * </p>
  95. */
  96. FieldFill fill() default FieldFill.DEFAULT;
  97. }