package com.gic.haoban.manage.web.controller.test;

import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.web.controller.WebBaseController;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.task.manage.api.service.TaskQuartzCallbackApiService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created 2018/12/17.
 *
 * @author hua
 */
@Controller
@RequestMapping("/test")
public class TestTaskController extends WebBaseController {

    @Autowired
    private TaskQuartzCallbackApiService taskQuartzCallbackApiService;
    @Autowired
    private HandoverOperationApiService handoverOperationApiService;

    @Autowired
    private MemberUnionidRelatedApiService memberUnionidRelatedApiService;

    @RequestMapping("/groupSendCreateEnd")
    @ResponseBody
    public HaobanResponse testListVo(String str) {
        if (StringUtils.isBlank(str)) {
            return resultResponse(HaoBanErrCode.ERR_2);
        }
        taskQuartzCallbackApiService.groupSendCreateEnd(str);
        return resultResponse(HaoBanErrCode.ERR_1);
    }

    @RequestMapping("/sendMessageAfter")
    @ResponseBody
    public HaobanResponse sendMessageAfter(String str) {
        if (StringUtils.isBlank(str)) {
            return resultResponse(HaoBanErrCode.ERR_2);
        }
        taskQuartzCallbackApiService.sendMessageAfter(str);
        return resultResponse(HaoBanErrCode.ERR_1);
    }

    @RequestMapping("/setTest")
    @ResponseBody
    public HaobanResponse setTest(String enterpriseId) {
        if (StringUtils.isBlank(enterpriseId)) {
            return resultResponse(HaoBanErrCode.ERR_2);
        }
        taskQuartzCallbackApiService.setTest(enterpriseId);
        return resultResponse(HaoBanErrCode.ERR_1);
    }

    @RequestMapping("/delTest")
    @ResponseBody
    public HaobanResponse delTest() {
        taskQuartzCallbackApiService.delTest();
        return resultResponse(HaoBanErrCode.ERR_1);
    }

    @RequestMapping("/dealQywxEnterpriseHandover")
    @ResponseBody
    public HaobanResponse dealQywxEnterpriseHandover(String wxEnterpriseId) {
        if (StringUtils.isBlank(wxEnterpriseId)) {
            return resultResponse(HaoBanErrCode.ERR_2);
        }
        handoverOperationApiService.dealQywxEnterpriseHandover(wxEnterpriseId);
        return resultResponse(HaoBanErrCode.ERR_1);
    }

    @RequestMapping("/dealQywxEnterpriseHandoverResult")
    @ResponseBody
    public HaobanResponse dealQywxEnterpriseHandoverResult(String wxEnterpriseId) {
        if (StringUtils.isBlank(wxEnterpriseId)) {
            return resultResponse(HaoBanErrCode.ERR_2);
        }
        handoverOperationApiService.dealQywxEnterpriseHandoverResult(wxEnterpriseId);
        return resultResponse(HaoBanErrCode.ERR_1);
    }

    /**
     * 处理标签同步
     * @param params
     * @return
     */
    @RequestMapping("/dealFriendTag")
    @ResponseBody
    public HaobanResponse dealFriendTag(String params) {
        if (StringUtils.isBlank(params)) {
            return resultResponse(HaoBanErrCode.ERR_2);
        }
        memberUnionidRelatedApiService.dealQywxExternalUser(params);
        return resultResponse(HaoBanErrCode.ERR_1);
    }
}
