package com.zjrs.zwnw.portal.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import org.mohrss.leaf.core.framework.web.exception.AppException;
import com.zjrs.zwnw.portal.bpo.RcglBPO;
import com.zjrs.zwnw.portal.dto.ChangeFbglDTO;
import com.zjrs.zwnw.portal.dto.CommonFbglDTO;
import com.zjrs.zwnw.portal.dto.SaveRcglDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;

@Api("日程管理")
@RestController
@RequestMapping("/api/portal/rcgl/")
public class RcglController {
    private static final Logger LOG = LoggerFactory.getLogger(RcglController.class);

    @Resource
    private RcglBPO rcglBPO;

    @ApiOperation(value = "获取日程管理时间线信息", notes = "根据条件查询消息列表1")
    @PostMapping(value = "getRcgltimeline")
    public AjaxResponse getRcgltimeline(@RequestBody @Valid ChangeFbglDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        try {
            rcglBPO.getRcgltimeline(dto);
            ajaxResponse.setData("data", rcglBPO.getRcgltimeline(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "获取单个日程管理信息", notes = "根据条件查询消息列表1")
    @PostMapping(value = "getRcgl")
    public AjaxResponse getRcgl(@RequestBody @Valid CommonFbglDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        try {
            ajaxResponse.setData("data", rcglBPO.getRcgl(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "新增或修改日程管理", notes = "根据条件查询消息列表1")
    @PostMapping(value = "saveRcgl")
    public AjaxResponse saveRcgl(@RequestBody @Valid SaveRcglDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        try {
            rcglBPO.saveRcgl(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "删除日程管理", notes = "根据条件查询消息列表1")
    @PostMapping(value = "delRcgl")
    public AjaxResponse delRcgl(@RequestBody @Valid CommonFbglDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        try {
            rcglBPO.delRcgl(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
}

