package com.gree.mall.manager.controller.wxCustomer;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.manager.bean.wxCustomer.WxCustomerBean;
import com.gree.mall.manager.bean.wxCustomer.WxCustomerTagBean;
import com.gree.mall.manager.helper.ResponseHelper;
import com.gree.mall.manager.logic.wxCustomer.WxCustomerLogic;
import com.gree.mall.manager.plus.entity.Tag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Slf4j
@RestController
@Api(value = "企业微信客户", tags = {"企业微信客户"})
@RequestMapping(value = "/wx/customer/", produces = "application/json; charset=utf-8")
public class WxCustomerController {
    @Autowired
    private WxCustomerLogic wxCustomerLogic;

    @GetMapping("/list")
    @ApiOperation("微信外部联系人列表")
    public ResponseHelper<IPage<WxCustomerBean>> list(
            @ApiParam(value = "keyword", required = false) @RequestParam(required = false) String keyword,
            @ApiParam(value = "标签id数组", required = false) @RequestParam(required = false) String[] tagIds,
            @ApiParam(value = "开始时间", required = false) @RequestParam(required = false) Date startTime,
            @ApiParam(value = "结束时间", required = false) @RequestParam(required = false) Date endtTime,
            @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
    ) {
        return ResponseHelper.success(wxCustomerLogic.list(keyword, tagIds, startTime, endtTime, pageNum, pageSize));
    }


    @GetMapping("/detail")
    @ApiOperation("微信外部联系人详情")
    public ResponseHelper<WxCustomerBean> detail(
            @ApiParam(value = "客户外部联系人externalUserId", required = true) @RequestParam String externalUserId
    ) {
        return ResponseHelper.success(wxCustomerLogic.detail(externalUserId));
    }


    @PostMapping("/tag/edit")
    @ApiOperation("打标签")
    public ResponseHelper edit(
            @ApiParam(value = "标签数据", required = true) @RequestBody WxCustomerTagBean wxCustomerTagBean) {
        wxCustomerLogic.edit(wxCustomerTagBean);
        return ResponseHelper.success();
    }


}
