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.OrgResignApplyApi;
import org.qinan.safetyeval.client.co.OrgResignApplyCO;
import org.qinan.safetyeval.client.dto.OrgResignApplyAddCmd;
import org.qinan.safetyeval.client.dto.OrgResignApplyModifyCmd;
import org.qinan.safetyeval.client.dto.OrgResignApplyPageQuery;
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-resign-apply")
public class OrgResignApplyController {

    @Resource
    private OrgResignApplyApi orgResignApplyApi;

    @ApiOperation("新增人员离职申请")
    @PostMapping("/save")
    public SingleResponse<OrgResignApplyCO> add(@Validated @RequestBody OrgResignApplyAddCmd cmd) {
        return orgResignApplyApi.add(cmd);
    }

    @ApiOperation("查询人员离职申请详情")
    @GetMapping("/get")
    public SingleResponse<OrgResignApplyCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return orgResignApplyApi.get(id);
    }

    @ApiOperation("修改人员离职申请")
    @PostMapping("/modify")
    public SingleResponse<OrgResignApplyCO> modify(@Validated @RequestBody OrgResignApplyModifyCmd cmd) {
        return orgResignApplyApi.modify(cmd);
    }

    @ApiOperation("删除人员离职申请")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return orgResignApplyApi.delete(id);
    }

    @ApiOperation("分页查询人员离职申请")
    @GetMapping("/page")
    public PageResponse<OrgResignApplyCO> page(@Validated OrgResignApplyPageQuery query) {
        return orgResignApplyApi.page(query);
    }
}
