package com.dsk.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dsk.common.core.domain.entity.BusinessRelateCompany;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.system.domain.BusinessIdDto;
import com.dsk.system.service.IBusinessRelateCompanyService;
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.dsk.common.annotation.Log;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.enums.BusinessType;
import com.dsk.common.core.page.TableDataInfo;

/**
 * 项目关联单位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: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));
//    }

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