package org.springblade.modules.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wn.common.datamodel.ResultDTO;
import lombok.AllArgsConstructor;
import org.springblade.common.auth.permission.DisableLoginVerify;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.modules.app.common.dto.EnteringZhejiangFilingDTO;
import org.springblade.modules.app.common.query.EnteringZhejiangFilingQuery;
import org.springblade.modules.app.manager.EnteringZhejiangFilingManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@NonDS
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/entering")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class EnteringController extends BladeController {

    @Autowired
    private EnteringZhejiangFilingManager enteringZhejiangFilingManager;

    //@ApiOperation(value = "查询省外养殖场登记信息列表")
    @GetMapping("/page")
    public R<Page<EnteringZhejiangFilingDTO>> pageEnteringZhejiangFiling(EnteringZhejiangFilingQuery enteringZhejiangFilingQuery) {
        return R.data(enteringZhejiangFilingManager.pageEnteringZhejiangFiling(enteringZhejiangFilingQuery));
    }

    @GetMapping("{id}")
    public R<EnteringZhejiangFilingDTO> getEnteringZhejiangFiling(@PathVariable Long id) {
        enteringZhejiangFilingManager.modifyEnteringZhejiangFiling(id);
        return R.data(enteringZhejiangFilingManager.getEnteringZhejiangFiling(id));
    }

    //@ApiOperation(value = "修改状态为已查看")
    @PutMapping("{id}")
    public R modifyEnteringZhejiangFiling(@PathVariable Long id) {
        return R.status(enteringZhejiangFilingManager.modifyEnteringZhejiangFiling(id));
    }

    //@ApiOperation(value = "导出Excel")
    @GetMapping("/export")
    @DisableLoginVerify
    public void exportEnteringZhejiangFiling(String ids, HttpServletResponse response) throws Exception{
        enteringZhejiangFilingManager.exportEnteringZhejiangFilings(ids, response);
    }
}
