package com.dsk.web.controller.business;

import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.domain.entity.BusinessRelateCompany;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.domain.BusinessIdDto;
import com.dsk.system.service.IBusinessRelateCompanyService;
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 AjaxResult companyRoleList(@RequestBody BusinessIdDto dto){
        return success(businessRelateCompanyService.companyRoleList(dto));
    }

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

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

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

    /**
     * 删除项目关联单位
     */
//    @PreAuthorize("@ss.hasPermi('system:company:remove')")
//    @Log(title = "项目关联单位", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{ids}")
    public AjaxResult 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));
//    }

}
