package com.yida.data.form.apply.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.form.apply.service.AppApplyFormService;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.customForm.dto.apply.*;
import com.yida.data.customForm.vo.apply.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * H5--申请类表单接口管理 Controller
 *
 * @author ZYJ
 * @date 2023/11/14
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/app/applyFrom")
@Api(tags = "H5--申请类表单接口管理")
public class AppApplyFormController {

    private final AppApplyFormService appApplyFormService;

    @ApiOperation("家长端查询可填报的申请表单列表数据")
    @PostMapping("/parent/listApplyFormPage")
    public ResultBean<IPage<ApplyFormSelectPageVO>> listApplyFormPage(H5ApplyFormSelectPageDTO dto) {
        IPage<ApplyFormSelectPageVO> page = appApplyFormService.listApplyFormPage(dto);
        return ResultBean.buildSuccess(page);
    }

    @ApiOperation("家长端查询已经填报的申请数据")
    @PostMapping("/parent/listMyApplyFormPage")
    public ResultBean<IPage<MyApplyFormPageVO>> listMyApplyFormPage(H5ApplyFormSelectPageDTO dto) {
        IPage<MyApplyFormPageVO> page = appApplyFormService.listMyApplyFormPage(dto);
        return ResultBean.buildSuccess(page);
    }

    @ApiOperation("家长端查询申请表单详情")
    @GetMapping("/parent/getApplyFormInfo")
    public ResultBean<ApplyFormInfoVO> getApplyFormInfo(
            @RequestParam @ApiParam(value = "表单id", required = true) Long id) {
        return ResultBean.buildSuccess(appApplyFormService.getApplyFormInfo(id));
    }

    @ApiOperation("家长端提交保存申请表单数据")
    @PostMapping("/parent/saveApplyFormData")
    public ResultBean<String> saveApplyFormData(@RequestBody ApplyFormDataInputDTO dto) {
        appApplyFormService.saveApplyFormData(dto);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("教师端我审批的申请表单")
    @GetMapping("/staff/findApprovalApplyFormDataList")
    public ResultBean<IPage<ApprovalApplyFormPageVO>> findApprovalApplyFormDataList(SelectApprovalApplyFormDataListDTO dto) {
        IPage<ApprovalApplyFormPageVO> page = appApplyFormService.findApprovalApplyFormDataList(dto);
        return ResultBean.buildSuccess(page);
    }

    @ApiOperation("获取申请表单填报数据")
    @PostMapping("/getApplyFormFillUserData")
    public ResultBean<ApplyFormFillUserDataVO> getApplyFormFillUserData(ApplyFormFillUserDataDTO dto) {
        return ResultBean.buildSuccess(appApplyFormService.getApplyFormFillUserData(dto));
    }

    @ApiOperation("教师端填报数据审核")
    @PostMapping("/staff/auditForm")
    public ResultBean<String> auditForm(@RequestBody AuditFormDTO dto) {
        appApplyFormService.auditForm(dto);
        return ResultBean.buildSuccess();
    }
}
