Commit 88a27a10 authored by wlx@33.cn's avatar wlx@33.cn

Merge branch 'dev' of https://gitlab.33.cn/yimu/mall-server into dev

parents b063eb7f afe93938
...@@ -97,7 +97,7 @@ public class SmsController { ...@@ -97,7 +97,7 @@ public class SmsController {
switch (Objects.requireNonNull(CodeTypeEnum.getByType(type))) { switch (Objects.requireNonNull(CodeTypeEnum.getByType(type))) {
case REGISTER: case REGISTER:
// templateId = "SMS_226745226"; // templateId = "SMS_226745226";
templateId = AliSmsUtils.tempId; templateId = AliSmsUtils.MERCHANT_REGISTER;
redisKey = MALLGlobalConfig.PHONE_CODE_MERCHANT_REGISTER_REDIS_KEY_SUFFIX; redisKey = MALLGlobalConfig.PHONE_CODE_MERCHANT_REGISTER_REDIS_KEY_SUFFIX;
break; break;
case SEARCH: case SEARCH:
...@@ -106,12 +106,12 @@ public class SmsController { ...@@ -106,12 +106,12 @@ public class SmsController {
break; break;
case REPAIR_PWD: case REPAIR_PWD:
// templateId = "SMS_226745226"; // templateId = "SMS_226745226";
templateId = AliSmsUtils.tempId; templateId = AliSmsUtils.REPAIR_PWD;
redisKey = MALLGlobalConfig.PHONE_CODE_REPAIR_PWD_REDIS_KEY_SUFFIX; redisKey = MALLGlobalConfig.PHONE_CODE_REPAIR_PWD_REDIS_KEY_SUFFIX;
break; break;
case AUTHENTICATION: case AUTHENTICATION:
// templateId = "SMS_226745226"; // templateId = "SMS_226745226";
templateId = AliSmsUtils.tempId; templateId = AliSmsUtils.RESET_PWD;
redisKey = MALLGlobalConfig.PHONE_CODE_IDENTITY_REDIS_KEY_SUFFIX; redisKey = MALLGlobalConfig.PHONE_CODE_IDENTITY_REDIS_KEY_SUFFIX;
break; break;
} }
......
package com.fzm.mall.server.admin.config; package com.fzm.mall.server.admin.config;
import cn.fzm.chain.simplesdk.client.ParaChainClient;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzm.mall.server.admin.auth_center.enums.status.AdminRoleStatusEnum; import com.fzm.mall.server.admin.auth_center.enums.status.AdminRoleStatusEnum;
import com.fzm.mall.server.admin.auth_center.enums.type.AdminRoleTypeEnum; import com.fzm.mall.server.admin.auth_center.enums.type.AdminRoleTypeEnum;
import com.fzm.mall.server.admin.auth_center.model.AdminRole; import com.fzm.mall.server.admin.auth_center.model.AdminRole;
import com.fzm.mall.server.admin.auth_center.service.IAdminRoleService; import com.fzm.mall.server.admin.auth_center.service.IAdminRoleService;
import com.fzm.mall.server.admin.block_chain.util.ChainUtil;
import com.fzm.mall.server.admin.constant.MALLGlobalConfig; import com.fzm.mall.server.admin.constant.MALLGlobalConfig;
import com.fzm.mall.server.admin.finance_center.enums.status.PlatformIntegralStatusEnum; import com.fzm.mall.server.admin.finance_center.enums.status.PlatformIntegralStatusEnum;
import com.fzm.mall.server.admin.finance_center.enums.type.PlatformIntegralTypeEnum; import com.fzm.mall.server.admin.finance_center.enums.type.PlatformIntegralTypeEnum;
...@@ -21,10 +23,7 @@ import com.fzm.mall.server.admin.home_page.service.IAdminService; ...@@ -21,10 +23,7 @@ import com.fzm.mall.server.admin.home_page.service.IAdminService;
import com.fzm.mall.server.admin.home_page.service.IMerchantService; import com.fzm.mall.server.admin.home_page.service.IMerchantService;
import com.fzm.mall.server.admin.system.model.SysConfig; import com.fzm.mall.server.admin.system.model.SysConfig;
import com.fzm.mall.server.admin.system.service.ISysConfigService; import com.fzm.mall.server.admin.system.service.ISysConfigService;
import com.fzm.mall.server.admin.util.OSSUtil; import com.fzm.mall.server.admin.util.*;
import com.fzm.mall.server.admin.util.SerialIdsUtil;
import com.fzm.mall.server.admin.util.Sha256Util;
import com.fzm.mall.server.admin.util.UUIDUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -52,6 +51,11 @@ public class InitConfig { ...@@ -52,6 +51,11 @@ public class InitConfig {
private final IAdminService adminService; private final IAdminService adminService;
private final IMerchantService merchantService; private final IMerchantService merchantService;
private final ISysConfigService sysConfigService; private final ISysConfigService sysConfigService;
private final ParaChainClient paraChainClient;
private static String abi = "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"URI\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"accounts\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"balanceOfBatch\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"burnTokenBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getTokenInfo\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"getUserTokens\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"mintTokenBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeBatchTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenInfo\",\"type\":\"string\"}],\"name\":\"setTokenInfo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"uri\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]";
private static String cAddr = "15DtbSyS4eVFxdF87jmrcAdXMSAwXEHVLW";
@PostConstruct @PostConstruct
public void init() { public void init() {
...@@ -66,7 +70,7 @@ public class InitConfig { ...@@ -66,7 +70,7 @@ public class InitConfig {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
String logoPath = OSSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png")); String logoPath = OBSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png"));
SysConfig sysConfig = new SysConfig(); SysConfig sysConfig = new SysConfig();
sysConfig.setConfigId(UUIDUtil.getUUID()); sysConfig.setConfigId(UUIDUtil.getUUID());
sysConfig.setDictKey("admin_head_img"); sysConfig.setDictKey("admin_head_img");
...@@ -158,12 +162,6 @@ public class InitConfig { ...@@ -158,12 +162,6 @@ public class InitConfig {
PlatformIntegralStatusEnum.ABLE.getStatus() PlatformIntegralStatusEnum.ABLE.getStatus()
); );
platformIntegralService.initBaseIntegral(integral); platformIntegralService.initBaseIntegral(integral);
// String hash = chainUtil.issue("1GsU4gvB8rGCQjRn7HTtSaJmJ913UgcQvu", 1631777984290L, 1000L);
// System.err.println("=============================" + hash);
// long l = chainUtil.evmBalance("1GsU4gvB8rGCQjRn7HTtSaJmJ913UgcQvu", 1631777329272L);
// System.err.println("=============================" + l);
} }
} }
...@@ -25,10 +25,7 @@ import com.fzm.mall.server.admin.system.model.SysConfig; ...@@ -25,10 +25,7 @@ import com.fzm.mall.server.admin.system.model.SysConfig;
import com.fzm.mall.server.admin.system.service.ISysConfigService; import com.fzm.mall.server.admin.system.service.ISysConfigService;
import com.fzm.mall.server.admin.user_center.model.User; import com.fzm.mall.server.admin.user_center.model.User;
import com.fzm.mall.server.admin.user_center.service.IUserService; import com.fzm.mall.server.admin.user_center.service.IUserService;
import com.fzm.mall.server.admin.util.ExcelUtil; import com.fzm.mall.server.admin.util.*;
import com.fzm.mall.server.admin.util.OSSUtil;
import com.fzm.mall.server.admin.util.SerialIdsUtil;
import com.fzm.mall.server.admin.util.UUIDUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dozer.DozerBeanMapper; import org.dozer.DozerBeanMapper;
...@@ -109,7 +106,7 @@ public class PlatformIntegralServiceImpl extends ServiceImpl<PlatformIntegralMap ...@@ -109,7 +106,7 @@ public class PlatformIntegralServiceImpl extends ServiceImpl<PlatformIntegralMap
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
String logoPath = OSSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".jpg")); String logoPath = OBSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".jpg"));
SysConfig sysConfig = new SysConfig(); SysConfig sysConfig = new SysConfig();
sysConfig.setConfigId(UUIDUtil.getUUID()); sysConfig.setConfigId(UUIDUtil.getUUID());
......
...@@ -263,7 +263,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i ...@@ -263,7 +263,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
String logoPath = OSSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png")); String logoPath = OBSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png"));
UpdateWrapper<Merchant> uw = new UpdateWrapper<>(); UpdateWrapper<Merchant> uw = new UpdateWrapper<>();
uw.lambda() uw.lambda()
...@@ -359,7 +359,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i ...@@ -359,7 +359,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
String logoPath = OSSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png")); String logoPath = OBSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png"));
merchant.setTokenIssueAddr(issueAddr); merchant.setTokenIssueAddr(issueAddr);
merchant.setTokenRecoverAddr(recoverAddr); merchant.setTokenRecoverAddr(recoverAddr);
......
...@@ -3,6 +3,7 @@ package com.fzm.mall.server.admin.system.controller; ...@@ -3,6 +3,7 @@ package com.fzm.mall.server.admin.system.controller;
import com.fzm.mall.server.admin.constant.MallResponseError; import com.fzm.mall.server.admin.constant.MallResponseError;
import com.fzm.mall.server.admin.repo.ResponseFactory; import com.fzm.mall.server.admin.repo.ResponseFactory;
import com.fzm.mall.server.admin.repo.ResponseVO; import com.fzm.mall.server.admin.repo.ResponseVO;
import com.fzm.mall.server.admin.util.OBSUtil;
import com.fzm.mall.server.admin.util.OSSUtil; import com.fzm.mall.server.admin.util.OSSUtil;
import com.fzm.mall.server.admin.util.SerialIdsUtil; import com.fzm.mall.server.admin.util.SerialIdsUtil;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
...@@ -85,7 +86,7 @@ public class UploadController { ...@@ -85,7 +86,7 @@ public class UploadController {
log.error("upload error:", e); log.error("upload error:", e);
e.printStackTrace(); e.printStackTrace();
} }
return OSSUtil.uploadByte(bytes, "manage/" + type + "/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(fileType)); return OBSUtil.uploadByte(bytes, "manage/" + type + "/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(fileType));
} }
private String getFileType(String fileName) { private String getFileType(String fileName) {
......
...@@ -36,8 +36,6 @@ public class AliSmsUtils { ...@@ -36,8 +36,6 @@ public class AliSmsUtils {
// 重置密码 // 重置密码
public static String RESET_PWD = "SMS_225125100"; public static String RESET_PWD = "SMS_225125100";
public static String tempId = "SMS_226745226";
public static boolean sendCode(String mobile, String code, String tplId, boolean isMsg) { public static boolean sendCode(String mobile, String code, String tplId, boolean isMsg) {
//设置超时时间-可自行调整 //设置超时时间-可自行调整
System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
...@@ -46,8 +44,8 @@ public class AliSmsUtils { ...@@ -46,8 +44,8 @@ public class AliSmsUtils {
final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改) final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)
final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改) final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改)
//替换成你的AK //替换成你的AK
final String accessKeyId = "LTAI5tD9SPnwKjaAzywQEvde";//你的accessKeyId,参考本文档步骤2+ final String accessKeyId = "LTAI5tKnkYvSprbF26n7FZN3";//你的accessKeyId,参考本文档步骤2+
final String accessKeySecret = "Mm1R0sVS10IrRBsNIEvJpLQRj4tOjj";//你的accessKeySecret,参考本文档步骤2 final String accessKeySecret = "kxJfWPa03WSTBsRvj7n2bYeBsdWBgY";//你的accessKeySecret,参考本文档步骤2
//初始化ascClient,暂时不支持多region(请勿修改) //初始化ascClient,暂时不支持多region(请勿修改)
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId,
accessKeySecret); accessKeySecret);
...@@ -66,7 +64,7 @@ public class AliSmsUtils { ...@@ -66,7 +64,7 @@ public class AliSmsUtils {
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000” //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
request.setPhoneNumbers(mobile); request.setPhoneNumbers(mobile);
//必填:短信签名-可在短信控制台中找到 //必填:短信签名-可在短信控制台中找到
request.setSignName("浙娱"); request.setSignName("一幕影链");
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版 //必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
request.setTemplateCode(tplId); request.setTemplateCode(tplId);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
......
...@@ -14,16 +14,16 @@ import java.net.URL; ...@@ -14,16 +14,16 @@ import java.net.URL;
*/ */
public class OBSUtil { public class OBSUtil {
private static String accessKey = "LTAI4GCoj6DGZx5JgUYVLs3P"; //取值为获取的AK private static String accessKey = "HIULSHJZJOTWB72Z38ZB"; //取值为获取的AK LTAI4GCoj6DGZx5JgUYVLs3P
private static String securityKey = "7TEBqdFmFtKT7AFDhh1DNgdoUSosYJ"; //取值为获取的SK private static String securityKey = "GI0oWEGRJuMKmPXJq2fCmuMpFPIITLmjeCQxo2tA"; //取值为获取的SK 7TEBqdFmFtKT7AFDhh1DNgdoUSosYJ
private static String endpoint = "https://obs.cn-east-3.myhuaweicloud.com"; //终端节点(Endpoint) private static String endpoint = "https://obs.cn-east-3.myhuaweicloud.com"; //终端节点(Endpoint)
private static String region = "cn-east-3"; // 取值为规划桶所在的区域 private static String region = "cn-east-3"; // 取值为规划桶所在的区域
private static String bucket = "lele-test"; //存储桶 private static String bucket = "yimu-file"; //存储桶
private static String baseUrl = "https://lele-test.obs.cn-east-3.myhuaweicloud.com/"; private static String baseUrl = "https://yimu-file.obs.cn-east-3.myhuaweicloud.com/";
public static void main(String[] str) { public static void main(String[] str) {
uploadNet("https://xls-data-test.oss-cn-shanghai.aliyuncs.com/manage/img/20210521/20210521112801772_571732.xlsx", "", "tes.xlsx"); String S = uploadFile("C:\\Users\\bl\\Desktop\\链命令.txt", "manage/img/ttt", "a.txt");
} System.err.println(S); }
// 创建ObsClient实例 // 创建ObsClient实例
public static ObsClient getObsClient() { public static ObsClient getObsClient() {
......
...@@ -262,7 +262,7 @@ public class QRCodeUtil { ...@@ -262,7 +262,7 @@ public class QRCodeUtil {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
String logoPath = OSSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png")); String logoPath = OBSUtil.uploadStream(inputStream, "manage/img/" + SerialIdsUtil.createDateStr() + "/", SerialIdsUtil.createFileName(".png"));
System.err.println(logoPath); System.err.println(logoPath);
} }
......
...@@ -103,6 +103,12 @@ ...@@ -103,6 +103,12 @@
<version>1.68</version> <version>1.68</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java</artifactId>
<version>3.19.7</version>
</dependency>
</dependencies> </dependencies>
......
...@@ -128,14 +128,14 @@ public interface UserAssetMapper extends BaseMapper<UserAsset> { ...@@ -128,14 +128,14 @@ public interface UserAssetMapper extends BaseMapper<UserAsset> {
@Update("update user_asset set amount = amount - #{unpaidAmount} where uid = #{uid} and coin = #{coinName} and amount >= #{unpaidAmount}") @Update("update user_asset set amount = amount - #{unpaidAmount} where uid = #{uid} and coin = #{coinName} and amount >= #{unpaidAmount}")
int delAsset(@Param("uid") String uid, @Param("unpaidAmount") BigDecimal unpaidAmount, @Param("coinName") String coinName); int delAsset(@Param("uid") String uid, @Param("unpaidAmount") BigDecimal unpaidAmount, @Param("coinName") String coinName);
@Select("select * from user_asset where uid = #{uid} and amount >0 and coin != 'BASE' limit #{start},#{size}") @Select("select * from user_asset where uid = #{uid} and amount >0 and goods_coin != 'BASE' limit #{start},#{size}")
List<UserAsset> getList(@Param("uid") String uid, @Param("start") int start, @Param("size") Integer size); List<UserAsset> getList(@Param("uid") String uid, @Param("start") int start, @Param("size") Integer size);
@Select("select count(*) from user_asset where uid = #{uid} and amount >0 and coin != 'BASE' ") @Select("select count(*) from user_asset where uid = #{uid} and amount >0 and coin != 'BASE' ")
Integer getCount(@Param("uid") String uid); Integer getCount(@Param("uid") String uid);
@Select("select IFNULL(sum(a.amount * b.original_price),0) from user_asset a left join goods_sku b on a.coin = b.coin_name where a.uid = #{uid} and a.amount > 0 and a.coin != 'BASE'") @Select("select IFNULL(sum(a.amount * b.original_price),0) from user_asset a left join goods_sku b on a.goods_coin = b.coin_name where a.uid = #{uid} and a.amount > 0 and a.goods_coin != #{mallCoin}")
BigDecimal getAllNotMallCoin(String uid); BigDecimal getAllNotMallCoin(@Param("uid") String uid,@Param("mallCoin") String mallCoin);
@Update("update user_asset set amount = amount + #{amount} where id = #{id}") @Update("update user_asset set amount = amount + #{amount} where id = #{id}")
void addCoin(@Param("id") Long id, @Param("amount") BigDecimal amount); void addCoin(@Param("id") Long id, @Param("amount") BigDecimal amount);
......
...@@ -138,7 +138,7 @@ public interface IUserAssetService extends IService<UserAsset> { ...@@ -138,7 +138,7 @@ public interface IUserAssetService extends IService<UserAsset> {
Integer getCount(String uid); Integer getCount(String uid);
BigDecimal getAllNotMallCoin(String uid); BigDecimal getAllNotMallCoin(String uid,String mallCoin);
void addCoin(Long id, BigDecimal amount); void addCoin(Long id, BigDecimal amount);
......
...@@ -85,6 +85,7 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -85,6 +85,7 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
QueryWrapper<UserAsset> qw = new QueryWrapper<>(); QueryWrapper<UserAsset> qw = new QueryWrapper<>();
qw.eq("type", type); qw.eq("type", type);
qw.eq("uid", uid); qw.eq("uid", uid);
qw.orderByDesc("update_time");
String keyWord = userAssetVo.getKeyWord(); String keyWord = userAssetVo.getKeyWord();
List<UserAsset> list = new ArrayList<>(); List<UserAsset> list = new ArrayList<>();
if (type == 1 && !StringUtil.isNullOrEmpty(keyWord)) { if (type == 1 && !StringUtil.isNullOrEmpty(keyWord)) {
...@@ -514,8 +515,8 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -514,8 +515,8 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
} }
@Override @Override
public BigDecimal getAllNotMallCoin(String uid) { public BigDecimal getAllNotMallCoin(String uid,String mallCoin) {
return coinDao.getAllNotMallCoin(uid); return coinDao.getAllNotMallCoin(uid,mallCoin);
} }
@Override @Override
......
...@@ -704,7 +704,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -704,7 +704,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber())); userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber()));
} }
String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, ""); String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, "");
String hash = chainUtil.tranToken(m.getTokenIssueAddr(),"",user.getAddress(),new BigDecimal(orderDetail.getNumber()),coinName); String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getNumber().longValue());
UserAssetRecord userAssetRecord = new UserAssetRecord(); UserAssetRecord userAssetRecord = new UserAssetRecord();
userAssetRecord.setUid(order.getUid()); userAssetRecord.setUid(order.getUid());
userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber())); userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber()));
...@@ -746,7 +746,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -746,7 +746,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber())); userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber()));
} }
String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, ""); String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, "");
String hash = chainUtil.tranToken(m.getTokenIssueAddr(),"",user.getAddress(),new BigDecimal(orderDetail.getNumber()),coinName); String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getNumber().longValue());
UserAssetRecord userAssetRecord = new UserAssetRecord(); UserAssetRecord userAssetRecord = new UserAssetRecord();
userAssetRecord.setUid(order.getUid()); userAssetRecord.setUid(order.getUid());
userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber())); userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber()));
...@@ -790,7 +790,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -790,7 +790,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber())); userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber()));
} }
String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, ""); String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, "");
String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getAmount().longValue()); String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getNumber().longValue());
UserAssetRecord userAssetRecord = new UserAssetRecord(); UserAssetRecord userAssetRecord = new UserAssetRecord();
userAssetRecord.setUid(order.getUid()); userAssetRecord.setUid(order.getUid());
userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber())); userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber()));
...@@ -888,7 +888,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -888,7 +888,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber())); userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber()));
} }
String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, ""); String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, "");
String hash = chainUtil.tranToken(m.getTokenIssueAddr(),"",user.getAddress(),new BigDecimal(orderDetail.getNumber()),coinName); String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getNumber().longValue());
UserAssetRecord userAssetRecord = new UserAssetRecord(); UserAssetRecord userAssetRecord = new UserAssetRecord();
userAssetRecord.setUid(order.getUid()); userAssetRecord.setUid(order.getUid());
userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber())); userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber()));
...@@ -955,7 +955,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -955,7 +955,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber())); userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber()));
} }
String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, ""); String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, "");
String hash = chainUtil.tranToken(m.getTokenIssueAddr(),"",user.getAddress(),new BigDecimal(orderDetail.getNumber()),coinName); String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getNumber().longValue());
UserAssetRecord userAssetRecord = new UserAssetRecord(); UserAssetRecord userAssetRecord = new UserAssetRecord();
userAssetRecord.setUid(order.getUid()); userAssetRecord.setUid(order.getUid());
userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber())); userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber()));
...@@ -1023,7 +1023,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -1023,7 +1023,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
} else { } else {
userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber())); userAssetService.addCoin(coin.getId(), new BigDecimal(orderDetail.getNumber()));
} }
String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(orderDetail.getCoin()),orderDetail.getAmount().longValue()); String coinName = orderDetail.getCoin().replace(MALLGlobalConfig.GOODS_NFT_PREFIX, "");
String hash = chainUtil.evmTransfer(user.getAddress(),m.getTokenIssueAddr(),Long.valueOf(coinName),orderDetail.getNumber().longValue());
UserAssetRecord userAssetRecord = new UserAssetRecord(); UserAssetRecord userAssetRecord = new UserAssetRecord();
userAssetRecord.setUid(order.getUid()); userAssetRecord.setUid(order.getUid());
userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber())); userAssetRecord.setAmount(new BigDecimal(orderDetail.getNumber()));
......
...@@ -2,6 +2,7 @@ package com.fzm.mall.server.front.system.controller; ...@@ -2,6 +2,7 @@ package com.fzm.mall.server.front.system.controller;
import com.fzm.mall.server.front.base.ResponseVO; import com.fzm.mall.server.front.base.ResponseVO;
import com.fzm.mall.server.front.constant.MallResponseEnum; import com.fzm.mall.server.front.constant.MallResponseEnum;
import com.fzm.mall.server.front.util.OBSUtil;
import com.fzm.mall.server.front.util.OSSUtil; import com.fzm.mall.server.front.util.OSSUtil;
import com.fzm.mall.server.front.util.SerialIdsUtil; import com.fzm.mall.server.front.util.SerialIdsUtil;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
...@@ -69,7 +70,7 @@ public class UploadController { ...@@ -69,7 +70,7 @@ public class UploadController {
log.error("upload error:", e); log.error("upload error:", e);
e.printStackTrace(); e.printStackTrace();
} }
return OSSUtil.uploadByte(bytes, "", SerialIdsUtil.createFileName(fileType)); return OBSUtil.uploadByte(bytes, "", SerialIdsUtil.createFileName(fileType));
} }
private String getFileType(String fileName) { private String getFileType(String fileName) {
......
...@@ -329,7 +329,7 @@ public class UserController { ...@@ -329,7 +329,7 @@ public class UserController {
assetVo.setList(assets); assetVo.setList(assets);
Integer count = userAssetService.getCount(uid); Integer count = userAssetService.getCount(uid);
assetVo.setCount(count); assetVo.setCount(count);
BigDecimal all = userAssetService.getAllNotMallCoin(uid); BigDecimal all = userAssetService.getAllNotMallCoin(uid,CoinNameEnum.MALLCOIN.value());
if (all == null) { if (all == null) {
all = BigDecimal.ZERO; all = BigDecimal.ZERO;
} }
...@@ -487,7 +487,7 @@ public class UserController { ...@@ -487,7 +487,7 @@ public class UserController {
BigDecimal mallCoin = u.getAmount(); BigDecimal mallCoin = u.getAmount();
//优惠券数量 //优惠券数量
int couponCount = couponService.getCount(uid, header.getType(), "1"); int couponCount = couponService.getCount(uid, header.getType(), "1");
BigDecimal all = userAssetService.getAllNotMallCoin(uid); BigDecimal all = userAssetService.getAllNotMallCoin(uid,CoinNameEnum.MALLCOIN.value());
if (all == null) { if (all == null) {
all = BigDecimal.ZERO; all = BigDecimal.ZERO;
} }
......
...@@ -25,7 +25,8 @@ public class AliSmsUtils { ...@@ -25,7 +25,8 @@ public class AliSmsUtils {
public static String WITHDRAW = "SMS_224356728"; public static String WITHDRAW = "SMS_224356728";
public static String tempId = "SMS_226745226"; public static String tempId = "SMS_197465258";
public static boolean sendCode(String mobile, String code , String tplId) { public static boolean sendCode(String mobile, String code , String tplId) {
...@@ -36,8 +37,8 @@ public class AliSmsUtils { ...@@ -36,8 +37,8 @@ public class AliSmsUtils {
final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改) final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)
final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改) final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改)
//替换成你的AK //替换成你的AK
final String accessKeyId = "LTAI5tD9SPnwKjaAzywQEvde";//你的accessKeyId,参考本文档步骤2+ final String accessKeyId = "LTAI5tKnkYvSprbF26n7FZN3";//你的accessKeyId,参考本文档步骤2+
final String accessKeySecret = "Mm1R0sVS10IrRBsNIEvJpLQRj4tOjj";//你的accessKeySecret,参考本文档步骤2 final String accessKeySecret = "kxJfWPa03WSTBsRvj7n2bYeBsdWBgY";//你的accessKeySecret,参考本文档步骤2
//初始化ascClient,暂时不支持多region(请勿修改) //初始化ascClient,暂时不支持多region(请勿修改)
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId,
accessKeySecret); accessKeySecret);
...@@ -56,7 +57,7 @@ public class AliSmsUtils { ...@@ -56,7 +57,7 @@ public class AliSmsUtils {
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000” //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
request.setPhoneNumbers(mobile); request.setPhoneNumbers(mobile);
//必填:短信签名-可在短信控制台中找到 //必填:短信签名-可在短信控制台中找到
request.setSignName("浙娱"); request.setSignName("一幕影链");
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版 //必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
//TODO 回头换成tplId //TODO 回头换成tplId
request.setTemplateCode(tempId); request.setTemplateCode(tempId);
...@@ -87,7 +88,4 @@ public class AliSmsUtils { ...@@ -87,7 +88,4 @@ public class AliSmsUtils {
return false; return false;
} }
public static void main(String[] args) {
sendCode("13083458852","9999","SMS_226745226");
}
} }
package com.fzm.mall.server.front.util;
import com.obs.services.ObsClient;
import com.obs.services.model.ObjectMetadata;
import java.io.*;
import java.net.URL;
/**
* @author wangp
* @date 2021/5/25 17:47
* @description 华为云对象存储
* @since JDK 1.8
*/
public class OBSUtil {
private static String accessKey = "HIULSHJZJOTWB72Z38ZB"; //取值为获取的AK LTAI4GCoj6DGZx5JgUYVLs3P
private static String securityKey = "GI0oWEGRJuMKmPXJq2fCmuMpFPIITLmjeCQxo2tA"; //取值为获取的SK 7TEBqdFmFtKT7AFDhh1DNgdoUSosYJ
private static String endpoint = "https://obs.cn-east-3.myhuaweicloud.com"; //终端节点(Endpoint)
private static String region = "cn-east-3"; // 取值为规划桶所在的区域
private static String bucket = "yimu-file"; //存储桶
private static String baseUrl = "https://yimu-file.obs.cn-east-3.myhuaweicloud.com/";
public static void main(String[] str) {
String S = uploadFile("C:\\Users\\bl\\Desktop\\链命令.txt", "manage/img/ttt", "a.txt");
System.err.println(S); }
// 创建ObsClient实例
public static ObsClient getObsClient() {
return new ObsClient(accessKey, securityKey, endpoint);
}
/**
* 上传Byte数组
*
* @param content 待上传字节数组
* @param folder OSS文件夹名
* @param fileName OSS文件名
* @return OSS访问地址
*/
public static String uploadByte(byte[] content, String folder, String fileName) {
// 创建ObsClient实例。
ObsClient obsClient = getObsClient();
// 上传Byte数组。
obsClient.putObject(bucket, folder + fileName, new ByteArrayInputStream(content));
// 关闭obsClient
try {
obsClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return baseUrl + folder + fileName;
}
/**
* 上传网络流
*
* @param spec 网络地址
* @param folder OSS文件夹名
* @param fileName OSS文件名
* @return OSS访问地址
*/
public static String uploadNet(String spec, String folder, String fileName) {
// 创建ObsClient实例。
ObsClient obsClient = getObsClient();
// 上传网络流。
InputStream inputStream = null;
try {
inputStream = new URL(spec).openStream();
} catch (IOException e) {
e.printStackTrace();
}
obsClient.putObject(bucket, folder + fileName, inputStream);
// 关闭obsClient
try {
obsClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return baseUrl + folder + fileName;
}
/**
* 上传文件流
*
* @param filePath 待上传文件路径
* @param folder OSS文件夹名
* @param fileName OSS文件名
* @return OSS访问地址
*/
public static String uploadFile(String filePath, String folder, String fileName) {
// 创建ObsClient实例。
ObsClient obsClient = getObsClient();
System.err.println("obsClient:" + obsClient);
// 上传文件流。
FileInputStream fis = null; // 待上传的本地文件路径,需要指定到具体的文件名
try {
fis = new FileInputStream(new File(filePath));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
obsClient.putObject(bucket, folder + fileName, fis);
// 关闭obsClient
try {
obsClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return baseUrl + folder + fileName;
}
/**
* 上传文件流
*
* @param in 待上传文件流
* @param folder OSS文件夹名
* @param fileName OSS文件名
* @return OSS访问地址
*/
public static String uploadStream(InputStream in, String folder, String fileName) {
// 创建ObsClient实例。
ObsClient obsClient = getObsClient();
// 上传Byte数组。
obsClient.putObject(bucket, folder + fileName, in);
// 关闭obsClient
try {
obsClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return baseUrl + folder + fileName;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment