package com.dsk.biz.controller;

import com.dsk.biz.domain.BusinessRelateCompany;
import com.dsk.biz.domain.bo.BusinessIdDto;
import com.dsk.biz.service.IBusinessRelateCompanyService;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目相关企业Controller
 *
 * @author lxl
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/business/company")
public class BusinessRelateCompanyController extends BaseController
{
    @Autowired
    private IBusinessRelateCompanyService businessRelateCompanyService;

    /**
     * 查询相关企业角色
     */
    @PostMapping("/role/list")
    public R<List<String>> companyRoleList(@RequestBody BusinessIdDto dto){
        return R.ok(businessRelateCompanyService.companyRoleList(dto));
    }

    /**
     * 查询项目相关企业列表
     */
//    @PreAuthorize("@ss.hasPermi('system:company:list')")
    @GetMapping("/list")
    public TableDataInfo<BusinessRelateCompany> list(BusinessRelateCompany bo, PageQuery pageQuery)
    {
        return businessRelateCompanyService.selectBusinessRelateCompanyList(bo, pageQuery);
    }

    /**
     * 新增项目关联单位
     */
//    @PreAuthorize("@ss.hasPermi('system:company:add')")
//    @Log(title = "项目关联单位", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R<Void> add(@RequestBody BusinessRelateCompany businessRelateCompany)
    {
        return toAjax(businessRelateCompanyService.insertBusinessRelateCompany(businessRelateCompany));
    }

    /**
     * 修改项目关联单位
     */
//    @PreAuthorize("@ss.hasPermi('system:company:edit')")
//    @Log(title = "项目关联单位", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public R<Void> edit(@RequestBody BusinessRelateCompany businessRelateCompany)
    {
        return toAjax(businessRelateCompanyService.updateBusinessRelateCompany(businessRelateCompany));
    }

    /**
     * 删除项目关联单位
     */
//    @PreAuthorize("@ss.hasPermi('system:company:remove')")
//    @Log(title = "项目关联单位", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{ids}")
    public R<Void> remove(@PathVariable Long[] ids)
    {
        return toAjax(businessRelateCompanyService.deleteBusinessRelateCompanyByIds(ids));
    }

//    /**
//     * 导出项目关联单位列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:company:export')")
//    @Log(title = "项目关联单位", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BusinessRelateCompany businessRelateCompany)
//    {
//        List<BusinessRelateCompany> list = businessRelateCompanyService.selectBusinessRelateCompanyList(businessRelateCompany);
//        ExcelUtil<BusinessRelateCompany> util = new ExcelUtil<BusinessRelateCompany>(BusinessRelateCompany.class);
//        util.exportExcel(response, list, "项目关联单位数据");
//    }

//    /**
//     * 获取项目关联单位详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:company:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(businessRelateCompanyService.selectBusinessRelateCompanyById(id));
//    }

}
