package com.ruoyi.project.business.controller;

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

import com.ruoyi.project.business.domain.TcAccountHistory;
import com.ruoyi.project.business.service.ITcAccountHistoryService;
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/accountHistory")
public class TcAccountHistoryController extends BaseController
{
    @Autowired
    private ITcAccountHistoryService tcAccountHistoryService;

    /**
     * 查询客户（组织）履历列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TcAccountHistory tcAccountHistory)
    {
        startPage();
        List<TcAccountHistory> list = tcAccountHistoryService.selectTcAccountHistoryList(tcAccountHistory);
        return getDataTable(list);
    }

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

    /**
     * 获取客户（组织）履历详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tcAccountHistoryService.selectTcAccountHistoryById(id));
    }

    /**
     * 新增客户（组织）履历
     */
    @Log(title = "客户（组织）履历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcAccountHistory tcAccountHistory)
    {
        return toAjax(tcAccountHistoryService.insertTcAccountHistory(tcAccountHistory));
    }

    /**
     * 修改客户（组织）履历
     */
    @Log(title = "客户（组织）履历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcAccountHistory tcAccountHistory)
    {
        return toAjax(tcAccountHistoryService.updateTcAccountHistory(tcAccountHistory));
    }

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