package com.yunfeiyun.agmp.fms.controller;

import java.util.List;

import com.yunfeiyun.agmp.fms.domain.TmnLand;
import com.yunfeiyun.agmp.fms.domain.reqvo.TmnBaseLandReqVo;
import com.yunfeiyun.agmp.fms.service.ITmnLandService;
import org.springframework.security.access.prepost.PreAuthorize;
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.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunfeiyun.agmp.common.annotation.Log;
import com.yunfeiyun.agmp.common.core.controller.BaseController;
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
import com.yunfeiyun.agmp.common.enums.BusinessType;
import com.yunfeiyun.agmp.common.core.page.TableDataInfo;

/**
 * 设备基地Controller
 * 
 * @author 杨晓辉
 * @date 2023-07-12
 */
@RestController
@RequestMapping("/tmn/land")
public class TmnLandController extends BaseController
{
    @Autowired
    private ITmnLandService tmnLandService;

    /**
     * 查询设备基地列表
     */
    @PreAuthorize("@ss.hasPermi('tmn:land:list')")
    @GetMapping("/list")
    public TableDataInfo list(TmnLand tmnLand)
    {
        startPage();
        List<TmnLand> list = tmnLandService.selectTmnLandList(tmnLand);
        return getDataTable(list);
    }

    /**
     * 设备绑定基地
     */
    @PreAuthorize("@ss.hasPermi('tmn:land:bind')")
    @Log(title = "设备", businessType = BusinessType.INSERT)
    @PostMapping("/bind")
    public AjaxResult bind(@RequestBody TmnBaseLandReqVo tmnBaseLandReqVo)
    {
        return toAjax(tmnLandService.insertTmnBaseLandByBind(tmnBaseLandReqVo));
    }

    /**
     * 设备解绑基地
     */
    @PreAuthorize("@ss.hasPermi('tmn:land:unbind')")
    @Log(title = "设备", businessType = BusinessType.DELETE)
    @DeleteMapping("/unbind")
    public AjaxResult unbind(@RequestBody TmnBaseLandReqVo tmnBaseLandReqVo)
    {
        return toAjax(tmnLandService.deleteTmnLandByTmnlandId(tmnBaseLandReqVo));
    }
}
