Userspace.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. package com.uas.sso.entity;
  2. import com.alibaba.fastjson.annotation.JSONField;
  3. import java.io.Serializable;
  4. import java.sql.Timestamp;
  5. import java.util.List;
  6. import java.util.Optional;
  7. import javax.persistence.*;
  8. import com.uas.sso.core.Const;
  9. import org.codehaus.jackson.annotate.JsonIgnore;
  10. import org.hibernate.annotations.Cache;
  11. import org.hibernate.annotations.CacheConcurrencyStrategy;
  12. /**
  13. * 企业实体
  14. *
  15. * @author wangmh
  16. * @date 2018/1/4
  17. */
  18. @Entity
  19. @Table(name = "sso$userspace")
  20. @Cacheable
  21. @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "UserSpaceCache")
  22. public class Userspace implements Serializable {
  23. /**
  24. *
  25. */
  26. private static final long serialVersionUID = 1L;
  27. /**
  28. * 企业uu号
  29. */
  30. @Id
  31. @Column(name = "spaceuu")
  32. private Long spaceUU;
  33. /**
  34. * 企业名称
  35. */
  36. @Column(name = "space_name", nullable = false, unique = true, length = 99)
  37. private String spaceName;
  38. /**
  39. * 法定代表人
  40. */
  41. @Column(name = "corporation", length = 20)
  42. private String corporation;
  43. /**
  44. * 注册日期
  45. */
  46. @Column(name = "space_register_date")
  47. private Timestamp registerDate;
  48. /**
  49. * 注册来源
  50. */
  51. @Column(name = "from_app")
  52. private String fromApp;
  53. /**
  54. * 管理员uu号
  55. */
  56. @Column(name = "adminuu")
  57. private Long adminUU;
  58. /**
  59. * 管理员
  60. */
  61. @ManyToOne
  62. @JoinColumn(name = "adminuu", insertable=false, updatable=false)
  63. private User admin;
  64. /**
  65. * 营业执照号
  66. */
  67. @Column(name = "business_code", unique = true, length = 100)
  68. private String businessCode;
  69. /**
  70. * 营业执照
  71. */
  72. @Column(name = "business_code_image")
  73. private String businessCodeImage;
  74. /**
  75. * 注册地址
  76. */
  77. @Column(name = "reg_address")
  78. private String regAddress;
  79. /**
  80. * 注册地址所在省份、州、直辖市、行政区
  81. */
  82. @Column(name = "reg_province", length = 50)
  83. private String regProvince;
  84. /**
  85. * 注册地址所在城市
  86. */
  87. @Column(name = "reg_city", length = 50)
  88. private String regCity;
  89. /**
  90. * 注册地址所在区域
  91. */
  92. @Column(name = "reg_district", length = 50)
  93. private String regDistrict;
  94. /**
  95. * 注册地址所在街道
  96. */
  97. @Column(name = "reg_street", length = 200)
  98. private String regStreet;
  99. /**
  100. * 公司地址经度
  101. */
  102. @Column(name = "company_longitude", length = 50)
  103. private String companyLongitude;
  104. /**
  105. * 公司地址纬度
  106. */
  107. @Column(name = "company_latitude", length = 50)
  108. private String companyLatitude;
  109. /**
  110. * 公司所在国家
  111. */
  112. @Column(name = "company_country", length = 50)
  113. private String companyCountry;
  114. /**
  115. * 公司所在省份、州、直辖市、行政区
  116. */
  117. @Column(name = "company_province", length = 50)
  118. private String companyProvince;
  119. /**
  120. * 公司所在城市
  121. */
  122. @Column(name = "company_city")
  123. private String companyCity;
  124. /**
  125. * 公司地址
  126. */
  127. @Column(name = "company_address")
  128. private String companyAddress;
  129. /**
  130. * 企业信息认证状态
  131. */
  132. @Column(name = "valid_code", nullable = false)
  133. private Short validCode;
  134. /**
  135. * logo图片
  136. */
  137. @Column(name = "logo_image")
  138. private String logoImage;
  139. /**
  140. * 企业联系电话
  141. */
  142. @Column(name = "telephone", length = 20)
  143. private String telephone;
  144. /**
  145. * 主营业务范围
  146. */
  147. @Column(name = "main_business")
  148. private String mainBusiness;
  149. /**
  150. * 对公银行账户
  151. */
  152. @Column(name = "bank_account")
  153. private String bankAccount;
  154. /**
  155. * 对公银行账户开户行
  156. */
  157. @Column(name = "bank")
  158. private String bank;
  159. /**
  160. * 企业域名
  161. */
  162. @Column(name = "domain")
  163. private String domain;
  164. /**
  165. * 行业
  166. */
  167. @Column(name = "profession")
  168. private String profession;
  169. /**
  170. * 经营范围标签,逗号分隔
  171. */
  172. @Column(name = "tags")
  173. private String tags;
  174. /**
  175. * 企业注册地区
  176. */
  177. @Column(name = "area")
  178. private String area;
  179. /**
  180. * 邀请人企业uu号
  181. */
  182. @Column(name = "invite_space_uu")
  183. private Long inviteSpaceUU;
  184. /**
  185. * 邀请人uu号
  186. */
  187. @Column(name = "invite_user_uu")
  188. private Long inviteUserUU;
  189. /**
  190. * 邀请来源
  191. */
  192. @Column(name = "source", length = 30)
  193. private String source;
  194. /**
  195. * 企业秘钥
  196. */
  197. @com.fasterxml.jackson.annotation.JsonIgnore
  198. @Column(name = "access_secret")
  199. private String accessSecret;
  200. /**
  201. * 企业对应erp的地址
  202. */
  203. @Column(name = "website")
  204. private String website;
  205. /**
  206. * 企业下的用户
  207. */
  208. @com.fasterxml.jackson.annotation.JsonIgnore
  209. @ManyToMany
  210. @JoinTable(name = "sso$user_userspace",
  211. joinColumns = {@JoinColumn(name="space_uu", referencedColumnName="spaceuu")},
  212. inverseJoinColumns = {@JoinColumn(name="user_uu", referencedColumnName="useruu")})
  213. private List<User> users;
  214. /**
  215. * 企业开通的应用
  216. */
  217. @ManyToMany(fetch = FetchType.LAZY)
  218. @JoinTable(name = "sso$app_userspace",
  219. joinColumns = {@JoinColumn(name="space_uu", referencedColumnName="spaceuu")},
  220. inverseJoinColumns = {@JoinColumn(name="app_uid", referencedColumnName="uid_")})
  221. private List<App> apps;
  222. public Userspace() {
  223. }
  224. public Userspace(Long spaceUU) {
  225. this.spaceUU = spaceUU;
  226. }
  227. public Userspace(String spaceName) {
  228. this.spaceName = spaceName;
  229. }
  230. public Long getSpaceUU() {
  231. return spaceUU;
  232. }
  233. public void setSpaceUU(Long spaceUU) {
  234. this.spaceUU = spaceUU;
  235. }
  236. public String getSpaceName() {
  237. if (spaceName != null && spaceName.contains(Const.REPEAT_SEPARATOR)) {
  238. return spaceName.substring(0, spaceName.indexOf(Const.REPEAT_SEPARATOR));
  239. }
  240. return spaceName;
  241. }
  242. public void setSpaceName(String spaceName) {
  243. this.spaceName = spaceName;
  244. }
  245. public String getCorporation() {
  246. return corporation;
  247. }
  248. public void setCorporation(String corporation) {
  249. this.corporation = corporation;
  250. }
  251. public Timestamp getRegisterDate() {
  252. return registerDate;
  253. }
  254. public void setRegisterDate(Timestamp registerDate) {
  255. this.registerDate = registerDate;
  256. }
  257. public String getFromApp() {
  258. return fromApp;
  259. }
  260. public void setFromApp(String fromApp) {
  261. this.fromApp = fromApp;
  262. }
  263. public Long getAdminUU() {
  264. return adminUU;
  265. }
  266. public void setAdminUU(Long adminUU) {
  267. this.adminUU = adminUU;
  268. }
  269. public User getAdmin() {
  270. return admin;
  271. }
  272. public void setAdmin(User admin) {
  273. this.admin = admin;
  274. }
  275. public String getBusinessCode() {
  276. if (businessCode != null && businessCode.contains(Const.REPEAT_SEPARATOR)) {
  277. return businessCode.substring(0, businessCode.indexOf(Const.REPEAT_SEPARATOR));
  278. }
  279. return businessCode;
  280. }
  281. public void setBusinessCode(String businessCode) {
  282. this.businessCode = businessCode;
  283. }
  284. public String getBusinessCodeImage() {
  285. return businessCodeImage;
  286. }
  287. public void setBusinessCodeImage(String businessCodeImage) {
  288. this.businessCodeImage = businessCodeImage;
  289. }
  290. public String getRegAddress() {
  291. return regAddress;
  292. }
  293. public void setRegAddress(String regAddress) {
  294. this.regAddress = regAddress;
  295. }
  296. public String getRegProvince() {
  297. return regProvince;
  298. }
  299. public void setRegProvince(String regProvince) {
  300. this.regProvince = regProvince;
  301. }
  302. public String getRegCity() {
  303. return regCity;
  304. }
  305. public void setRegCity(String regCity) {
  306. this.regCity = regCity;
  307. }
  308. public String getRegDistrict() {
  309. return regDistrict;
  310. }
  311. public void setRegDistrict(String regDistrict) {
  312. this.regDistrict = regDistrict;
  313. }
  314. public String getRegStreet() {
  315. return regStreet;
  316. }
  317. public void setRegStreet(String regStreet) {
  318. this.regStreet = regStreet;
  319. }
  320. public String getCompanyLongitude() {
  321. return companyLongitude;
  322. }
  323. public void setCompanyLongitude(String companyLongitude) {
  324. this.companyLongitude = companyLongitude;
  325. }
  326. public String getCompanyLatitude() {
  327. return companyLatitude;
  328. }
  329. public void setCompanyLatitude(String companyLatitude) {
  330. this.companyLatitude = companyLatitude;
  331. }
  332. public String getCompanyCountry() {
  333. return companyCountry;
  334. }
  335. public void setCompanyCountry(String companyCountry) {
  336. this.companyCountry = companyCountry;
  337. }
  338. public String getCompanyProvince() {
  339. return companyProvince;
  340. }
  341. public void setCompanyProvince(String companyProvince) {
  342. this.companyProvince = companyProvince;
  343. }
  344. public String getCompanyCity() {
  345. return companyCity;
  346. }
  347. public void setCompanyCity(String companyCity) {
  348. this.companyCity = companyCity;
  349. }
  350. public String getCompanyAddress() {
  351. return companyAddress;
  352. }
  353. public void setCompanyAddress(String companyAddress) {
  354. this.companyAddress = companyAddress;
  355. }
  356. public Short getValidCode() {
  357. return validCode;
  358. }
  359. public void setValidCode(Short validCode) {
  360. this.validCode = validCode;
  361. }
  362. public String getLogoImage() {
  363. return logoImage;
  364. }
  365. public void setLogoImage(String logoImage) {
  366. this.logoImage = logoImage;
  367. }
  368. public String getTelephone() {
  369. return telephone;
  370. }
  371. public void setTelephone(String telephone) {
  372. this.telephone = telephone;
  373. }
  374. public String getMainBusiness() {
  375. return mainBusiness;
  376. }
  377. public void setMainBusiness(String mainBusiness) {
  378. this.mainBusiness = mainBusiness;
  379. }
  380. public String getBankAccount() {
  381. return bankAccount;
  382. }
  383. public void setBankAccount(String bankAccount) {
  384. this.bankAccount = bankAccount;
  385. }
  386. public String getBank() {
  387. return bank;
  388. }
  389. public void setBank(String bank) {
  390. this.bank = bank;
  391. }
  392. public String getDomain() {
  393. return domain;
  394. }
  395. public void setDomain(String domain) {
  396. this.domain = domain;
  397. }
  398. @JsonIgnore
  399. @JSONField(serialize = false)
  400. public List<User> getUsers() {
  401. return users;
  402. }
  403. public void setUsers(List<User> users) {
  404. this.users = users;
  405. }
  406. @JsonIgnore
  407. @JSONField(serialize = false)
  408. public List<App> getApps() {
  409. return apps;
  410. }
  411. public void setApps(List<App> apps) {
  412. this.apps = apps;
  413. }
  414. public String getProfession() {
  415. return profession;
  416. }
  417. public void setProfession(String profession) {
  418. this.profession = profession;
  419. }
  420. public String getTags() {
  421. return tags;
  422. }
  423. public void setTags(String tags) {
  424. this.tags = tags;
  425. }
  426. public String getArea() {
  427. return area;
  428. }
  429. public void setArea(String area) {
  430. this.area = area;
  431. }
  432. public Long getInviteSpaceUU() {
  433. return inviteSpaceUU;
  434. }
  435. public void setInviteSpaceUU(Long inviteSpaceUU) {
  436. this.inviteSpaceUU = inviteSpaceUU;
  437. }
  438. public Long getInviteUserUU() {
  439. return inviteUserUU;
  440. }
  441. public void setInviteUserUU(Long inviteUserUU) {
  442. this.inviteUserUU = inviteUserUU;
  443. }
  444. public String getSource() {
  445. return source;
  446. }
  447. public void setSource(String source) {
  448. this.source = source;
  449. }
  450. @JsonIgnore
  451. @JSONField(serialize = false)
  452. public String getAccessSecret() {
  453. return accessSecret;
  454. }
  455. public void setAccessSecret(String accessSecret) {
  456. this.accessSecret = accessSecret;
  457. }
  458. public String getWebsite() {
  459. return website;
  460. }
  461. public void setWebsite(String website) {
  462. this.website = website;
  463. }
  464. /**
  465. * 将企业信息变成视图
  466. * @return
  467. */
  468. public UserSpaceView toView() {
  469. UserSpaceView userSpaceView = new UserSpaceView();
  470. userSpaceView.setSpaceUU(this.getSpaceUU());
  471. userSpaceView.setSpaceName(this.getSpaceName());
  472. userSpaceView.setCorporation(this.getCorporation());
  473. userSpaceView.setRegisterDate(Optional.ofNullable(registerDate).map(Timestamp::getTime).orElse(null));
  474. userSpaceView.setAdmin(this.getAdmin().toView());
  475. userSpaceView.setAdminUU(this.getAdminUU());
  476. userSpaceView.setBusinessCode(this.getBusinessCode());
  477. userSpaceView.setBusinessCodeImage(this.getBusinessCodeImage());
  478. userSpaceView.setRegAddress(this.getRegAddress());
  479. userSpaceView.setValidCode(this.getValidCode());
  480. userSpaceView.setLogoImage(this.getLogoImage());
  481. userSpaceView.setTelephone(this.getTelephone());
  482. userSpaceView.setProfession(this.getProfession());
  483. userSpaceView.setTags(this.getTags());
  484. userSpaceView.setInviteSpaceUU(this.getInviteSpaceUU());
  485. userSpaceView.setInviteUserUU(this.getInviteUserUU());
  486. userSpaceView.setSource(this.getSource());
  487. userSpaceView.setArea(this.getArea());
  488. userSpaceView.setAccessSecret(this.getAccessSecret());
  489. return userSpaceView;
  490. }
  491. @Override
  492. public boolean equals(Object o) {
  493. if (this == o) return true;
  494. if (o == null || getClass() != o.getClass()) return false;
  495. Userspace userspace = (Userspace) o;
  496. return spaceUU.equals(userspace.spaceUU);
  497. }
  498. @Override
  499. public int hashCode() {
  500. return spaceUU.hashCode();
  501. }
  502. }