Dept.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 2019-2020 Zheng Jie
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package me.zhengjie.modules.system.domain;
  17. import com.alibaba.fastjson.annotation.JSONField;
  18. import io.swagger.annotations.ApiModelProperty;
  19. import lombok.Getter;
  20. import lombok.Setter;
  21. import me.zhengjie.base.BaseEntity;
  22. import javax.persistence.*;
  23. import javax.validation.constraints.NotBlank;
  24. import javax.validation.constraints.NotNull;
  25. import java.io.Serializable;
  26. import java.util.Objects;
  27. import java.util.Set;
  28. /**
  29. * @author Zheng Jie
  30. * @date 2019-03-25
  31. */
  32. @Entity
  33. @Getter
  34. @Setter
  35. @Table(name="sys_dept")
  36. public class Dept extends BaseEntity implements Serializable {
  37. @Id
  38. @Column(name = "dept_id")
  39. @NotNull(groups = Update.class)
  40. @ApiModelProperty(value = "ID", hidden = true)
  41. private String id;
  42. @JSONField(serialize = false)
  43. @ManyToMany(mappedBy = "depts")
  44. @ApiModelProperty(value = "角色")
  45. private Set<Role> roles;
  46. @ApiModelProperty(value = "排序")
  47. private Integer deptSort;
  48. @Column(name = "dept_type")
  49. @ApiModelProperty(value = "部门类型")
  50. private Integer deptType;
  51. @Column(name = "tree_names")
  52. @ApiModelProperty(value = "树形目录名称")
  53. private String treeNames;
  54. @Column(name = "tree_ids")
  55. @ApiModelProperty(value = "树形目录编号")
  56. private String treeIds;
  57. @NotBlank
  58. @ApiModelProperty(value = "部门名称")
  59. private String name;
  60. @ApiModelProperty(value = "部门描述")
  61. private String description;
  62. @ApiModelProperty(value = "部门备注")
  63. private String remark;
  64. @NotNull
  65. @ApiModelProperty(value = "是否启用")
  66. private Boolean enabled;
  67. @ApiModelProperty(value = "上级部门")
  68. private String pid;
  69. @ApiModelProperty(value = "子节点数目", hidden = true)
  70. private Integer subCount = 0;
  71. @Override
  72. public boolean equals(Object o) {
  73. if (this == o) {
  74. return true;
  75. }
  76. if (o == null || getClass() != o.getClass()) {
  77. return false;
  78. }
  79. Dept dept = (Dept) o;
  80. return Objects.equals(id, dept.id) &&
  81. Objects.equals(name, dept.name);
  82. }
  83. @Override
  84. public int hashCode() {
  85. return Objects.hash(id, name);
  86. }
  87. }