DepartmentUserQueryRequest.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.malk.minglei.dto;
  2. import com.fasterxml.jackson.annotation.JsonProperty;
  3. import javax.validation.constraints.NotBlank;
  4. import javax.validation.constraints.Max;
  5. import javax.validation.constraints.Min;
  6. import javax.validation.constraints.NotNull;
  7. import javax.validation.constraints.Pattern;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. /**
  11. * 按部门查询钉钉成员的请求模型。
  12. */
  13. public class DepartmentUserQueryRequest {
  14. @NotBlank
  15. @Pattern(regexp = "\\s*[1-9]\\d*\\s*(,\\s*[1-9]\\d*\\s*)*", message = "dept_Id must be comma-separated positive integers")
  16. @JsonProperty("dept_Id")
  17. private String departmentId;
  18. @NotNull
  19. @Min(value = 0, message = "type must be 0 or 1")
  20. @Max(value = 1, message = "type must be 0 or 1")
  21. private Integer type;
  22. public List<Long> getDepartmentIds() {
  23. List<Long> departmentIds = new ArrayList<Long>();
  24. for (String value : departmentId.split(",")) {
  25. departmentIds.add(Long.parseLong(value.trim()));
  26. }
  27. return departmentIds;
  28. }
  29. public void setDepartmentId(String departmentId) {
  30. this.departmentId = departmentId;
  31. }
  32. /**
  33. * 返回部门查询范围:0 表示包含子部门,1 表示仅当前部门。
  34. *
  35. * @return 部门查询范围标识
  36. */
  37. public int getType() {
  38. return type;
  39. }
  40. /**
  41. * 设置部门查询范围,由请求体中的 type 字段绑定。
  42. *
  43. * @param type 0 表示包含子部门,1 表示仅当前部门
  44. */
  45. public void setType(Integer type) {
  46. this.type = type;
  47. }
  48. }