package com.om.controller.user;

import com.om.entity.dto.AppBaseDTO;
import com.om.utils.AesUtil;
import com.om.utils.HuaweiObsUtil;
import com.om.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/app/obs")
@Api(tags = "app端obs相关接口")
public class AppObsController {

    @Resource
    private HuaweiObsUtil obsUtil;

    

    @PostMapping("/getObsConfig")
    @ApiOperation("获取obs直传配置")
    public Result  getObsConfig(@RequestBody AppBaseDTO dto){
        String ak = obsUtil.getAk();
        String sk = obsUtil.getSk();
        String endpoint = obsUtil.getEndpoint();

        Map<String,Object> claims = new HashMap();
        claims.put("ak",ak);
        claims.put("sk",sk);
        claims.put("endpoint",endpoint);
        String obs = AesUtil.generateObs(claims);

        return Result.ok(obs);
    }
}
