/* * ******************************************************************************************************************** * * :*$@@%$*: ;: ;; ;; * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@ * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$ * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$= * =@* %! @ $= % %@= =%@! %= * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =% * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%* * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$ * $@* ;@@@%=!: *@* * =@$ ;;;!=%@@@@=! =@! * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司 * ;%@@$=$@@%* *@@@$=%@@%; * ::;:: ::;:: All rights reserved. * * ******************************************************************************************************************** */ package cn.sagacloud.server.datacenter.controllers import cn.sagacloud.server.datacenter.models.entities.Property import cn.sagacloud.server.datacenter.services.PropertyService import com.sybotan.base.extensions.toJson import com.sybotan.database.SFilter import com.sybotan.service.SPageContext import com.sybotan.service.models.requests.SCountRequest import com.sybotan.service.models.requests.SCreateRequest import com.sybotan.service.models.requests.SQueryRequest import com.sybotan.service.models.requests.SUpdateRequest import com.sybotan.service.models.responses.SBaseResponse import com.sybotan.service.models.responses.SCountResponse import com.sybotan.service.models.responses.SCreateResponse import com.sybotan.service.models.responses.SQueryResponse import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import org.slf4j.LoggerFactory import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController /** * 资产接口 * * @author 张维新 */ @Api(tags = ["资产接口"]) @RestController @RequestMapping("/object/property") open class PropertyController2 { companion object { /** 日志 */ private val logger = LoggerFactory.getLogger(PropertyController2::class.java) } // Companion object /** * 创建资产 * * @param request 资产对象列表 * @return 创建结果信息 */ @ApiOperation(value = "创建资产信息", notes = "") @PostMapping(value = ["/create"]) fun create(@RequestBody request: SCreateRequest): SCreateResponse { logger.debug("property =${request.toJson()}") return PropertyService.createList( request) } // Function create() /** * 根据id删除资产 * * @param idList id数组 * @return 删除的结果信息 */ @ApiOperation(value = "根据id删除资产信息", notes = "") @PostMapping(value = ["/delete"]) fun delete(@RequestBody idList: ArrayList): SBaseResponse { return PropertyService.deleteByKeysList(idList) } // Function delete() /** * 更新资产信息 * * @param request 更新的内容对象 * @return 更新的结果 */ @ApiOperation(value = "更新资产信息", notes = "") @PostMapping(value = ["/update"]) fun update(@RequestBody request: SUpdateRequest): SBaseResponse { logger.debug("equipUpdate =${request.toJson()}") return PropertyService.updateList(request) } // Function update() /** * 查询资产信息 * * @param request 查询信息条件 * @return 查询结果 */ @ApiOperation(value = "查询资产信息", notes = "级联查询对象:项目(project)、建筑(building)、楼层(floor)、设备(equipment)、设备族(equipFamilyList)、设备族名称(familyName)") @PostMapping(value = ["/query"]) fun query(@RequestBody request: SQueryRequest): SQueryResponse { logger.debug("equipQuery =${request.toJson()}") val withFilterList = ArrayList() withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString())) return PropertyService.pageQuery(request,withFilterList) } // Function query() /** * 根据条件查询统计数量 */ @ApiOperation(value = "根据条件查询统计数量", notes = "例子: 已经关联岗位的资产数量(\"Filters\": \" not EquipId isNull\")," + "未关联岗位的资产数量(\"Filters\": \" EquipId isNull\")") @PostMapping(value = ["/count"]) fun count(@RequestBody request: SCountRequest): SCountResponse { val withFilterList = ArrayList() withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString())) return PropertyService.count(request,withFilterList) } // Function count() } // Class AssetsController