package com.ruoyi.web.controller.system;

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.system.domain.Company;
import com.ruoyi.system.service.ICompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业信息Controller
 *
 * @author lyp
 * @date 2023-08-30
 */
@Api(tags = "PC企业信息相关接口")
@RestController
@RequestMapping("/system/company")
public class CompanyController extends BaseController {
    @Autowired
    private ICompanyService companyService;

    /**
     * 查询企业信息列表
     */
    @ApiOperation("企业信息列表")
    //TODO 20230920PreAuthorize("@("@ss.hasPermi('company:company:list')")
    @GetMapping("/list")
    public TableDataInfo list(Company company) {
        startPage();
        List<Company> list = companyService.selectCompanyList(company);
        return getDataTable(list);
    }

    /**
     * 导出企业信息列表
     //TODO 20230920PreAuthorize("@("@ss.hasPermi('company:company:export')")
     @Log(title = "企业信息", businessType = BusinessType.EXPORT)
     @PostMapping("/export") public void export(HttpServletResponse response, Company company)
     {
     List<Company> list = companyService.selectCompanyList(company);
     ExcelUtil<Company> util = new ExcelUtil<Company>(Company.class);
     util.exportExcel(response, list, "企业信息数据");
     }
     */

    /**
     * 获取企业信息详细信息
     */
    @ApiOperation("企业信息详细信息")
    //TODO 20230920PreAuthorize("@("@ss.hasPermi('company:company:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(companyService.selectCompanyById(id));
    }

    /**
     * 新增企业信息
     //TODO 20230920PreAuthorize("@("@ss.hasPermi('company:company:add')")
     @Log(title = "企业信息", businessType = BusinessType.INSERT)
     @PostMapping public AjaxResult add(@RequestBody Company company)
     {
     return toAjax(companyService.insertCompany(company));
     }
     */

    /**
     * 修改企业信息
     */
    @ApiOperation("企业信息修改")
    //TODO 20230920PreAuthorize("@("@ss.hasPermi('company:company:edit')")
    @Log(title = "企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Company company) {
        return toAjax(companyService.updateCompany(company));
    }

    /**
     * 删除企业信息
     //TODO 20230920PreAuthorize("@("@ss.hasPermi('company:company:remove')")
     @Log(title = "企业信息", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids)
     {
     return toAjax(companyService.deleteCompanyByIds(ids));
     }
     */
}
