Skip to content

Commit

Permalink
项目部署
Browse files Browse the repository at this point in the history
  • Loading branch information
lyj8330328 committed Jan 10, 2019
1 parent 749048b commit 8635c76
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 98 deletions.
5 changes: 5 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions leyou-api-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>


<!--配置管理依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
2 changes: 1 addition & 1 deletion leyou-api-gateway/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: gateway
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: auth
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

Expand All @@ -30,6 +32,9 @@ public class CartServiceImpl implements CartService {
@Autowired
private StringRedisTemplate stringRedisTemplate;

@Autowired
private RedisTemplate redisTemplate;

@Autowired
private GoodsClient goodsClient;

Expand All @@ -43,6 +48,8 @@ public class CartServiceImpl implements CartService {
*/
@Override
public void addCart(Cart cart) {


//1.获取用户
UserInfo userInfo = LoginInterceptor.getLoginUser();
//2.Redis的key
Expand Down
2 changes: 1 addition & 1 deletion leyou-cart/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: cart
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: comments
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
4 changes: 2 additions & 2 deletions leyou-config/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ spring:
config:
server:
git:
uri: https://gitee.com/lyj8330328/leyou-config-dev.git
uri: https://github.com/lyj8330328/leyou-config.git
rabbitmq:
host: 47.104.175.20
host: 192.168.19.121
username: /leyou
password: leyou
virtual-host: /leyou
Expand Down
2 changes: 1 addition & 1 deletion leyou-goods-web/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: goodsweb
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
124 changes: 63 additions & 61 deletions leyou-goods-web/src/test/java/RedisTest.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
//import com.leyou.LyGoodsWebApplication;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.data.redis.core.BoundHashOperations;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import java.util.HashMap;
//import java.util.Map;
//import java.util.concurrent.TimeUnit;
//
///**
// * @Author: 98050
// * @Time: 2018-10-25 22:58
// * @Feature:
// */
//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = LyGoodsWebApplication.class)
//public class RedisTest {
//
// @Autowired
// private StringRedisTemplate stringRedisTemplate;
//
// @Autowired
// private RedisTemplate<String, String> redisTemplate;
//
// private static final String KEY_PREFIX = "leyou:seckill:test";
//
// @Test
// public void testRedisObj() {
// //redisTemplate.opsForValue().set("111111111","2222221231232222222");
// //redisTemplate.opsForValue().set("key","1");
// redisTemplate.opsForValue().increment("key",1);
// }
//
//
// @Test
// public void test(){
// BoundHashOperations<String,Object,Object> hashOperations = this.stringRedisTemplate.boundHashOps("leyou:goods:detail:1");
// hashOperations.put("1","22222222");
// //hashOperations.expire(10, TimeUnit.SECONDS);
// }
//
// @Test
// public void redisTest(){
// Map<String,String> result = new HashMap<>();
// BoundHashOperations<String,Object,Object> hashOperations = this.stringRedisTemplate.boundHashOps(KEY_PREFIX);
// hashOperations.put("1", "22");
// hashOperations.put("2", "22");
// hashOperations.put("3", "22");
//
//
// System.out.println("---------------------------------------------------------");
// hashOperations.entries().forEach((m,n) ->{
// System.out.println("key:" + m + "," + n);
// });
// }
//}
import com.leyou.LyGoodsWebApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

/**
* @Author: 98050
* @Time: 2018-10-25 22:58
* @Feature:
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = LyGoodsWebApplication.class)
public class RedisTest {

@Autowired
private StringRedisTemplate stringRedisTemplate;

@Autowired
private RedisTemplate<String, String> redisTemplate;

private static final String KEY_PREFIX = "leyou:seckill:test";

@Test
public void testRedisObj() {
//redisTemplate.opsForValue().set("111111111","2222221231232222222");
//redisTemplate.opsForValue().set("key","1");
redisTemplate.opsForValue().increment("key",1);
}


@Test
public void test(){
BoundHashOperations<String,Object,Long> hashOperations = this.stringRedisTemplate.boundHashOps("leyou:goods:detail:1");
BoundValueOperations<String, String> valueOperations = this.stringRedisTemplate.boundValueOps("leyou:goods:detail:1");
valueOperations.set("123", 1);
//hashOperations.increment("123", 2);
//hashOperations.expire(10, TimeUnit.SECONDS);
}

@Test
public void redisTest(){
Map<String,String> result = new HashMap<>();
BoundHashOperations<String,Object,Object> hashOperations = this.stringRedisTemplate.boundHashOps(KEY_PREFIX);
hashOperations.put("1", "22");
hashOperations.put("2", "22");
hashOperations.put("3", "22");


System.out.println("---------------------------------------------------------");
hashOperations.entries().forEach((m,n) ->{
System.out.println("key:" + m + "," + n);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: item
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: order
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
2 changes: 1 addition & 1 deletion leyou-registry/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: registry
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
2 changes: 1 addition & 1 deletion leyou-search/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: search
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,18 @@ public ResponseEntity<String> seckillOrder(@PathVariable("path") String path, @R

//3.读取库存,减一后更新缓存
BoundHashOperations<String,Object,Object> hashOperations = this.stringRedisTemplate.boundHashOps(KEY_PREFIX);
String s = (String) hashOperations.get(seckillGoods.getSkuId().toString());
if (s == null){
return ResponseEntity.ok(result);
}
int stock = Integer.valueOf(s) - 1;
Long stock = hashOperations.increment(seckillGoods.getSkuId().toString(), -1);

//4.库存不足直接返回
if (stock < 0){
localOverMap.put(seckillGoods.getSkuId(),true);
return ResponseEntity.ok(result);
}
//5.更新库存
hashOperations.delete(seckillGoods.getSkuId().toString());
hashOperations.put(seckillGoods.getSkuId().toString(),String.valueOf(stock));

//6.库存充足,请求入队
//6.1 获取用户信息
//5.库存充足,请求入队
//5.1 获取用户信息
SeckillMessage seckillMessage = new SeckillMessage(userInfo,seckillGoods);
//6.2 发送消息
//5.2 发送消息
this.seckillService.sendMessage(seckillMessage);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: seckill
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
2 changes: 1 addition & 1 deletion leyou-sms/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: sms
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
2 changes: 1 addition & 1 deletion leyou-upload/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: upload
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ spring:
name: user
profile: dev
label: master
uri: http://172.31.179.200:10011
uri: http://127.0.0.1:10011

0 comments on commit 8635c76

Please sign in to comment.