package ink.wgink.module.form.controller.app.route.report;

import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.form.service.report.IFormReportRouteService;
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: FormReportRouteController
 * @Description: 表单上报
 * @Author: wanggeng
 * @Date: 2022/3/10 7:29 PM
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_APP_ROUTE_PREFIX + "表单")
@Controller
@RequestMapping(ISystemConstant.APP_ROUTE_PREFIX + "/form-report")
public class FormReportAppRouteController {

    @Autowired
    private IFormReportRouteService formReportService;

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

    @GetMapping("save-release/code/{formCode}/version/{formVersion}")
    public void saveRelease(@PathVariable("formCode") String formCode,
                            @PathVariable("formVersion") Integer formVersion,
                            HttpSession httpSession,
                            HttpServletRequest httpServletRequest,
                            HttpServletResponse httpServletResponse) {
        formReportService.appSave(formCode, formVersion, httpSession, httpServletRequest, httpServletResponse);
    }

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

    @GetMapping("update-release/code/{formCode}/version/{formVersion}")
    public void updateRelease(@PathVariable("formCode") String formCode,
                              @PathVariable("formVersion") Integer formVersion,
                              HttpSession httpSession,
                              HttpServletRequest httpServletRequest,
                              HttpServletResponse httpServletResponse) {
        formReportService.appUpdate(formCode, formVersion, 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) {
        formReportService.appShow(formCode, formVersion, httpSession, httpServletRequest, httpServletResponse);
    }

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

}
