package com.ruoyi.ibs.list.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.CustInfoBusiness;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.ibs.list.domain.CustInfoMerchant;
import com.ruoyi.ibs.list.domain.CustInfoRetail;
import com.ruoyi.ibs.list.domain.MarketingCustomerListVo;
import com.ruoyi.ibs.list.domain.MarketingListVo;
import com.ruoyi.ibs.list.service.ICustInfoBusinessService;
import com.ruoyi.ibs.list.service.ICustInfoMerchantService;
import com.ruoyi.ibs.list.service.ICustInfoRetailService;
import com.ruoyi.ibs.list.service.ISysListService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 角色信息
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/grid/listSearch")
@Api("网格走访-清单查询")
public class SysListController extends BaseController
{
    @Autowired
    private ISysListService listService;

    @Autowired
    private ICustInfoRetailService iCustInfoRetailService;

    @Autowired
    private ICustInfoMerchantService iCustInfoMerchantService;

    @Autowired
    private ICustInfoBusinessService iCustInfoBusinessService;



//    @PreAuthorize("@ss.hasPermi('system:grid:list')")
    @GetMapping("/list")
    @ApiOperation("获取清单列表")
    @Log(title = "走访-清单查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "关键词，可以是清单名称和活动名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "groupType", value = "1我创建的，0推荐给我的", dataType = "String", dataTypeClass = String.class)
    })
    public TableDataInfo list(String keyword,String groupType)
    {
        //startPage();
        List<MarketingListVo> list = listService.selectMarketList(keyword,groupType);
        return getDataTable(list);
    }



//    @PreAuthorize("@ss.hasPermi('system:grid:list')")
    @GetMapping("/CustomerList")
    @ApiOperation("获取客户列表")
    @Log(title = "走访-清单查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupId", value = "清单id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "campaignId", value = "活动id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "keyword", value = "关键词，可以是客户号，证件号，手机号", dataType = "String", dataTypeClass = String.class)
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = MarketingCustomerListVo.class)
    })
    public TableDataInfo CustomerList(String groupId,String campaignId,String keyword)
    {
        //startPage();
        List<MarketingCustomerListVo> list = listService.selectCustomerList(groupId,campaignId,keyword);

        return getDataTable(list);
    }

//    @PreAuthorize("@ss.hasPermi('system:grid:list')")
    @GetMapping("/CustomerDetail")
    @Log(title = "走访-清单查询")
    @ApiOperation("获取个人客户详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "custId", value = "客户id", dataType = "String", dataTypeClass = String.class)
    })

    public CustInfoRetail CustomerDetail(String custId)
    {
        return iCustInfoRetailService.selectCustInfoRetailByCustId(custId);
    }

    @GetMapping("/MerchantDetail")
    @Log(title = "走访-清单查询")
    @ApiOperation("获取商户客户详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "custId", value = "客户id", dataType = "String", dataTypeClass = String.class)
    })

    public CustInfoMerchant MerchantDetail(String custId)
    {
        return iCustInfoMerchantService.selectCustInfoMerchantByCustId(custId);
    }

    @GetMapping("/BusinessDetail")
    @Log(title = "走访-清单查询")
    @ApiOperation("获取企业客户详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "custId", value = "客户id", dataType = "String", dataTypeClass = String.class)
    })

    public CustInfoBusiness BusinessDetail(String custId)
    {
        return iCustInfoBusinessService.selectCustInfoBusinessByCustId(custId);
    }




}
