safe_audit_api.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * @description: 安全巡检审批相关
  3. * @Author: LanJianRong
  4. * @Date: 2020-12-18
  5. * @FilePath: \construction_management\web\api\safe_rpc_api.go
  6. */
  7. package api
  8. import (
  9. "fmt"
  10. "github.com/kataras/iris/v12"
  11. "go.mod/services"
  12. "go.mod/web/utils"
  13. )
  14. type SafeAuditApi struct {
  15. //框架-web应用上下文环境
  16. Ctx iris.Context
  17. // 需要用的service
  18. SafeAuditService services.SafeAuditService
  19. }
  20. // @Summary 添加审批流程
  21. // @Tags 安全巡检-审批
  22. // @Description 增加审批人进审批流程
  23. // @Accept json
  24. // @Produce json
  25. // @Security ApiKeyAuth
  26. // @Param safe_id body string true "质量巡检id"
  27. // @Param bidsection_id body string true "标段id"
  28. // @Param times body string true "审批次数"
  29. // @Param audit_id body string true "审批人id"
  30. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  31. // @Failure 400 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  32. // @Router /api/safe_audit/add [post]
  33. func (c *SafeAuditApi) PostAdd() {
  34. // 1.规则验证
  35. safeAuditData, err := c.SafeAuditService.ValidRule(c.Ctx)
  36. if err != nil {
  37. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  38. return
  39. }
  40. bidsectionId, err := utils.GetDecryptId(safeAuditData.BidsectionId)
  41. if err != nil {
  42. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  43. return
  44. }
  45. auditId, err := utils.GetDecryptId(safeAuditData.AuditId)
  46. if err != nil {
  47. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  48. return
  49. }
  50. safeId, err := utils.GetDecryptId(safeAuditData.SafeId)
  51. if err != nil {
  52. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  53. return
  54. }
  55. err = c.SafeAuditService.AddAuditor(safeId, bidsectionId, auditId, safeAuditData.Times)
  56. if err != nil {
  57. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  58. return
  59. }
  60. c.Ctx.JSON(iris.Map{
  61. "code": 0,
  62. "msg": "插入成功",
  63. })
  64. }