| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.resource.builder; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import org.springblade.core.oss.enums.OssEnum; |
| | | import org.springblade.core.oss.enums.OssStatusEnum; |
| | | import org.springblade.core.oss.props.OssProperties; |
| | | import org.springblade.core.oss.rule.OssRule; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springblade.modules.resource.entity.Oss; |
| | | import org.springblade.modules.resource.rule.context.OssContext; |
| | | import org.springblade.modules.resource.rule.oss.MyOssRule; |
| | | import org.springblade.modules.resource.service.IOssService; |
| | | |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取template |
| | | * @param prefixPath 上传文件前缀路径 |
| | | * @return OssTemplate |
| | | */ |
| | | public OssTemplate templateByPrefix(String prefixPath) { |
| | | return templateByPath(StringPool.EMPTY,prefixPath); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 自定义路径前缀获取template |
| | | * |
| | | * @param code 资源编号 |
| | | * @param prefixPath 上传文件前缀路径 |
| | | * @return OssTemplate |
| | | */ |
| | | public OssTemplate templateByPath(String code,String prefixPath) { |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | if (Strings.isBlank(tenantId)){ |
| | | tenantId = "000000"; |
| | | } |
| | | Oss oss = getOss(tenantId, code); |
| | | |
| | | OssContext ossContext = new OssContext(); |
| | | ossContext.setPrefix(prefixPath); |
| | | ossContext.setOss(oss); |
| | | ossContext.setOssProperties(ossProperties); |
| | | ossContext.setOssPool(ossPool); |
| | | ossContext.setTemplatePool(templatePool); |
| | | |
| | | LiteflowResponse resp = flowExecutor.execute2Resp("ossChain", tenantId, ossContext); |
| | | if (resp.isSuccess()) { |
| | | OssContext contextBean = resp.getFirstContextBean(); |
| | | return contextBean.getOssTemplate(); |
| | | } else { |
| | | throw new ServiceException("未获取到对应的对象存储配置"); |
| | | } |
| | | } |
| | | } |