safe_rpc_api.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. // type SafeRpcApi struct {
  9. // //框架-web应用上下文环境
  10. // Ctx iris.Context
  11. // // 需要用的service
  12. // ServiceSafe services.SafeService
  13. // }
  14. // @Summary 安全巡检列表
  15. // @Tags 安全巡检
  16. // @Description 获得列表数据
  17. // @Accept json
  18. // @Produce json
  19. // @Security ApiKeyAuth
  20. // @Param bidsectionId path string true "标段ID"
  21. // @Success 200 {object} viewmodels.Safe "{code:0成功,data:viewmodels.Safe,msg:}"
  22. // @Failure 400 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  23. // @Router /api/safe [get]
  24. // func (c *SafeRpcApi) Get() {
  25. // // RpcConnect := c.Ctx.Values().Get("RpcConnect").(*grpc.ClientConn)
  26. // // 1.规则验证
  27. // safeData, err := c.ServiceSafe.ValidRule(c.Ctx)
  28. // if err != nil {
  29. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  30. // return
  31. // }
  32. // bidsectionId, err := utils.GetDecryptId(safeData.BidsectionId)
  33. // if err != nil {
  34. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  35. // return
  36. // }
  37. // // c.ServiceSafe.Get(bidsectionId, RpcConnect)
  38. // SafeData := c.ServiceSafe.Get(bidsectionId)
  39. // c.Ctx.JSON(iris.Map{
  40. // "code": 0,
  41. // "msg": "请求成功",
  42. // "data": SafeData,
  43. // })
  44. // }
  45. // @Summary 安全巡检列表
  46. // @Tags 安全巡检
  47. // @Description 创建新的安全巡检记录
  48. // @Accept json
  49. // @Produce json
  50. // @Security ApiKeyAuth
  51. // @Param bidsectionId body string true "标段ID"
  52. // @Param code body string true "编号"
  53. // @Param createTime body string true "日期"
  54. // @Param inspection body string true "检查部位"
  55. // @Param position body string true "部位"
  56. // @Success 200 {object} viewmodels.Safe "{code:0成功,msg:}"
  57. // @Failure 400 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  58. // @Router /api/safe/create [post]
  59. // func (c *SafeRpcApi) PostCreate() {
  60. // // 1.规则验证
  61. // safeData, err := c.ServiceSafe.ValidRule(c.Ctx)
  62. // if err != nil {
  63. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  64. // return
  65. // }
  66. // fmt.Println(safeData)
  67. // bidsectionId, err := utils.GetDecryptId(safeData.BidsectionId)
  68. // if err != nil {
  69. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  70. // return
  71. // }
  72. // RpcConnect := c.Ctx.Values().Get("RpcConnect").(*grpc.ClientConn)
  73. // code, msg := c.ServiceSafe.Post(bidsectionId, safeData.Position, safeData.Code, safeData.CreateTime, safeData.Inspection, RpcConnect)
  74. // c.Ctx.JSON(iris.Map{
  75. // "code": code,
  76. // "msg": msg,
  77. // })
  78. // }