Business.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package com.java110.entity.center;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. /**
  5. * 业务数据
  6. * Created by wuxw on 2018/4/13.
  7. */
  8. public class Business implements Comparable{
  9. private String bId;
  10. //业务编码
  11. private String serviceCode;
  12. private String serviceName;
  13. private String remark;
  14. private JSONArray datas;
  15. private JSONArray attrs;
  16. //返回 编码
  17. private String code;
  18. private String message;
  19. private int seq;
  20. public String getbId() {
  21. return bId;
  22. }
  23. public void setbId(String bId) {
  24. this.bId = bId;
  25. }
  26. public String getServiceCode() {
  27. return serviceCode;
  28. }
  29. public void setServiceCode(String serviceCode) {
  30. this.serviceCode = serviceCode;
  31. }
  32. public String getServiceName() {
  33. return serviceName;
  34. }
  35. public void setServiceName(String serviceName) {
  36. this.serviceName = serviceName;
  37. }
  38. public String getRemark() {
  39. return remark;
  40. }
  41. public void setRemark(String remark) {
  42. this.remark = remark;
  43. }
  44. public JSONArray getDatas() {
  45. return datas;
  46. }
  47. public void setDatas(JSONArray datas) {
  48. this.datas = datas;
  49. }
  50. public JSONArray getAttrs() {
  51. return attrs;
  52. }
  53. public void setAttrs(JSONArray attrs) {
  54. this.attrs = attrs;
  55. }
  56. public String getCode() {
  57. return code;
  58. }
  59. public void setCode(String code) {
  60. this.code = code;
  61. }
  62. public String getMessage() {
  63. return message;
  64. }
  65. public void setMessage(String message) {
  66. this.message = message;
  67. }
  68. public int getSeq() {
  69. return seq;
  70. }
  71. public void setSeq(int seq) {
  72. this.seq = seq;
  73. }
  74. /**
  75. * 构建成对象
  76. * @return
  77. * @throws Exception
  78. */
  79. public Business builder(JSONObject businessObj) throws Exception{
  80. try{
  81. this.setbId(businessObj.getString("bId"));
  82. this.setServiceCode(businessObj.getString("serviceCode"));
  83. this.setServiceName(businessObj.getString("serviceName"));
  84. this.setRemark(businessObj.getString("remark"));
  85. this.setDatas(businessObj.getJSONArray("datas"));
  86. this.setAttrs(businessObj.getJSONArray("attrs"));
  87. if(businessObj.containsKey("response")){
  88. this.setCode(businessObj.getJSONObject("response").getString("code"));
  89. this.setMessage(businessObj.getJSONObject("response").getString("message"));
  90. }
  91. }catch (Exception e){
  92. throw e;
  93. }
  94. return this;
  95. }
  96. @Override
  97. public int compareTo(Object o) {
  98. Business otherBusiness = (Business)o;
  99. if(this.getSeq() > otherBusiness.getSeq()) {
  100. return -1;
  101. }
  102. return 0;
  103. }
  104. }