AddNoticeViewComponent.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.java110.api.components.notice;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.core.context.IPageData;
  4. import com.java110.core.context.PageData;
  5. import com.java110.api.smo.file.IAddFileSMO;
  6. import com.java110.api.smo.notice.IAddNoticeSMO;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.http.ResponseEntity;
  9. import org.springframework.stereotype.Component;
  10. import org.springframework.web.multipart.MultipartFile;
  11. /**
  12. * 添加公告组件
  13. */
  14. @Component("addNoticeView")
  15. public class AddNoticeViewComponent {
  16. @Autowired
  17. private IAddNoticeSMO addNoticeSMOImpl;
  18. @Autowired
  19. private IAddFileSMO addFileSMOImpl;
  20. /**
  21. * 添加公告数据
  22. *
  23. * @param pd 页面数据封装
  24. * @return ResponseEntity 对象
  25. */
  26. public ResponseEntity<String> save(IPageData pd) {
  27. return addNoticeSMOImpl.saveNotice(pd);
  28. }
  29. /**
  30. * 上传图片
  31. *
  32. * @param pd 页面数据封装
  33. * @return ResponseEntity 对象
  34. */
  35. public ResponseEntity<String> uploadImage(IPageData pd, MultipartFile uploadFile) throws Exception {
  36. JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
  37. paramIn.put("suffix", "jpeg");
  38. IPageData newPd = PageData.newInstance().builder(pd.getUserId(), pd.getUserName(),pd.getToken(), paramIn.toJSONString(), pd.getComponentCode(), pd.getComponentMethod(), "", pd.getSessionId(),pd.getAppId());
  39. return addFileSMOImpl.saveFile(newPd, uploadFile);
  40. }
  41. public IAddNoticeSMO getAddNoticeSMOImpl() {
  42. return addNoticeSMOImpl;
  43. }
  44. public void setAddNoticeSMOImpl(IAddNoticeSMO addNoticeSMOImpl) {
  45. this.addNoticeSMOImpl = addNoticeSMOImpl;
  46. }
  47. public IAddFileSMO getAddFileSMOImpl() {
  48. return addFileSMOImpl;
  49. }
  50. public void setAddFileSMOImpl(IAddFileSMO addFileSMOImpl) {
  51. this.addFileSMOImpl = addFileSMOImpl;
  52. }
  53. }