KeycloakUserCO.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.inspur.customer.object.keycloak;
  2. import com.fasterxml.jackson.annotation.JsonIgnore;
  3. import lombok.Data;
  4. import org.apache.commons.lang3.StringUtils;
  5. import org.springframework.lang.Nullable;
  6. import java.io.Serializable;
  7. import java.util.BitSet;
  8. import java.util.List;
  9. /**
  10. * keycloak user
  11. * @author linwenhua
  12. * @date 2022-06-14 16:54
  13. **/
  14. @Data
  15. public class KeycloakUserCO implements Serializable {
  16. private static final long serialVersionUID = 6869360605249346844L;
  17. private String id;
  18. private String username;
  19. private String phone;
  20. private String email;
  21. private String wechat;
  22. private String wechatAppletOpenId;
  23. public void setPhone(@Nullable List<String> phones) {
  24. if (phones != null && !phones.isEmpty()) {
  25. phone = phones.get(0);
  26. }
  27. }
  28. public void setWechat(@Nullable List<String> wechats) {
  29. if (wechats != null && !wechats.isEmpty()) {
  30. String temp = wechats.get(0);
  31. if (!temp.contains("{\"")) {
  32. wechat = temp;
  33. }
  34. }
  35. }
  36. public void setWechatApplet(@Nullable List<String> wechatApplets) {
  37. if (wechatApplets != null && !wechatApplets.isEmpty()) {
  38. String temp = wechatApplets.get(0);
  39. if (!temp.contains("{\"")) {
  40. wechatAppletOpenId = temp;
  41. }
  42. }
  43. }
  44. @JsonIgnore
  45. public BitSet getInformFlag() {
  46. BitSet bitSet = new BitSet(4);
  47. if (StringUtils.isNotBlank(phone)) {
  48. bitSet.set(0);
  49. }
  50. if (StringUtils.isNotBlank(email)) {
  51. bitSet.set(1);
  52. }
  53. if (StringUtils.isNotBlank(wechat)) {
  54. bitSet.set(2);
  55. }
  56. if (StringUtils.isNotBlank(wechatAppletOpenId)) {
  57. bitSet.set(3);
  58. }
  59. return bitSet;
  60. }
  61. }