Menu.java 1.8 KB
Newer Older
1
package me.zhengjie.modules.system.domain;
郑杰 已提交
2

3
import com.fasterxml.jackson.annotation.JsonIgnore;
郑杰 已提交
4 5 6 7 8
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
9 10
import javax.validation.constraints.NotNull;
import java.io.Serializable;
郑杰 已提交
11
import java.sql.Timestamp;
12
import java.util.Objects;
郑杰 已提交
13 14 15
import java.util.Set;

/**
16
 * @author Zheng Jie
郑杰 已提交
17 18 19 20 21 22
 * @date 2018-12-17
 */
@Entity
@Getter
@Setter
@Table(name = "menu")
23
public class Menu implements Serializable {
郑杰 已提交
24 25 26

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
27
    @NotNull(groups = {Update.class})
郑杰 已提交
28 29 30 31 32 33
    private Long id;

    @NotBlank
    private String name;

    @Column(unique = true)
34
    @NotNull
35
    private Long sort;
郑杰 已提交
36

37
    @NotBlank
郑杰 已提交
38 39 40 41 42
    @Column(name = "path")
    private String path;

    private String component;

43
    @Column(unique = true,name = "component_name")
44 45
    private String componentName;

郑杰 已提交
46 47
    private String icon;

48 49 50 51 52 53
    @Column(columnDefinition = "bit(1) default 0")
    private Boolean cache;

    @Column(columnDefinition = "bit(1) default 0")
    private Boolean hidden;

郑杰 已提交
54 55 56 57 58 59 60 61 62
    /**
     * 上级菜单ID
     */
    @Column(name = "pid",nullable = false)
    private Long pid;

    /**
     * 是否为外链 true/false
     */
63
    @Column(name = "i_frame")
郑杰 已提交
64 65
    private Boolean iFrame;

66 67
    @ManyToMany(mappedBy = "menus")
    @JsonIgnore
郑杰 已提交
68 69 70
    private Set<Role> roles;

    @CreationTimestamp
71
    @Column(name = "create_time")
郑杰 已提交
72
    private Timestamp createTime;
73 74

    public interface Update{}
75 76 77 78 79 80 81 82 83 84 85 86 87

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Menu menu = (Menu) o;
        return Objects.equals(id, menu.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
郑杰 已提交
88
}