package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.msg.WxMsgRecord;
import com.iformall.enums.EnumAssignTagsTrigger;
import com.iformall.mq.MqBaseProducer;
import com.iformall.mq.impl.RabbitMqMessageProducer;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCUserTagsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Api(description = "登录相关接口")
public class UserTagsController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    WxCUserTagsService wxCUserTagsService;

    @Autowired
    WxCUserBasicInfoService wxCUserBasicInfoService;

    @GetMapping("/userTag")
    public void mqtest() {
        WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo();

        int pageIndex = 1;
        final int pageSize = 1000;

        PageInfo page;
        do{
            page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageIndex++, pageSize);
            page.getList().stream().forEach(cubi -> {
                long lStart = System.currentTimeMillis();
                wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_SCAN, cubi);
                logger.info("user tag cost time: {}", System.currentTimeMillis() - lStart);
            });
        } while ((page.isHasNextPage()));
    }
}