package com.xunmei.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.xunmei.system.api.domain.SysArea;
import com.xunmei.system.domain.SysNfcBind;
import com.xunmei.system.service.ISysAreaService;
import com.xunmei.system.service.ISysNfcBindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xunmei.common.log.annotation.Log;
import com.xunmei.common.log.enums.BusinessType;
import com.xunmei.common.security.annotation.RequiresPermissions;
import com.xunmei.system.domain.SysAreaCheck;
import com.xunmei.system.service.ISysAreaCheckService;
import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xunmei.common.core.web.page.TableDataInfo;

/**
 * 区域采集点Controller
 *
 * @author xunmei
 * @date 2023-08-15
 */
@Api(tags = {"SysAreaCheck"})
@RestController
@RequestMapping("/check")
public class SysAreaCheckController extends BaseController {
    @Autowired
    private ISysAreaCheckService sysAreaCheckService;
    @Autowired
    private ISysNfcBindService sysNfcBindService;
    @Autowired
    private ISysAreaService sysAreaService;
    /**
     * 查询区域采集点列表
     */
    @ApiOperation(value = "查询SysAreaCheck列表")
    @RequiresPermissions("system:check:list")
    @GetMapping("/list")
    public TableDataInfo<SysAreaCheck> list(SysAreaCheck sysAreaCheck) {

        return sysAreaCheckService.selectPage(sysAreaCheck);
    }


    /**
     * 获取区域采集点详细信息
     */
    @ApiOperation(value = "获取SysAreaCheck详细信息")
    @RequiresPermissions("system:check:query")
    @GetMapping(value = {"/", "/{id}"})
    public AjaxResult getInfo(@PathVariable(value = "id", required = false) Long id) {
        AjaxResult ajax = AjaxResult.success();
        SysAreaCheck areaCheck = sysAreaCheckService.selectSysAreaCheckById(id);
        List<SysArea> sysAreas = sysAreaService.selectSysAreaList(new SysArea());
        ajax.put(AjaxResult.DATA_TAG, areaCheck);
        ajax.put("areas", sysAreas);
        return ajax;
    }

    /**
     * 新增区域采集点
     */
    @ApiOperation(value = "新增SysAreaCheck")
    @RequiresPermissions("system:check:add")
    @Log(title = "区域采集点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAreaCheck sysAreaCheck) {
        return toAjax(sysAreaCheckService.insertSysAreaCheck(sysAreaCheck));
    }

    /**
     * 修改区域采集点
     */
    @ApiOperation(value = "修改SysAreaCheck")
    @RequiresPermissions("system:check:edit")
    @Log(title = "区域采集点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAreaCheck sysAreaCheck) {
        return toAjax(sysAreaCheckService.updateSysAreaCheck(sysAreaCheck));
    }

    /**
     * 删除区域采集点
     */
    @ApiOperation(value = "删除SysAreaCheck")
    @RequiresPermissions("system:check:remove")
    @Log(title = "区域采集点", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysAreaCheckService.deleteSysAreaCheckByIds(ids));
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取SysNfcBind通过区域id")
    @RequiresPermissions("system:bind:query")
    @GetMapping(value = "/getAreaCheckInfo/{areaId}")
    public AjaxResult getAreaCheckInfo(@PathVariable(value = "areaId", required = false) Long areaId) {
        AjaxResult ajax = AjaxResult.success();
        List<SysAreaCheck> sysAreaChecks = sysAreaCheckService.selectByAreaId(areaId);
        ajax.put(AjaxResult.DATA_TAG, sysAreaChecks);
        return ajax;
    }
}
