package com.fs.crm.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.crm.domain.CrmCustomerLogs;
import com.fs.crm.service.ICrmCustomerLogsService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 客户日志Controller
 * 
 * @author fs
 * @date 2022-12-21
 */
@RestController
@RequestMapping("/crm/customerLogs")
public class CrmCustomerLogsController extends BaseController
{
    @Autowired
    private ICrmCustomerLogsService crmCustomerLogsService;

    /**
     * 查询客户日志列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CrmCustomerLogs crmCustomerLogs)
    {
        startPage();
        List<CrmCustomerLogs> list = crmCustomerLogsService.selectCrmCustomerLogsList(crmCustomerLogs);
        return getDataTable(list);
    }

    /**
     * 导出客户日志列表
     */
    @Log(title = "客户日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CrmCustomerLogs crmCustomerLogs)
    {
        List<CrmCustomerLogs> list = crmCustomerLogsService.selectCrmCustomerLogsList(crmCustomerLogs);
        ExcelUtil<CrmCustomerLogs> util = new ExcelUtil<CrmCustomerLogs>(CrmCustomerLogs.class);
        return util.exportExcel(list, "customerLogs");
    }

    /**
     * 获取客户日志详细信息
     */
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") Long logsId)
    {
        return AjaxResult.success(crmCustomerLogsService.selectCrmCustomerLogsById(logsId));
    }

    /**
     * 新增客户日志
     */
    @Log(title = "客户日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmCustomerLogs crmCustomerLogs)
    {
        return toAjax(crmCustomerLogsService.insertCrmCustomerLogs(crmCustomerLogs));
    }

    /**
     * 修改客户日志
     */
    @Log(title = "客户日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmCustomerLogs crmCustomerLogs)
    {
        return toAjax(crmCustomerLogsService.updateCrmCustomerLogs(crmCustomerLogs));
    }

    /**
     * 删除客户日志
     */
    @Log(title = "客户日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable Long[] logsIds)
    {
        return toAjax(crmCustomerLogsService.deleteCrmCustomerLogsByIds(logsIds));
    }
}
