package com.fs.app.controller;


import com.fs.wx.cp.config.WxCpConfiguration;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import org.springframework.beans.factory.annotation.Autowired;
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;


@RestController
@RequestMapping(value="/")
public class TestController extends AppBaseController {


	@Autowired
	private WxCpConfiguration wxCpConfiguration;

	@ApiOperation("获取数据字典")
	@GetMapping("/WW_verify_vFu5z0l4wIXrSMbr.txt")
	public String getDicts(
	){

		return "vFu5z0l4wIXrSMbr";

	}

	@ApiOperation("test")
	@GetMapping("/sendTest")
	public WxCpMessageSendResult sendTest(
	) throws WxErrorException {
		WxCpService cpService = wxCpConfiguration.getCpService(1000002);
		WxCpExternalContactService externalContactService=cpService.getExternalContactService();
		List<String> list=externalContactService.listExternalContacts("YuZhongXin");
		WxCpMessage message=new WxCpMessage();
		message.setAgentId(1000002);
		message.setToUser("YuZhongXin");
		message.setContent("test");
		message.setMsgType("text");
		WxCpMessageService messageService=cpService.getMessageService();
		cpService.getExternalContactService();
		WxCpMessageSendResult data=messageService.send(message);
		return data;

	}







}
