package cn.pluss.platform.controller.wx;

import cn.pluss.platform.annotation.PassToken;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.wx.WxCertService;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequiredArgsConstructor
@RequestMapping("/wx")
public class WxController {

    private final WxCertService wxCertService;

    @PassToken
    @PostMapping("/wxCert")
    @ResponseBody
    public Result<JSONObject> wxCert(String userId, String merchantCode, Integer channelId) {
        wxCertService.wxCert(userId, merchantCode, channelId);
        return ResultGenerator.genSuccessResult("微信实名认证申请成功", null);
    }

    @PostMapping("/wxCert/result")
    @ResponseBody
    public Result<JSONObject> wxCertResult(@RequestParam String userId) {
        // TODO 暂无用，后面再写
        return ResultGenerator.genSuccessResult("微信实名认证成功", null);
    }

    @PostMapping("/wxCert/cancel")
    @ResponseBody
    public Result<JSONObject> wxCertCancel(String userId, String merchantCode, Integer channelId) {
        wxCertService.wxCertCancel(userId, merchantCode, channelId);
        return ResultGenerator.genSuccessResult("微信认证申请已经撤销", null);
    }
}
