package com.ruoyi.web.modules.industryservice.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.modules.industryservice.domain.BizPasture;
import com.ruoyi.web.modules.industryservice.service.IBizPastureService;

/**
 * 牧场管理
 */
@RestController
@RequestMapping("/dataModel/pasture")
public class BizPastureController extends BaseController
{
    @Autowired
    private IBizPastureService bizPastureService;

    @PreAuthorize("@ss.hasPermi('dataModel:pasture:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPasture query)
    {
        startPage();
        List<BizPasture> list = bizPastureService.selectBizPastureList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('dataModel:pasture:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizPastureService.selectBizPastureById(id));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:pasture:sync')")
    @Log(title = "牧场管理", businessType = BusinessType.OTHER)
    @PostMapping("/sync")
    public AjaxResult sync()
    {
        return success(bizPastureService.syncFromThirdParty());
    }
}
