diff --git a/ms-biz/src/main/java/com/ms/api/TestTosService.java b/ms-biz/src/main/java/com/ms/api/TestTosService.java index 70329472..c7dbc1d9 100644 --- a/ms-biz/src/main/java/com/ms/api/TestTosService.java +++ b/ms-biz/src/main/java/com/ms/api/TestTosService.java @@ -5,6 +5,7 @@ import com.jinritemai.cloud.base.api.BaseResponse; import com.jinritemai.cloud.base.api.ExtensionService; import com.jinritemai.cloud.base.api.ExtensionServiceHandler; import com.ms.api.common.R; +import com.ms.api.common.Ret; import com.ms.api.common.SPIBaseService; import com.ms.api.dto.ItemDTO; import com.ms.api.paas.StorageService; @@ -23,7 +24,14 @@ public class TestTosService extends SPIBaseService implements ExtensionServiceHa public BaseResponse handle(BaseRequest req) { try{ initHandle(req); - return R.ok(""); + + Ret ret = storageService.uploadContent("test","这是测试数据"); + String url = (String)ret.getData().get("url"); + ret = storageService.getContent("test"); + String content = (String)ret.getData().get("data"); + String publicUrl = storageService.getPubOssUrlByOssPath("test"); + + return R.ok("地址:" + url + "内容:" + content + "公网地址: " + publicUrl); }catch (Throwable e){ e.printStackTrace(); return R.ok(e.getMessage()); diff --git a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java index 7c197611..b483de63 100644 --- a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java +++ b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java @@ -1,5 +1,6 @@ package com.ms.api.common; +import com.jinritemai.cloud.base.core.util.LogUtils; import com.ms.api.bo.RedisKeyBO; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -39,6 +40,7 @@ public abstract class TaskBaseService implements TaskHandler { public void runTask() { RedisKeyBO redisKeyBO = getRedisKey(); try{ + setLogId(); if(isPoolFull()){ return;} execute(redisKeyBO); }catch (Throwable e){ @@ -53,6 +55,7 @@ public abstract class TaskBaseService implements TaskHandler { TransactionStatus status = transactionManager.getTransaction(def); RedisKeyBO redisKeyBO = getRedisKey(); try{ + setLogId(); if(isPoolFull()){ return;} execute(redisKeyBO); transactionManager.commit(status); @@ -64,6 +67,10 @@ public abstract class TaskBaseService implements TaskHandler { } } + private void setLogId(){ + LogUtils.setLogId(getLogId() + System.currentTimeMillis()); + } + private boolean isPoolFull(){ ThreadPoolTaskExecutor mTaskPool = (ThreadPoolTaskExecutor) getTaskPool(); if(mTaskPool.getActiveCount() == mTaskPool.getCorePoolSize()){ @@ -95,6 +102,7 @@ public abstract class TaskBaseService implements TaskHandler { log.info("执行任务结束"); } + protected String getLogId(){return getTaskExecutorName();} protected RedisKeyBO getRedisKey(){ return null; };