package com.dsk.web.controller.business;

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

import com.dsk.common.core.domain.entity.BusinessContacts;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.system.service.IBusinessContactsService;
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/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));
//    }
}
