package org.qinan.safetyeval.adapter.web;

import io.swagger.annotations.Api;
import org.qinan.safetyeval.client.dto.PageResponse;
import org.qinan.safetyeval.client.dto.SingleResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.qinan.safetyeval.client.api.OrgEquipmentApi;
import org.qinan.safetyeval.client.co.OrgEquipmentCO;
import org.qinan.safetyeval.client.dto.OrgEquipmentAddCmd;
import org.qinan.safetyeval.client.dto.OrgEquipmentModifyCmd;
import org.qinan.safetyeval.client.dto.OrgEquipmentPageQuery;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 装备信息适配层（Controller）
 *
 * @author safety-eval
 */
@Api(tags = "装备信息管理")
@RestController
@RequestMapping("/safetyEval/org-equipment")
public class OrgEquipmentController {

    @Resource
    private OrgEquipmentApi orgEquipmentApi;

    @ApiOperation("新增装备信息")
    @PostMapping("/save")
    public SingleResponse<OrgEquipmentCO> add(@Validated @RequestBody OrgEquipmentAddCmd cmd) {
        return orgEquipmentApi.add(cmd);
    }

    @ApiOperation("查询装备信息详情")
    @GetMapping("/get")
    public SingleResponse<OrgEquipmentCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return orgEquipmentApi.get(id);
    }

    @ApiOperation("修改装备信息")
    @PostMapping("/modify")
    public SingleResponse<OrgEquipmentCO> modify(@Validated @RequestBody OrgEquipmentModifyCmd cmd) {
        return orgEquipmentApi.modify(cmd);
    }

    @ApiOperation("删除装备信息")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return orgEquipmentApi.delete(id);
    }

    @ApiOperation("分页查询装备信息")
    @GetMapping("/page")
    public PageResponse<OrgEquipmentCO> page(@Validated OrgEquipmentPageQuery query) {
        return orgEquipmentApi.page(query);
    }
}
