IntelligentLightingStrategy.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "iot_manager_service/app/device/model"
  5. "iot_manager_service/app/device/service"
  6. "iot_manager_service/util"
  7. "net/http"
  8. "strconv"
  9. )
  10. var IntelligentLighting = new(intelligentLightingCtl)
  11. type intelligentLightingCtl struct{}
  12. func (c *intelligentLightingCtl) Detail(ctx *gin.Context) {
  13. publicId, e := strconv.Atoi(ctx.Query("publicId"))
  14. if e != nil {
  15. ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(e.Error(), nil))
  16. return
  17. }
  18. if publicId == 0 {
  19. ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(model.RelationIdInvalid, nil))
  20. return
  21. }
  22. //当前类型1=灯杆2=灯杆分组
  23. relationType, e := strconv.Atoi(ctx.Query("type"))
  24. if e != nil {
  25. ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(e.Error(), nil))
  26. return
  27. }
  28. if relationType == model.RelationTypeLight {
  29. detail, err := service.IntelligentLightingService.GetDetailByLight(publicId)
  30. if err != nil {
  31. ctx.JSON(http.StatusOK, err)
  32. return
  33. }
  34. ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, detail))
  35. } else if relationType == model.RelationTypeLampPoleGroup {
  36. detail, err := service.IntelligentLightingService.GetDetailByGroup(publicId)
  37. if err != nil {
  38. ctx.JSON(http.StatusOK, err)
  39. return
  40. }
  41. ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, detail))
  42. } else {
  43. ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(model.RelationTypeInvalid, nil))
  44. }
  45. }
  46. func (c *intelligentLightingCtl) List(ctx *gin.Context) {
  47. }
  48. func (c *intelligentLightingCtl) RelationList(ctx *gin.Context) {
  49. }
  50. func (c *intelligentLightingCtl) Relation(ctx *gin.Context) {
  51. }
  52. func (c *intelligentLightingCtl) Remove(ctx *gin.Context) {
  53. }
  54. func (c *intelligentLightingCtl) ChangeHandSwitch(ctx *gin.Context) {
  55. }
  56. func (c *intelligentLightingCtl) GetStatus(ctx *gin.Context) {
  57. }