PropertyController2.kt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * :*$@@%$*: ;: ;; ;;
  5. * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@
  6. * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$
  7. * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$=
  8. * =@* %! @ $= % %@= =%@! %=
  9. * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =%
  10. * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%*
  11. * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$
  12. * $@* ;@@@%=!: *@*
  13. * =@$ ;;;!=%@@@@=! =@!
  14. * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司
  15. * ;%@@$=$@@%* *@@@$=%@@%;
  16. * ::;:: ::;:: All rights reserved.
  17. *
  18. * ********************************************************************************************************************
  19. */
  20. package cn.sagacloud.server.datacenter.controllers
  21. import cn.sagacloud.server.datacenter.models.entities.Property
  22. import cn.sagacloud.server.datacenter.services.PropertyService
  23. import com.sybotan.base.extensions.toJson
  24. import com.sybotan.database.SFilter
  25. import com.sybotan.service.SPageContext
  26. import com.sybotan.service.models.requests.SCountRequest
  27. import com.sybotan.service.models.requests.SCreateRequest
  28. import com.sybotan.service.models.requests.SQueryRequest
  29. import com.sybotan.service.models.requests.SUpdateRequest
  30. import com.sybotan.service.models.responses.SBaseResponse
  31. import com.sybotan.service.models.responses.SCountResponse
  32. import com.sybotan.service.models.responses.SCreateResponse
  33. import com.sybotan.service.models.responses.SQueryResponse
  34. import io.swagger.annotations.Api
  35. import io.swagger.annotations.ApiOperation
  36. import org.slf4j.LoggerFactory
  37. import org.springframework.web.bind.annotation.PostMapping
  38. import org.springframework.web.bind.annotation.RequestBody
  39. import org.springframework.web.bind.annotation.RequestMapping
  40. import org.springframework.web.bind.annotation.RestController
  41. /**
  42. * 资产接口
  43. *
  44. * @author 张维新
  45. */
  46. @Api(tags = ["资产接口"])
  47. @RestController
  48. @RequestMapping("/object/property")
  49. open class PropertyController2 {
  50. companion object {
  51. /** 日志 */
  52. private val logger = LoggerFactory.getLogger(PropertyController2::class.java)
  53. } // Companion object
  54. /**
  55. * 创建资产
  56. *
  57. * @param request 资产对象列表
  58. * @return 创建结果信息
  59. */
  60. @ApiOperation(value = "创建资产信息", notes = "")
  61. @PostMapping(value = ["/create"])
  62. fun create(@RequestBody request: SCreateRequest<Property>): SCreateResponse<Property> {
  63. logger.debug("property =${request.toJson()}")
  64. return PropertyService.createList( request)
  65. } // Function create()
  66. /**
  67. * 根据id删除资产
  68. *
  69. * @param idList id数组
  70. * @return 删除的结果信息
  71. */
  72. @ApiOperation(value = "根据id删除资产信息", notes = "")
  73. @PostMapping(value = ["/delete"])
  74. fun delete(@RequestBody idList: ArrayList<Property>): SBaseResponse {
  75. return PropertyService.deleteByKeysList(idList)
  76. } // Function delete()
  77. /**
  78. * 更新资产信息
  79. *
  80. * @param request 更新的内容对象
  81. * @return 更新的结果
  82. */
  83. @ApiOperation(value = "更新资产信息", notes = "")
  84. @PostMapping(value = ["/update"])
  85. fun update(@RequestBody request: SUpdateRequest<Property>): SBaseResponse {
  86. logger.debug("equipUpdate =${request.toJson()}")
  87. return PropertyService.updateList(request)
  88. } // Function update()
  89. /**
  90. * 查询资产信息
  91. *
  92. * @param request 查询信息条件
  93. * @return 查询结果
  94. */
  95. @ApiOperation(value = "查询资产信息", notes = "级联查询对象:项目(project)、建筑(building)、楼层(floor)、设备(equipment)、设备族(equipFamilyList)、设备族名称(familyName)")
  96. @PostMapping(value = ["/query"])
  97. fun query(@RequestBody request: SQueryRequest): SQueryResponse<Property> {
  98. logger.debug("equipQuery =${request.toJson()}")
  99. val withFilterList = ArrayList<SFilter>()
  100. withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString()))
  101. return PropertyService.pageQuery(request,withFilterList)
  102. } // Function query()
  103. /**
  104. * 根据条件查询统计数量
  105. */
  106. @ApiOperation(value = "根据条件查询统计数量", notes = "例子: 已经关联岗位的资产数量(\"Filters\": \" not EquipId isNull\")," +
  107. "未关联岗位的资产数量(\"Filters\": \" EquipId isNull\")")
  108. @PostMapping(value = ["/count"])
  109. fun count(@RequestBody request: SCountRequest): SCountResponse {
  110. val withFilterList = ArrayList<SFilter>()
  111. withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString()))
  112. return PropertyService.count(request,withFilterList)
  113. } // Function count()
  114. } // Class AssetsController