12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /*
- * @description: 安全巡检审批相关
- * @Author: LanJianRong
- * @Date: 2020-12-18
- * @FilePath: \construction_management\web\api\safe_rpc_api.go
- */
- package api
- import (
- "fmt"
- "github.com/kataras/iris/v12"
- "go.mod/services"
- "go.mod/web/utils"
- )
- type SafeAuditApi struct {
- //框架-web应用上下文环境
- Ctx iris.Context
- // 需要用的service
- SafeAuditService services.SafeAuditService
- }
- // @Summary 添加审批流程
- // @Tags 安全巡检-审批
- // @Description 增加审批人进审批流程
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param safe_id body string true "质量巡检id"
- // @Param bidsection_id body string true "标段id"
- // @Param times body string true "审批次数"
- // @Param audit_id body string true "审批人id"
- // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
- // @Failure 400 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
- // @Router /api/safe_audit/add [post]
- func (c *SafeAuditApi) PostAdd() {
- // 1.规则验证
- safeAuditData, err := c.SafeAuditService.ValidRule(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- bidsectionId, err := utils.GetDecryptId(safeAuditData.BidsectionId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
- return
- }
- auditId, err := utils.GetDecryptId(safeAuditData.AuditId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
- return
- }
- safeId, err := utils.GetDecryptId(safeAuditData.SafeId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
- return
- }
- err = c.SafeAuditService.AddAuditor(safeId, bidsectionId, auditId, safeAuditData.Times)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "插入成功",
- })
- }
|