document_manage_service.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // @Author gmy 2024/9/19 16:45:00
  2. package document_manage_service
  3. import (
  4. "eta/eta_hub/models/document_manage_model"
  5. "eta/eta_hub/utils"
  6. "github.com/beego/beego/v2/core/logs"
  7. "github.com/google/uuid"
  8. )
  9. func DocumentSave(outsideReport *document_manage_model.OutsideReportBO) error {
  10. logs.Info("DocumentSave")
  11. // 保存报告
  12. report := document_manage_model.OutsideReport{
  13. Source: outsideReport.Source,
  14. Title: outsideReport.Title,
  15. Abstract: outsideReport.Abstract,
  16. ClassifyId: outsideReport.ClassifyId,
  17. ClassifyName: outsideReport.ClassifyName,
  18. Content: outsideReport.Content,
  19. SysUserId: outsideReport.SysUserId,
  20. SysUserName: outsideReport.SysUserName,
  21. ReportUpdateTime: utils.GetCurrentTime(),
  22. ModifyTime: utils.GetCurrentTime(),
  23. CreateTime: utils.GetCurrentTime(),
  24. ReportCode: uuid.New().String(),
  25. }
  26. id, err := document_manage_model.SaveOutsideReport(report)
  27. if err != nil {
  28. return err
  29. }
  30. // 保存附件
  31. attachmentList := outsideReport.AttachmentList
  32. if len(attachmentList) > 0 {
  33. for _, attachment := range attachmentList {
  34. if attachment.Title == "" || attachment.Url == "" {
  35. continue
  36. }
  37. attachment.OutsideReportId = int(id)
  38. attachment.CreateTime = utils.GetCurrentTime()
  39. _, err := document_manage_model.SaveOutsideReportAttachment(attachment)
  40. if err != nil {
  41. return err
  42. }
  43. }
  44. }
  45. return err
  46. }