package com.ruoyi.ibs.list.controller;

import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.ibs.list.domain.CustLeadReg;
import com.ruoyi.ibs.list.domain.CustLeadRegDTO;
import com.ruoyi.ibs.list.domain.CustLeadRegListDTO;
import com.ruoyi.ibs.list.domain.CustLeadRegVO;
import com.ruoyi.ibs.list.service.CustLeadRegService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * @Author 吴凯程
 * @Date 2025/10/3
 **/
@Api(tags ="潜客登记接口")
@RestController
@RequestMapping("/cust/lead")
public class CustLeadRegController extends BaseController {

    @Resource
    private CustLeadRegService custLeadRegService;

    @GetMapping(value = "/list")
    @Log(title = "走访-查询潜客登记列表")
    @ApiOperation("查询潜客登记列表")
    public TableDataPageInfo<CustLeadReg> list(CustLeadRegListDTO custLeadRegListDTO) {
        Page<Object> pages = startPage();
        List<CustLeadReg> custLeadRegs = custLeadRegService.selectList(custLeadRegListDTO);
        return getDataTable(custLeadRegs, pages);
    }

    @PostMapping(value = "/add")
    @Log(title = "走访-新增潜在客户信息")
    @ApiOperation("新增潜在客户信息")
    public AjaxResult addCustLeadReg( CustLeadRegDTO custLeadRegDTO) {
        return success(custLeadRegService.addCustLeadReg(custLeadRegDTO));
    }

    @GetMapping(value = "/select")
    @Log(title = "走访-查询潜客登记信息")
    @ApiOperation("查询潜客登记信息")
    public R<CustLeadRegVO> getCustLeadReg(@RequestParam String custId) {
        return R.ok(custLeadRegService.getCustLeadReg(custId));
    }

    @GetMapping(value = "/update/reg/status")
    @Log(title = "走访-修改潜客开户状态")
    @ApiOperation("修改潜客开户状态")
    public AjaxResult updateCustLeadRegStatus(@RequestParam String custId) {
        return success(custLeadRegService.updateCustLeadRegStatus(custId));
    }


}
