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.SysAreaCheck;
import com.xunmei.system.service.ISysAreaCheckService;
import com.xunmei.system.service.ISysAreaService;
import com.xunmei.system.service.ISysOrgService;
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.SysNfcBind;
import com.xunmei.system.service.ISysNfcBindService;
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 = {"SysNfcBind"})
@RestController
@RequestMapping("/bind")
public class SysNfcBindController extends BaseController {
    @Autowired
    private ISysNfcBindService sysNfcBindService;
    @Autowired
    private ISysAreaService sysAreaService;
    @Autowired
    private ISysAreaCheckService sysAreaCheckService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "查询SysNfcBind列表")
    @RequiresPermissions("system:bind:list")
    @GetMapping("/list")
    public TableDataInfo<SysNfcBind> list(SysNfcBind sysNfcBind) {
        return sysNfcBindService.selectPage(sysNfcBind);
    }


    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取SysNfcBind详细信息")
    @RequiresPermissions("system:bind:query")
    @GetMapping(value = {"/", "/{id}"})
    public AjaxResult getInfo(@PathVariable(value = "id", required = false) Long id) {
        AjaxResult ajax = AjaxResult.success();
        SysNfcBind sysNfcBind = sysNfcBindService.selectSysNfcBindById(id);
        Long checkId = null;
        if (null != sysNfcBind) {
            checkId = sysNfcBind.getCheckId();
        }
        List<SysArea> sysAreas = sysAreaService.selectSysAreaList(new SysArea());
        List<SysAreaCheck> areaCheck = sysAreaCheckService.selectSysAreaCheckList(new SysAreaCheck().setId(checkId));
        ajax.put(AjaxResult.DATA_TAG, sysNfcBind);
        ajax.put("areas", sysAreas);
        ajax.put("checks", areaCheck);
        return ajax;
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation(value = "新增SysNfcBind")
    @RequiresPermissions("system:bind:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysNfcBind sysNfcBind) {
        return toAjax(sysNfcBindService.insertSysNfcBind(sysNfcBind));
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation(value = "修改SysNfcBind")
    @RequiresPermissions("system:bind:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysNfcBind sysNfcBind) {
        return toAjax(sysNfcBindService.updateSysNfcBind(sysNfcBind));
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation(value = "删除SysNfcBind")
    @RequiresPermissions("system:bind:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysNfcBindService.deleteSysNfcBindByIds(ids));
    }
}
