package com.miaxis.app.controller.customer;

import com.miaxis.collection.service.ICollectionInfoService;
import com.miaxis.common.constant.Constants;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.page.ResponsePageInfo;
import com.miaxis.customer.domain.CustomerInfo;
import com.miaxis.customer.service.ICustomerInfoService;
import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【小程序-客户信息】Controller
 *
 * @author miaxis
 * @date 2021-03-10
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(Constants.STUDENT_PREFIX+"/applet/customer")
@Api(tags = {"【小程序-客户信息】"})
public class AppletCustomerInfoController extends BaseController {

    private final ICustomerInfoService customerInfoService;


    /**
     * 查询客户信息列表
     */
    @GetMapping("/list")
    @ApiOperation("查询客户信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<CustomerInfo> list(@ModelAttribute CustomerInfo customerInfo) {
        startPage();
        List<CustomerInfo> list = customerInfoService.selectCustomerInfoList(customerInfo);
        return toResponsePageInfo(list);
    }


    /**
     * 查询所属品类商家
     */
    @GetMapping(value = "/getCustomerListByProductId/{id}")
    @ApiOperation("查询所属品类商家")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<ExhibitionCustomerInfoVo> getCustomerListByProductId(
            @ApiParam(name = "id", value = "品类id", required = true)
            @PathVariable("id") Long id
    ) {
        startPage();
        List<ExhibitionCustomerInfoVo> list = customerInfoService.getCustomerListByProductId(id);
        return toResponsePageInfo(list);
    }

    /**
     * 查询精选商家列表 根据收藏数排行
     */
    @GetMapping(value = "/getCustomerListByCollectionCount")
    @ApiOperation("查询精选商家列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<ExhibitionCustomerInfoVo> getCustomerListByCollectionCount() {
        startPage();
        List<ExhibitionCustomerInfoVo> list = customerInfoService.getCustomerListByCollectionCount();
        return toResponsePageInfo(list);
    }


}
