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.BusinessContacts;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.service.IBusinessContactsService;
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/contacts")
public class BusinessContactsController extends BaseController
{
    @Autowired
    private IBusinessContactsService businessContactsService;

    /**
     * 分页查询项目联系人列表
     */
//    @PreAuthorize("@ss.hasPermi('system:contacts:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessContacts businessContacts)
    {
        startPage();
        List<BusinessContacts> list = businessContactsService.selectBusinessContactsList(businessContacts);
        return getDataTable(list);
    }

    /**
     * 新增项目联系人
     */
//    @PreAuthorize("@ss.hasPermi('system:contacts:add')")
//    @Log(title = "项目联系人", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusinessContacts businessContacts)
    {
        return toAjax(businessContactsService.insertBusinessContacts(businessContacts));
    }

    /**
     * 修改项目联系人
     */
//    @PreAuthorize("@ss.hasPermi('system:contacts:edit')")
//    @Log(title = "项目联系人", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusinessContacts businessContacts)
    {
        return toAjax(businessContactsService.updateBusinessContacts(businessContacts));
    }

//    /**
//     * 导出项目联系人列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:contacts:export')")
//    @Log(title = "项目联系人", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BusinessContacts businessContacts)
//    {
//        List<BusinessContacts> list = businessContactsService.selectBusinessContactsList(businessContacts);
//        ExcelUtil<BusinessContacts> util = new ExcelUtil<BusinessContacts>(BusinessContacts.class);
//        util.exportExcel(response, list, "项目联系人数据");
//    }

//    /**
//     * 获取项目联系人详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:contacts:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(businessContactsService.selectBusinessContactsById(id));
//    }

//    /**
//     * 删除项目联系人
//     */
//    @PreAuthorize("@ss.hasPermi('system:contacts:remove')")
//    @Log(title = "项目联系人", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(businessContactsService.deleteBusinessContactsByIds(ids));
//    }
}
