package com.fs.qw.controller;

import java.util.List;

import com.fs.company.domain.Company;
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.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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.sop.domain.CompanySopRole;
import com.fs.sop.service.ICompanySopRoleService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 公司SOP权限Controller
 * 
 * @author fs
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/sop/companySopRole")
public class CompanySopRoleController extends BaseController
{
    @Autowired
    private ICompanySopRoleService companySopRoleService;

    /**
     * 查询公司SOP权限列表
     */
    @PreAuthorize("@ss.hasPermi('sop:companySopRole:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanySopRole companySopRole)
    {
        startPage();
        List<Company> list = companySopRoleService.selectCompanySopRoleList(companySopRole);
        return getDataTable(list);
    }

    /**
     * 导出公司SOP权限列表
     */
    @PreAuthorize("@ss.hasPermi('sop:companySopRole:export')")
    @Log(title = "公司SOP权限", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanySopRole companySopRole)
    {
        List<Company> list = companySopRoleService.selectCompanySopRoleList(companySopRole);
        ExcelUtil<Company> util = new ExcelUtil<Company>(Company.class);
        return util.exportExcel(list, "公司SOP权限数据");
    }

    /**
     * 获取公司SOP权限详细信息
     */
    @PreAuthorize("@ss.hasPermi('sop:companySopRole:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companySopRoleService.selectCompanySopRoleById(id));
    }

    /**
     * 新增公司SOP权限
     */
    @PreAuthorize("@ss.hasPermi('sop:companySopRole:add')")
    @Log(title = "公司SOP权限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanySopRole companySopRole)
    {
        return toAjax(companySopRoleService.insertCompanySopRole(companySopRole));
    }

    /**
     * 修改公司SOP权限
     */
    @PreAuthorize("@ss.hasPermi('sop:companySopRole:edit')")
    @Log(title = "公司SOP权限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanySopRole companySopRole)
    {
        return toAjax(companySopRoleService.updateCompanySopRole(companySopRole));
    }

    /**
     * 删除公司SOP权限
     */
    @PreAuthorize("@ss.hasPermi('sop:companySopRole:remove')")
    @Log(title = "公司SOP权限", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companySopRoleService.deleteCompanySopRoleByIds(ids));
    }
}
