package com.jeeplus.centerservice.controller.ccpm;

import com.jeeplus.centerservice.service.ccpm.CcpmService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/ccpm_control")
public class CcpmController {


    @Resource
    private CcpmService ccpmService;

    /**
     * 查询流程详情
     * @param id
     * @return
     */
    @GetMapping("getByIdGenerate")
    public ResponseEntity getByIdGenerate(String id, String processDefKey) {
        Map<String, Object> res = ccpmService.getByIdGenerate(id, processDefKey);
        return ResponseEntity.ok (res);
    }

    /**
     * 报销审核
     * @param id
     * @param flag yes 审核通过 no 审核失败
     * @param comment 审批意见
     * @param processDefKey 流程类型
     * @return
     */
    @GetMapping("reimAudit")
    public ResponseEntity reimAudit(String id, String flag, String comment, String processDefKey) {
        Map<String, Object> resultMap = this.ccpmService.reimAudit(id, flag, comment, processDefKey);
        return ResponseEntity.ok (resultMap);
    }

    /**
     * 报销重新申请
     * @param id
     * @return
     */
    @GetMapping("reimReapply")
    public ResponseEntity reimReapply(String id, String processDefKey) {
        Map<String, Object> resultMap = this.ccpmService.reimAudit(id, "yes", null, processDefKey);
        return ResponseEntity.ok (resultMap);
    }

    /**
     * 报销申请删除
     * @param id
     * @return
     */
    @GetMapping("deleteReim")
    public ResponseEntity deleteReim(String id) {
        Map<String, Object> resultMap = this.ccpmService.deleteReim(id);
        return ResponseEntity.ok (resultMap);
    }


}
