package ink.wgink.module.activiti.controller.route.oa;

import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.activiti.service.oa.IOaFormReportRouteService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @ClassName: OaController
 * @Description: Oa管理
 * @Author: wanggeng
 * @Date: 2022/3/23 09:54
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "oa管理")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/oa-form-report")
public class OaFormReportRouteController extends DefaultBaseController {

    @Autowired
    private IOaFormReportRouteService oaFormReportRouteService;

    @GetMapping("save/definition-id/{processDefinitionId}/code/{formCode}/version/{formVersion}")
    public void get(@PathVariable("processDefinitionId") String processDefinitionId,
                    @PathVariable("formCode") String formCode,
                    @PathVariable("formVersion") Integer formVersion,
                    HttpSession httpSession,
                    HttpServletRequest httpServletRequest,
                    HttpServletResponse httpServletResponse) {
        oaFormReportRouteService.save(processDefinitionId, formCode, formVersion, httpSession, httpServletRequest, httpServletResponse);
    }

    @GetMapping("update/task-id/{taskId}/code/{formCode}/version/{formVersion}/is-need-claim/{isNeedClaim}")
    public void update(@PathVariable("taskId") String taskId,
                       @PathVariable("formCode") String formCode,
                       @PathVariable("formVersion") Integer formVersion,
                       @PathVariable("isNeedClaim") Integer isNeedClaim,
                       HttpSession httpSession,
                       HttpServletRequest httpServletRequest,
                       HttpServletResponse httpServletResponse) {
        oaFormReportRouteService.update(taskId, formCode, formVersion, isNeedClaim, httpSession, httpServletRequest, httpServletResponse);
    }

    @GetMapping("show/code/{formCode}/version/{formVersion}")
    public void show(@PathVariable("formCode") String formCode,
                     @PathVariable("formVersion") Integer formVersion,
                     HttpSession httpSession,
                     HttpServletRequest httpServletRequest,
                     HttpServletResponse httpServletResponse) {
        oaFormReportRouteService.show(formCode, formVersion, httpSession, httpServletRequest, httpServletResponse);
    }

    @GetMapping("print/code/{formCode}/version/{formVersion}/uid/{uid}")
    public void print(@PathVariable("formCode") String formCode,
                     @PathVariable("formVersion") Integer formVersion,
                     @PathVariable("uid") String uid,
                     HttpSession httpSession,
                     HttpServletRequest httpServletRequest,
                     HttpServletResponse httpServletResponse) {
        oaFormReportRouteService.print(formCode, formVersion, uid, httpSession, httpServletRequest, httpServletResponse);
    }

}
