Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop into feature/pg
This commit is contained in:
commit
7de49dcfb8
@ -70,7 +70,7 @@ public class MinioFilePlugin implements FilePlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputStreamUpload(InputStream inputStream, String key) {
|
||||
public String inputStreamUpload(InputStream inputStream, String key) {
|
||||
String bucket = "";
|
||||
try {
|
||||
MinioClient client = getOssClient();
|
||||
@ -78,7 +78,7 @@ public class MinioFilePlugin implements FilePlugin {
|
||||
PutObjectArgs putObjectArgs = PutObjectArgs.builder()
|
||||
.bucket(bucket).stream(inputStream, inputStream.available(), 5 * 1024 * 1024)
|
||||
.object(key)
|
||||
.contentType("image/png")
|
||||
.contentType("image/png" )
|
||||
.build();
|
||||
client.putObject(putObjectArgs);
|
||||
} catch (Exception e) {
|
||||
@ -86,7 +86,7 @@ public class MinioFilePlugin implements FilePlugin {
|
||||
throw new ServiceException(ResultCode.OSS_DELETE_ERROR, e.getMessage());
|
||||
}
|
||||
//拼接出可访问的url地址
|
||||
return ossSetting.getM_endpoint() + "/" + bucket + "/" + key;
|
||||
return ossSetting.getM_frontUrl() + "/" + bucket + "/" + key;
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ public class MinioFilePlugin implements FilePlugin {
|
||||
//创建bucket
|
||||
MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(ossSetting.getM_bucketName()).build();
|
||||
this.minioClient.makeBucket(makeBucketArgs);
|
||||
setBucketPolicy(this.minioClient, ossSetting.getM_bucketName(), "read-write");
|
||||
setBucketPolicy(this.minioClient, ossSetting.getM_bucketName(), "read-write" );
|
||||
log.info("创建minio桶成功{}", ossSetting.getM_bucketName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -153,7 +153,7 @@ public class MinioFilePlugin implements FilePlugin {
|
||||
client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).config(WRITE_ONLY.replace(BUCKET_PARAM, bucket)).build());
|
||||
break;
|
||||
case "read-write":
|
||||
client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).region("public").config(READ_WRITE.replace(BUCKET_PARAM, bucket)).build());
|
||||
client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).region("public" ).config(READ_WRITE.replace(BUCKET_PARAM, bucket)).build());
|
||||
break;
|
||||
case "none":
|
||||
default:
|
||||
|
@ -50,6 +50,11 @@ public class OssSetting implements Serializable {
|
||||
*/
|
||||
private String m_endpoint;
|
||||
|
||||
/**
|
||||
* minio 前端请求地址
|
||||
*/
|
||||
private String m_frontUrl;
|
||||
|
||||
/**
|
||||
* minio用户名
|
||||
*/
|
||||
|
@ -1,61 +0,0 @@
|
||||
package cn.lili.test;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.statistics.serviceimpl.OrderStatisticsServiceImpl;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* RedisLimiterHelperTest
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @since 2020-06-13 12:17
|
||||
*/
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
public class RedisLimiterHelperTest {
|
||||
|
||||
@Autowired
|
||||
private OrderItemService orderItemService;
|
||||
|
||||
@Autowired
|
||||
private OrderStatisticsServiceImpl orderStatisticsDataService;
|
||||
|
||||
|
||||
@Test
|
||||
public void orderTest() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBatchUpdate() {
|
||||
OrderItem orderItem = new OrderItem();
|
||||
orderItem.setId("1356539557729796097");
|
||||
orderItem.setCreateBy("1356539557729796097");
|
||||
|
||||
|
||||
OrderItem orderItem1 = new OrderItem();
|
||||
orderItem1.setId("1356787800921341953");
|
||||
orderItem1.setCreateBy("1356787800921341953");
|
||||
|
||||
|
||||
List<OrderItem> orderItemList = new ArrayList<>();
|
||||
orderItemList.add(orderItem);
|
||||
orderItemList.add(orderItem1);
|
||||
|
||||
orderItemService.updateBatchById(orderItemList);
|
||||
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package cn.lili.test.script;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.scripting.support.ResourceScriptSource;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* redis 事务测试
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @since
|
||||
* 2020-02-22 20:26
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
@Rollback()
|
||||
@ContextConfiguration
|
||||
@Configuration
|
||||
@ComponentScan("cn.lili")
|
||||
public class ScriptTest {
|
||||
@Resource
|
||||
private DefaultRedisScript<Boolean> redisScript;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Test
|
||||
public void lua() {
|
||||
stringRedisTemplate.opsForValue().set("key_1", "100");
|
||||
stringRedisTemplate.opsForValue().set("key_2", "95");
|
||||
stringRedisTemplate.opsForValue().set("key_3", "90");
|
||||
stringRedisTemplate.opsForValue().set("key_4", "85");
|
||||
List<String> keys = new ArrayList<>();
|
||||
keys.add("key_1");
|
||||
keys.add("key_2");
|
||||
keys.add("key_3");
|
||||
keys.add("key_4");
|
||||
List<String> value = new ArrayList<>();
|
||||
value.add("-1");
|
||||
value.add("-1");
|
||||
value.add("-1");
|
||||
value.add("-1");
|
||||
//启用十个线程
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
//每个线程循环十次
|
||||
Thread thread = new Thread(() -> {
|
||||
for (int i1 = 0; i1 <= 10; i1++) {
|
||||
Boolean execute = stringRedisTemplate.execute(redisScript, keys, value.toArray());
|
||||
System.out.println(Thread.currentThread().getName() + "|" + i1 + "|" + execute);
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
class LuaConfiguration {
|
||||
@Bean
|
||||
public DefaultRedisScript<Boolean> redisScript() {
|
||||
DefaultRedisScript<Boolean> redisScript = new DefaultRedisScript<>();
|
||||
redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("script/quantity.lua")));
|
||||
redisScript.setResultType(Boolean.class);
|
||||
return redisScript;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user