outside_report_controller.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // @Author gmy 2024/9/24 16:05:00
  2. package controllers
  3. import (
  4. "encoding/json"
  5. "eta/eta_hub/models"
  6. "eta/eta_hub/models/document_manage_model"
  7. "eta/eta_hub/models/system"
  8. "eta/eta_hub/services/document_manage_service"
  9. )
  10. type OutsideReportController struct {
  11. BaseAuthController
  12. }
  13. // DocumentSave
  14. // @Title 新建文档
  15. // @Description 新建文档
  16. // @Success 200 “操作成功”
  17. // @router /document/save [post]
  18. func (this *OutsideReportController) DocumentSave() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. var req *document_manage_model.OutsideReportBO
  25. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  26. br.Msg = "参数解析异常!"
  27. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  28. return
  29. }
  30. userName := req.UserName
  31. sysUser, err := system.GetUserByAdminName(userName)
  32. req.SysUserId = sysUser.AdminId
  33. req.SysUserName = sysUser.AdminName
  34. err = document_manage_service.DocumentSave(req)
  35. if err != nil {
  36. br.Msg = "保存文档失败"
  37. br.ErrMsg = "保存文档失败,Err:" + err.Error()
  38. return
  39. }
  40. br.Ret = 200
  41. br.Msg = "操作成功"
  42. return
  43. }