package com.ruoyi.project.business.controller;

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

import com.ruoyi.project.business.domain.TcAccountContactHistory;
import com.ruoyi.project.business.service.ITcAccountContactHistoryService;
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.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 客户（组织）联系人履历Controller
 * 
 * @author ruoyi
 * @date 2024-04-23
 */
@RestController
@RequestMapping("/business/accountContactHistory")
public class TcAccountContactHistoryController extends BaseController
{
    @Autowired
    private ITcAccountContactHistoryService tcAccountContactHistoryService;

    /**
     * 查询客户（组织）联系人履历列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TcAccountContactHistory tcAccountContactHistory)
    {
        startPage();
        List<TcAccountContactHistory> list = tcAccountContactHistoryService.selectTcAccountContactHistoryList(tcAccountContactHistory);
        return getDataTable(list);
    }

    /**
     * 导出客户（组织）联系人履历列表
     */
    @Log(title = "客户（组织）联系人履历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TcAccountContactHistory tcAccountContactHistory)
    {
        List<TcAccountContactHistory> list = tcAccountContactHistoryService.selectTcAccountContactHistoryList(tcAccountContactHistory);
        ExcelUtil<TcAccountContactHistory> util = new ExcelUtil<TcAccountContactHistory>(TcAccountContactHistory.class);
        util.exportExcel(response, list, "客户（组织）联系人履历数据");
    }

    /**
     * 获取客户（组织）联系人履历详细信息
     */
    @GetMapping(value = "/{contactId}")
    public AjaxResult getInfo(@PathVariable("contactId") Long contactId)
    {
        return success(tcAccountContactHistoryService.selectTcAccountContactHistoryByContactId(contactId));
    }

    /**
     * 新增客户（组织）联系人履历
     */
    @Log(title = "客户（组织）联系人履历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcAccountContactHistory tcAccountContactHistory)
    {
        return toAjax(tcAccountContactHistoryService.insertTcAccountContactHistory(tcAccountContactHistory));
    }

    /**
     * 修改客户（组织）联系人履历
     */
    @Log(title = "客户（组织）联系人履历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcAccountContactHistory tcAccountContactHistory)
    {
        return toAjax(tcAccountContactHistoryService.updateTcAccountContactHistory(tcAccountContactHistory));
    }

    /**
     * 删除客户（组织）联系人履历
     */
    @Log(title = "客户（组织）联系人履历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contactIds}")
    public AjaxResult remove(@PathVariable Long[] contactIds)
    {
        return toAjax(tcAccountContactHistoryService.deleteTcAccountContactHistoryByContactIds(contactIds));
    }
}
