safe_rpc_api.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * @description: rpc - 安全巡检
  3. * @Author: LanJianRong
  4. * @Date: 2020-11-18
  5. * @FilePath: \construction_management\web\api\safe_rpc_api.go
  6. */
  7. package api
  8. import (
  9. "github.com/kataras/iris/v12"
  10. "go.mod/services"
  11. "go.mod/web/utils"
  12. )
  13. type SafeRpcApi struct {
  14. //框架-web应用上下文环境
  15. Ctx iris.Context
  16. // 需要用的service
  17. ServiceSafe services.SafeService
  18. }
  19. // @Summary 安全巡检列表
  20. // @Tags 安全巡检
  21. // @Description 获得列表数据
  22. // @Accept json
  23. // @Produce json
  24. // @Security ApiKeyAuth
  25. // @Success 200 {object} viewmodels.Safe "{code:0成功,data:viewmodels.Safe,msg:}"
  26. // @Failure 400 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  27. // @Router /api/safe [get]
  28. func (c *SafeRpcApi) Get() {
  29. // 1.规则验证
  30. safeData, err := c.ServiceSafe.ValidRule(c.Ctx)
  31. if err != nil {
  32. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  33. return
  34. }
  35. bidsectionId, err := utils.GetDecryptId(safeData.BidsectionId)
  36. if err != nil {
  37. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  38. return
  39. }
  40. c.ServiceSafe.Get(bidsectionId)
  41. // SafeList := c.ServiceSafe.GetSafeList()
  42. // c.Ctx.JSON(iris.Map{
  43. // "code": 0,
  44. // "msg": "",
  45. // "data": SafeList,
  46. // })
  47. }