package thyyxxk.webserver.controller.outpatient.wxapi;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.service.outpatient.wxapi.SendWxInfoService;

@Slf4j
@RestController
@RequestMapping("/sendWxInfo")
public class SendWxInfoController {
    private final SendWxInfoService service;

    @Autowired
    public SendWxInfoController(SendWxInfoService service) {
        this.service = service;
    }

    @PassToken
    @GetMapping("/send")
    public JSONObject sendCorpWxMsg(@RequestParam("touser") String touser,
                                    @RequestParam("content") String content) {
        return service.sendCorpWxMsg(touser, content);
    }

    @PassToken
    @GetMapping("/createGroupChat")
    public JSONObject createGroupChat(@RequestParam("name") String name) {
        return service.createGroupChat(name);
    }

    @PassToken
    @GetMapping("/sendGroupMsg")
    public JSONObject sendGroupMsg(@RequestParam("chatid") String chatid,
                                   @RequestParam("content") String content) {
        return service.sendGroupMsg(chatid, content);
    }
}
