1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // @Author gmy 2024/9/19 16:45:00
- package document_manage_service
- import (
- "eta/eta_hub/models/document_manage_model"
- "eta/eta_hub/utils"
- "github.com/beego/beego/v2/core/logs"
- "github.com/google/uuid"
- )
- func DocumentSave(outsideReport *document_manage_model.OutsideReportBO) error {
- logs.Info("DocumentSave")
- // 保存报告
- report := document_manage_model.OutsideReport{
- Source: outsideReport.Source,
- Title: outsideReport.Title,
- Abstract: outsideReport.Abstract,
- ClassifyId: outsideReport.ClassifyId,
- ClassifyName: outsideReport.ClassifyName,
- Content: outsideReport.Content,
- SysUserId: outsideReport.SysUserId,
- SysUserName: outsideReport.SysUserName,
- ReportUpdateTime: utils.GetCurrentTime(),
- ModifyTime: utils.GetCurrentTime(),
- CreateTime: utils.GetCurrentTime(),
- ReportCode: uuid.New().String(),
- }
- id, err := document_manage_model.SaveOutsideReport(report)
- if err != nil {
- return err
- }
- // 保存附件
- attachmentList := outsideReport.AttachmentList
- if len(attachmentList) > 0 {
- for _, attachment := range attachmentList {
- if attachment.Title == "" || attachment.Url == "" {
- continue
- }
- attachment.OutsideReportId = int(id)
- attachment.CreateTime = utils.GetCurrentTime()
- _, err := document_manage_model.SaveOutsideReportAttachment(attachment)
- if err != nil {
- return err
- }
- }
- }
- return err
- }
|