/*
package com.lakala.zf.laop.java.sdk.demo.notify;

import com.lakala.zf.laop.java.sdk.demo.BaseCommonDemo;
import com.lkl.laop.sdk.LKLSDK;
import com.lkl.laop.sdk.notification.NotificationResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

*/
/**
 * @author nxj
 * @date 2023/8/18 17:02
 * @description 处理拉卡拉推送DEMO
 *//*

@RestController
public class NotificationHandlerDemo extends BaseCommonDemo {

    */
/**
     * @param request spring-boot 2.x 使用javax.servlet.http.HttpServletRequest接收
     *                spring-boot 3.x 使用jakarta.servlet.http.HttpServletRequest接收
     * @return
     * @throws Exception
     *//*

    @RequestMapping("/messageHandle")
    public ResponseEntity<?> messageHandle(HttpServletRequest request) throws Exception {
        // 1. 配置初始化
        doInit();

        // spring-boot 2.x 直接调用读取请求提并验签方法,返回请求体
        String body = LKLSDK.notificationHandle(request);

        //spring-boot 3.x 先读取请求体及请求头中的认证信息，SDK提供验签方法
//        LKLSDK.notificationHandle(getBody(request), getAuthorization(request));

        System.out.println("验签成功,请求body：" + body);

        //业务处理

        //标准响应成功格式
        return ResponseEntity.ok(NotificationResult.ok());
    }


    */
/**
     * 读取请求头
     *//*

    private String getAuthorization(HttpServletRequest request) {
        return request.getHeader("Authorization");
    }

    */
/**
     * 读取请求体
     *//*

    private String getBody(HttpServletRequest request) {
        try (InputStreamReader in = new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8)) {
            StringBuilder bf = new StringBuilder();
            int len;
            char[] chs = new char[1024];
            while ((len = in.read(chs)) != -1) {
                bf.append(new String(chs, 0, len));
            }
            return bf.toString();
        } catch (Exception e) {
            throw new RuntimeException("读取body失败");
        }

    }

}
*/
