package com.ruoyi.ibs.cmpm.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.ibs.cmpm.domain.dto.VisitCustReachDTO;
import com.ruoyi.ibs.cmpm.domain.dto.VisitCustReachListDTO;
import com.ruoyi.ibs.cmpm.domain.vo.VisitCustReachListVO;
import com.ruoyi.ibs.cmpm.domain.vo.VisitCustReachVO;
import com.ruoyi.ibs.cmpm.service.VisitCustReachService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Author 吴凯程
 * @Date 2025/12/11
 **/
@Api(tags = "客户接触记录接口")
@RestController
@RequestMapping("/cust/reach")
public class VisitCustReachController extends BaseController {

    @Resource
    private VisitCustReachService visitCustReachService;

    @ApiOperation("查询客户接触记录列表")
    @Log(title = "客户接触记录-查询客户接触记录列表")
    @GetMapping("/list")
    public R<PageInfo<VisitCustReachListVO>> queryVisitCustReachList(@Valid VisitCustReachListDTO visitCustReachListDTO){
        return R.ok(visitCustReachService.queryVisitCustReachList(visitCustReachListDTO));
    }

    @ApiOperation("查询客户搜索框")
    @Log(title = "客户接触记录-查询客户搜索框")
    @GetMapping("/query")
    public R<List<VisitCustReachVO>> queryVisitCustReach(@RequestParam String custName){
        return R.ok(visitCustReachService.queryVisitCust(custName));
    }

    @ApiOperation("保存客户接触记录")
    @Log(title = "客户接触记录-保存客户接触记录")
    @PostMapping("/save")
    public R<String> saveVisitCustReach(@RequestBody VisitCustReachDTO visitCustReachDTO){
        return R.ok(visitCustReachService.saveVisitCustReachDTO(visitCustReachDTO));
    }

    @ApiOperation("查询客户历史接触记录")
    @Log(title = "客户接触记录-查询客户历史接触记录")
    @GetMapping("/query/history")
    public R<List<VisitCustReachListVO>> queryVisitCustReachListByCustId(@RequestParam String custId){
        return R.ok(visitCustReachService.queryVisitCustReachListByCustId(custId));
    }
}
