好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Mybatis-plus使用注解 @TableField(exist = false)

当表中午字段,但是实体类中需要这个成员变量时怎么办,可以使用mybatis-plus中@TableField(exist=false)

如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

import com.baomidou.mybatisplus.annotation.TableField;

import com.baomidou.mybatisplus.annotation.TableId;

import com.baomidou.mybatisplus.annotation.TableLogic;

import com.baomidou.mybatisplus.annotation.TableName;

 

import java.io.Serializable;

import java.util.Date;

import java.util.List;

 

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Data;

 

/**

  * 商品三级分类

  *

  * @author yuhl

  * @email fsjwin@163测试数据

  * @date 2020-09-04 14:12:07

  */

@Data

@TableName ( "pms_category" )

public class CategoryEntity implements Serializable {

  private static final long serialVersionUID = 1L;

 

  /**

  * 分类id

  */

  @TableId

  private Long catId;

  /**

  * 分类名称

  */

  private String name;

  /**

  * 父分类id

  */

  private Long parentCid;

  /**

  * 层级

  */

  private Integer catLevel;

  /**

  * 是否显示[0-不显示,1显示]

  */

  @TableLogic (value = "1" ,delval = "0" )

  private Integer showStatus;

  /**

  * 排序

  */

  private Integer sort;

  /**

  * 图标地址

  */

  private String icon;

  /**

  * 计量单位

  */

  private String productUnit;

  /**

  * 商品数量

  */

  private Integer productCount;

 

  @JsonInclude (JsonInclude.Include.NON_EMPTY) //children不为空则显示,要不然就不展示了。解决了,树下没有子树但是会有个空白的占位的情况

  @TableField (exist= false ) //树形展示用的,表中无此字段标识表中无次字段

  private List<CategoryEntity> children;

}

@TableField(exist=false) //树形展示用的,表中无此字段标识表中无次字段即为此用法

注意: @JsonInclude(JsonInclude.Include.NON_EMPTY) //children不为空则显示,要不然就不展示了。解决了,树下没有子树但是会有个空白的占位的情况

到此这篇关于Mybatis-plus使用注解 @TableField(exist = false)的文章就介绍到这了,更多相关Mybatis-plus @TableField(exist = false) 内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

原文链接:https://blog.csdn.net/fsjwin/article/details/114707236

查看更多关于Mybatis-plus使用注解 @TableField(exist = false)的详细内容...

  阅读:21次