package ink.wgink.module.wechat.controller.api.official.account;

import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.wechat.pojo.vos.official.account.OfficialAccountTemplateMessageSendVO;
import ink.wgink.module.wechat.service.official.account.IOfficialAccountTemplateMessageService;
import ink.wgink.pojo.result.SuccessResult;
import io.swagger.annotations.Api;
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.HashMap;
import java.util.Map;

/**
 * @ClassName: OfficialAccountDemoController
 * @Description: 公众号Demo
 * @Author: wanggeng
 * @Date: 2021/9/30 10:58 上午
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "公众号")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/official/account")
public class OfficialAccountDemoController {

    @Autowired
    private IOfficialAccountTemplateMessageService officialAccountTemplateMessageService;

    @GetMapping("send")
    public SuccessResult send() {
        OfficialAccountTemplateMessageSendVO officialAccountTemplateMessageSendVO = new OfficialAccountTemplateMessageSendVO();
        officialAccountTemplateMessageSendVO.setTouser("oXtnkwxZGEccnCVitqEcFV6TyNvM");
        officialAccountTemplateMessageSendVO.setTemplate_id("K5MLWBBVBE30bIo1cc04nYoePRWN5wlqlWDU9x5lxc4");
        Map<String, OfficialAccountTemplateMessageSendVO.Data> data = new HashMap<>();

        OfficialAccountTemplateMessageSendVO.Data startTime = new OfficialAccountTemplateMessageSendVO.Data();
        startTime.setValue("2021-10-01");

        OfficialAccountTemplateMessageSendVO.Data endTime = new OfficialAccountTemplateMessageSendVO.Data();
        endTime.setValue("2021-10-07");

        OfficialAccountTemplateMessageSendVO.Data remarks = new OfficialAccountTemplateMessageSendVO.Data();
        remarks.setValue("敬请期待");

        data.put("startTime", startTime);
        data.put("endTime", endTime);
        data.put("remarks", remarks);

        officialAccountTemplateMessageSendVO.setData(data);

        officialAccountTemplateMessageService.send(officialAccountTemplateMessageSendVO);
        return new SuccessResult();
    }

}
