package com.izouma.nineth.web; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.aliyun.cdn20180510.Client; import com.aliyun.cdn20180510.models.RefreshObjectCachesRequest; import com.aliyun.cdn20180510.models.RefreshObjectCachesResponse; import com.aliyun.teaopenapi.models.Config; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @RestController @Slf4j @AllArgsConstructor public class OSSAuditController { private Client cdnClient; @PostMapping("/ossNotify") public String ossNotify(String checksum, String content) throws Exception { JSONObject jsonObject = JSON.parseObject(content); RefreshObjectCachesRequest refreshObjectCachesRequest = new RefreshObjectCachesRequest(); refreshObjectCachesRequest.setObjectPath("cdn.raex.vip/" + jsonObject.getString("object")); RefreshObjectCachesResponse resp = cdnClient.refreshObjectCaches(refreshObjectCachesRequest); log.info(JSON.toJSONString(resp, true)); return "ok"; } }