OrgAuditPublishEvent.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package com.uas.console.donate.event;
  2. import com.uas.console.donate.model.Message;
  3. import com.uas.console.donate.model.MessageDetail;
  4. import com.uas.console.donate.model.Org;
  5. import java.util.List;
  6. /**
  7. * 机构审核事件
  8. * Created by dongbw
  9. * 2018年1月8日
  10. */
  11. public class OrgAuditPublishEvent extends PublishEvent<MessageDetail, Org> {
  12. /**
  13. *
  14. */
  15. private static final long serialVersionUID = 1L;
  16. private static final short TO_BE_AUDITED = 0;
  17. private static final short BE_AGREED = 1;
  18. private static final short BE_REFUSED = 2;
  19. public OrgAuditPublishEvent(List<Org> savedList) {
  20. super(savedList);
  21. }
  22. /**
  23. * 生成对应消息记录
  24. *
  25. * @param org 机构
  26. * @return 消息
  27. */
  28. @Override
  29. public MessageDetail release(Org org) {
  30. // 发起人UU
  31. Long userUU = org.getUuid();
  32. // 类型
  33. String type = "机构消息";
  34. // 来源表
  35. String table = "donate$organization";
  36. // 来源id
  37. Long sourceId = org.getId();
  38. // url
  39. String url = "/#/organization/list";
  40. // 标题
  41. String title = "";
  42. // 内容
  43. String context = "";
  44. if (BE_AGREED == org.getStatus()) {
  45. title = "机构申请已通过";
  46. context = "您申请入驻的机构‘" + org.getName() + "’已通过审核, 编号:" + org.getCode();
  47. } else if (BE_REFUSED == org.getStatus()) {
  48. title = "机构申请被驳回";
  49. context = "您发布的项目‘" + org.getName() + "’已被驳回, 原因:" + org.getRefuse();
  50. }
  51. // 接收对象
  52. String receiver = org.getPerson();
  53. Message message = new Message(userUU, title, context, type, table, sourceId, url, receiver);
  54. MessageDetail messageDetail = new MessageDetail(org.getUuid());
  55. messageDetail.setMessage(message);
  56. return messageDetail;
  57. }
  58. }