package com.yida.data.customForm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.customform.CoreCustomForm;
import com.yida.data.customForm.dto.RemindAgainDTO;
import com.yida.data.customForm.service.CoreCustomFormService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ccl
 */
@Slf4j
@Validated
@RestController
@RequestMapping("in/coreCustomForm")
@RequiredArgsConstructor
@Api(tags = "不鉴权-表单管理")
public class InCoreCustomFormController {

    private final CoreCustomFormService coreCustomFormService;

    @GetMapping("updateById")
    @ApiOperation("修改表单为发布")
    public ResultBean updateById(@RequestParam Long id){
        coreCustomFormService.updateAndSendNotice(id);
        return ResultBean.buildSuccess();
    }

    @GetMapping("remindLast")
    @ApiOperation("距离结束通知")
    public ResultBean remindLast(@RequestParam Long id){
        RemindAgainDTO dto = new RemindAgainDTO();
        dto.setFormId(id);
        coreCustomFormService.remindAgain(dto);
        return ResultBean.buildSuccess();
    }

}
