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.OrgPersonnelChangeApi;
import org.qinan.safetyeval.client.co.OrgPersonnelChangeCO;
import org.qinan.safetyeval.client.dto.OrgPersonnelChangeAddCmd;
import org.qinan.safetyeval.client.dto.OrgPersonnelChangeModifyCmd;
import org.qinan.safetyeval.client.dto.OrgPersonnelChangePageQuery;
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-personnel-change")
public class OrgPersonnelChangeController {

    @Resource
    private OrgPersonnelChangeApi orgPersonnelChangeApi;

    @ApiOperation("新增人员变更记录")
    @PostMapping("/save")
    public SingleResponse<OrgPersonnelChangeCO> add(@Validated @RequestBody OrgPersonnelChangeAddCmd cmd) {
        return orgPersonnelChangeApi.add(cmd);
    }

    @ApiOperation("查询人员变更记录详情")
    @GetMapping("/get")
    public SingleResponse<OrgPersonnelChangeCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return orgPersonnelChangeApi.get(id);
    }

    @ApiOperation("修改人员变更记录")
    @PostMapping("/modify")
    public SingleResponse<OrgPersonnelChangeCO> modify(@Validated @RequestBody OrgPersonnelChangeModifyCmd cmd) {
        return orgPersonnelChangeApi.modify(cmd);
    }

    @ApiOperation("删除人员变更记录")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return orgPersonnelChangeApi.delete(id);
    }

    @ApiOperation("分页查询人员变更记录")
    @GetMapping("/page")
    public PageResponse<OrgPersonnelChangeCO> page(@Validated OrgPersonnelChangePageQuery query) {
        return orgPersonnelChangeApi.page(query);
    }
}
