package com.css.txw.sso.controller.thirdparty;//package com.css.lsl.sso.controller.thirdparty;
//
//
//import cn.hutool.crypto.SecureUtil;
//import cn.hutool.http.HttpRequest;
//import cn.hutool.http.HttpResponse;
//import cn.hutool.http.HttpStatus;
//import com.alibaba.fastjson.JSONObject;
//import com.css.znsb.framework.common.pojo.CommonResult;
//import com.css.ckts.sso.pojo.vo.thirdparty.GssbTokenVO;
//import com.css.ckts.sso.util.AesUtil;
//import io.swagger.v3.oas.annotations.Operation;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import java.net.URLEncoder;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@Tag(name = "对接个税申报系统")
//@RestController
//@RequestMapping("/gssb")
//@Slf4j
//public class GssbController {
//
//    //租户ID  平台分配
//    private static String tenantId = "zrgssy_admin";
//    //用户名  平台分配
//    private static String username = "12586555655";
//    //密码  平台分配
//    private static String password = "tKlkv*oM";
//
//    // 固定的
//    private static String authorization = "Basic bWFnaWNjdWJlX2ludm9pY2U6bWFnaWNjdWJlX2ludm9pY2Vfc2VjcmV0";
//    // 密码AES加密秘钥
//    private static String aesKey = "O2BEeIv399qHQNhD6aGW8R8DEj4bqHXm";
//
//    // 平台根url
//    private static String baseUrl = "https://zr.jcsk100.com/api/";
//
//    // token url
//    private static String tokenUrl = "cube-auth/oauth/token";
//
//
//
//    @Operation(summary = "获取token", description = "密码模式与个税申报系统对接")
//    @PostMapping("/getToken")
//    public CommonResult<GssbTokenVO> getToken(){
//        final GssbTokenVO gssbTokenVO = new GssbTokenVO();
//        HttpResponse response = reqSaasToken();
//        log.info("获取 Saas 授权信息 body：{}", response.body());
//        if (response.getStatus() == HttpStatus.HTTP_OK) {
//            String body = response.body();
//            log.info("Gssb Response->{}",body);
//            JSONObject responseJson = JSONObject.parseObject(body);
//            String accessToken = responseJson.getString("access_token");
//            String refreshToken = responseJson.getString("refresh_token");
//            gssbTokenVO.setAccessToken(accessToken);
//            gssbTokenVO.setRefreshToken(refreshToken);
//        }
//        gssbTokenVO.setTenantId(tenantId);
//        return CommonResult.success(gssbTokenVO);
//    }
//
//
//    public static HttpResponse reqSaasToken() {
//        String param = "?tenantId=" + tenantId + "&username=" + username + "&password=" + URLEncoder.encode(encodeAes(SecureUtil.md5(password))) + "&grant_type=password&scope=all&type=account";
//        String url = baseUrl + tokenUrl + param;
//
//        return HttpRequest.post(url)
//                .header("Content-Type", "application/json")
//                .header("Authorization", authorization)
//                .header("Tenant-Id", tenantId)
//                .execute();
//    }
//
//    public static String encodeAes(String txt) {
//        return AesUtil.encryptToBase64(txt, aesKey);
//    }
//
//}
