package com.zjrs.zwnw.rlzysc.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.rlzysc.bpo.JxgwBPO;
import com.zjrs.zwnw.rlzysc.dto.JxgwCommDTO;
import com.zjrs.zwnw.rlzysc.dto.JxgwQueryDTO;
import com.zjrs.zwnw.rlzysc.dto.JxgwSaveDTO;
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.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;

/*
见习岗位管理
 */
@Api("见习岗位管理")
@RestController
@RequestMapping("/api/rlzysc/jxgwgl")
public class JxgwController {
    private static final Logger LOG = LoggerFactory.getLogger(JxgwController.class);

    @Resource
    private JxgwBPO jxgwBPO;
    /*
    见习岗位管理*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "见习岗位管理*获取列表")
    @PostMapping(value = "/getList")
    public AjaxResponse getList(@RequestBody @Valid JxgwQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", jxgwBPO.getList(dto));
        ajaxResponse.setData("pagenum", dto.getPagenum());
        ajaxResponse.setData("pagesize", dto.getPagesize());
        return ajaxResponse;
    }
    /*
    见习岗位管理*获取明细信息
     */
    @ApiOperation(value = "获取明细信息", notes = "见习岗位管理*获取明细信息")
    @PostMapping(value = "/getDetail")
    public AjaxResponse getDetail(@RequestBody @Valid JxgwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", jxgwBPO.getDetail(dto));
        return ajaxResponse;
    }
    /*
    见习岗位管理*保存
     */
    @ApiOperation(value = "保存见习岗位", notes = "见习岗位管理*保存见习岗位")
    @PostMapping(value = "/saveJxgw")
    public AjaxResponse saveJxgw(@RequestBody @Valid JxgwSaveDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        try {
            ajaxResponse.setData("rsrlzyjxgwlsh", jxgwBPO.saveJxgw(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        }
        return ajaxResponse;
    }
    /*
    见习岗位管理*删除见习岗位
     */
    @ApiOperation(value = "删除见习岗位", notes = "见习岗位管理*删除见习岗位")
    @PostMapping(value = "/delJxgw")
    public AjaxResponse delJxgw(@RequestBody @Valid JxgwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        jxgwBPO.delJxgw(dto);
        return ajaxResponse;
    }
    /*
    见习岗位管理*更新发布状态
     */
    @ApiOperation(value = "更新发布状态", notes = "见习岗位管理*更新发布状态")
    @PostMapping(value = "/updateFbzt")
    public AjaxResponse updateFbzt(@RequestBody @Valid JxgwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        jxgwBPO.updateFbzt(dto);
        return ajaxResponse;
    }
    /*
见习岗位管理*更新报名状态
 */
    @ApiOperation(value = "更新报名状态", notes = "见习岗位管理*更新报名状态")
    @PostMapping(value = "/updateBmzt")
    public AjaxResponse updateBmzt(@RequestBody @Valid JxgwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        jxgwBPO.updateBmzt(dto);
        return ajaxResponse;
    }

    /*
    见习岗位管理*导出
     */
    @ApiOperation(value = "导出", notes = "见习岗位管理*导出")
    @PostMapping("/exportJxgw")
    public void exportJxgw(@RequestBody JxgwQueryDTO dto, HttpServletResponse res) throws IOException {
        LOG.info("见习岗位管理*导出,start");
        jxgwBPO.exportJxgw(dto, res);
        LOG.info("见习岗位管理*导出,end");
    }

}
