package com.persagy.server.controllers

import com.persagy.database.SFilter
import com.persagy.server.models.PropertyEquip
import com.persagy.server.models.PropertyFamily
import com.persagy.server.models.requests.EquipUpDateEnclosure
import com.persagy.server.models.requests.EquipUpDateEnclosureRequest
import com.persagy.server.service.PropertyEquipService
import com.persagy.server.service.PropertyFamilyService
import com.persagy.service.SPageContext
import com.persagy.service.models.requests.SQueryRequest
import com.persagy.service.models.responses.SBaseResponse
import com.persagy.service.models.responses.SQueryResponse
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.web.bind.annotation.*

/**
 * 资产接口
 *
 * @author 张维新
 */
@Api(tags = ["资产相关接口"])
@RestController
@RequestMapping("/property")
class PropertyController {

    /**
     * 查询资产关联设备
     */
    @ApiOperation(value = "查询资产 同时关联设备信息", notes = " 设备相关字段：LinkeEquipName、LinkeEquipId、LinkeEquipLocalName")
    @PostMapping(value = ["/property-query"])
    fun pageQueryProperty(@RequestBody request: SQueryRequest): SQueryResponse<PropertyEquip> {
        val withFilterList = ArrayList<SFilter>()
        withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString()))
        return PropertyEquipService.pageQuery(request, withFilterList)
    } // Function pageQueryProperty()

    /**
     * 查询项目下的设备族分类 以及数量
     */
    @ApiOperation(value = "查询项目下的设备族分类 以及相同设备族资产的数量数量", notes = " ")
    @GetMapping(value = ["/property-family"])
    fun pageQueryPropertyFamily(buildingId: String?, floorId: String?,startTime: String?, endingTime: String?,pointId: String?, checked: String?): SQueryResponse<PropertyFamily> {
        return PropertyFamilyService.queryFamily(buildingId,floorId,startTime,endingTime,pointId,checked)
    } // Function pageQueryProperty()

    /**
     * 修改资产的附件功能
     */
    @ApiOperation(value = " 修改资产的附件功能", notes = "")
    @PostMapping(value = ["/update"])
    fun equipUpDateEnclosure(@RequestBody equipUpDateEnclosureRequest: EquipUpDateEnclosureRequest<EquipUpDateEnclosure>) : SBaseResponse {
        return PropertyEquipService.equipUpDateEnclosurs(equipUpDateEnclosureRequest)
    } // Function equipUpDateEnclosure()

} // Class PropertyContrpller