package com.jeeplus.human.depart.handover.controller;

import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.human.depart.handover.domain.HandoverComputer;
import com.jeeplus.human.depart.handover.domain.HandoverDraft;
import com.jeeplus.human.depart.handover.service.HandoverComputerService;
import com.jeeplus.logging.annotation.ApiLog;
import com.jeeplus.logging.constant.enums.LogTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 王强
 * @version 1.0
 * @date 2023-11-06 10:57
 */
@RestController
@Api("电脑款项检查")
@RequestMapping(value = "/handoverComputer")
public class HandoverComputerController {

    @Resource
    private HandoverComputerService computerService;

    /**
     * 保存电脑款项信息
     * @param computer
     * @return
     */
    @ApiLog(value = "保存电脑款项信息", type = LogTypeEnum.SAVE)
    @PostMapping("save")
    public ResponseEntity save(@Valid @RequestBody HandoverComputer computer) throws Exception {
        HandoverComputer s = computerService.saveComputer(computer);
        return ResponseUtil.newInstance().add("businessTable", "human_resources_depart_handover_draft")
                .add("businessId", s.getId())
                .ok ("操作成功");
    }

    /**
     * 查询
     * @param id
     * @return
     */
    @ApiOperation(value = "查询")
    @GetMapping("/findById")
    public ResponseEntity<HandoverComputer> findById(@RequestParam String id) throws Exception{
        HandoverComputer dto = computerService.findById(id);
        return ResponseEntity.ok(dto);
    }

    /**
     * 根据id修改状态status
     */
    @ApiOperation(value = "根据id修改状态status")
    @PostMapping(value = "updateStatusById")
    public void updateStatusById(@RequestBody HandoverComputer dto) {
        computerService.updateStatusById(dto);
    }
}
