diff --git a/miaosha-v1/pom.xml b/miaosha-v1/pom.xml
index 6aa15a0..c59d503 100644
--- a/miaosha-v1/pom.xml
+++ b/miaosha-v1/pom.xml
@@ -13,10 +13,7 @@
${project.artifactId}
jar
-
- com.github.sgroschupf
- zkclient
-
+
org.apache.curator
curator-framework
diff --git a/miaosha-v1/src/main/java/com/geekq/miaosha/common/SnowflakeIdWorker.java b/miaosha-v1/src/main/java/com/geekq/miaosha/common/SnowflakeIdWorker.java
index 15c4743..8e31165 100644
--- a/miaosha-v1/src/main/java/com/geekq/miaosha/common/SnowflakeIdWorker.java
+++ b/miaosha-v1/src/main/java/com/geekq/miaosha/common/SnowflakeIdWorker.java
@@ -116,20 +116,6 @@ public class SnowflakeIdWorker {
return idWorker.nextId();
}
- // ==============================Methods==========================================
-
- /**
- * 测试
- */
- public static void main(String[] args) {
- SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
- for (int i = 0; i < 1000; i++) {
- long id = idWorker.nextId();
- System.out.println(Long.toBinaryString(id));
- System.out.println(id);
- }
- }
-
/**
* 获得下一个ID (该方法是线程安全的)
*
diff --git a/miaosha-v1/src/main/java/com/geekq/miaosha/controller/GoodsController.java b/miaosha-v1/src/main/java/com/geekq/miaosha/controller/GoodsController.java
index 7d13ab1..db87657 100644
--- a/miaosha-v1/src/main/java/com/geekq/miaosha/controller/GoodsController.java
+++ b/miaosha-v1/src/main/java/com/geekq/miaosha/controller/GoodsController.java
@@ -18,6 +18,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
+import org.thymeleaf.context.WebContext;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import javax.servlet.http.HttpServletRequest;
@@ -58,7 +59,6 @@ public class GoodsController extends BaseController {
public String detail2(HttpServletRequest request, HttpServletResponse response, Model model, MiaoshaUser user,
@PathVariable("goodsId") long goodsId) {
model.addAttribute("user", user);
-
//取缓存
String html = redisService.get(GoodsKey.getGoodsDetail, "" + goodsId, String.class);
if (!StringUtils.isEmpty(html)) {
@@ -75,26 +75,16 @@ public class GoodsController extends BaseController {
int miaoshaStatus = 0;
int remainSeconds = 0;
if (now < startAt) {//秒杀还没开始,倒计时
- miaoshaStatus = 0;
remainSeconds = (int) ((startAt - now) / 1000);
} else if (now > endAt) {//秒杀已经结束
miaoshaStatus = 2;
remainSeconds = -1;
} else {//秒杀进行中
miaoshaStatus = 1;
- remainSeconds = 0;
}
model.addAttribute("miaoshaStatus", miaoshaStatus);
model.addAttribute("remainSeconds", remainSeconds);
-// return "goods_detail";
-//TODO support spring5
-// SpringWebContext ctx = new SpringWebContext(request,response,
-// request.getServletContext(),request.getLocale(), model.asMap(), applicationContext );
-// html = viewResolver.getTemplateEngine().process("goods_detail", ctx);
-// if(!StringUtils.isEmpty(html)) {
-// redisService.set(GoodsKey.getGoodsDetail, ""+goodsId, html);
-// }
- return html;
+ return "goods_detail";
}
/**
@@ -117,14 +107,12 @@ public class GoodsController extends BaseController {
int miaoshaStatus = 0;
int remainSeconds = 0;
if (now < startAt) {//秒杀还没开始,倒计时
- miaoshaStatus = 0;
remainSeconds = (int) ((startAt - now) / 1000);
} else if (now > endAt) {//秒杀已经结束
miaoshaStatus = 2;
remainSeconds = -1;
} else {//秒杀进行中
miaoshaStatus = 1;
- remainSeconds = 0;
}
GoodsDetailVo vo = new GoodsDetailVo();
vo.setGoods(goods);
diff --git a/miaosha-v1/src/main/java/com/geekq/miaosha/utils/DateTimeUtils.java b/miaosha-v1/src/main/java/com/geekq/miaosha/utils/DateTimeUtils.java
index c9e0021..ba65d81 100644
--- a/miaosha-v1/src/main/java/com/geekq/miaosha/utils/DateTimeUtils.java
+++ b/miaosha-v1/src/main/java/com/geekq/miaosha/utils/DateTimeUtils.java
@@ -47,12 +47,4 @@ public class DateTimeUtils {
return dateTime.toString(STANDARD_FORMAT);
}
-
- public static void main(String[] args) {
- System.out.println(DateTimeUtils.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"));
- System.out.println(DateTimeUtils.strToDate("2010-01-01 11:11:11", "yyyy-MM-dd HH:mm:ss"));
-
- }
-
-
}
\ No newline at end of file
diff --git a/miaosha-v1/src/main/java/com/geekq/miaosha/utils/HttpUtil.java b/miaosha-v1/src/main/java/com/geekq/miaosha/utils/HttpUtil.java
deleted file mode 100644
index c9f4220..0000000
--- a/miaosha-v1/src/main/java/com/geekq/miaosha/utils/HttpUtil.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.geekq.miaosha.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-/**
- * @author 605162215@qq.com
- * @date 2018年1月31日 下午4:32:40
- */
-public class HttpUtil {
- public static void main(String[] args) throws Exception {
-
- for (int i = 0; i < 10; i++) {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- for (int i = 0; i < 10; i++) {
- URL url = new URL("http://192.168.220.130/index.html");
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- InputStream in = conn.getInputStream();
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- byte[] buff = new byte[1024];
- int len = 0;
- while ((len = in.read(buff)) >= 0) {
- bout.write(buff, 0, len);
- }
- in.close();
- bout.close();
- byte[] response = bout.toByteArray();
- System.out.println(new String(response, "UTF-8"));
- Thread.sleep(3000);
- }
- } catch (Exception e) {
-
- }
- }
- });
- t.start();
- }
- }
-}
diff --git a/miaosha-v1/src/main/java/com/geekq/miaosha/utils/MD5Utils.java b/miaosha-v1/src/main/java/com/geekq/miaosha/utils/MD5Utils.java
index 603f555..5ea2e3d 100644
--- a/miaosha-v1/src/main/java/com/geekq/miaosha/utils/MD5Utils.java
+++ b/miaosha-v1/src/main/java/com/geekq/miaosha/utils/MD5Utils.java
@@ -37,8 +37,4 @@ public class MD5Utils {
String dbPass = formPassToDBPass(formPass, saltDB);
return dbPass;
}
-
- public static void main(String[] args) {
- System.out.println(inputPassToDBPass("123456", "1a2b3c4d"));
- }
}
diff --git a/miaosha-v2/miaosha-service/pom.xml b/miaosha-v2/miaosha-service/pom.xml
index 4867aab..626cb58 100644
--- a/miaosha-v2/miaosha-service/pom.xml
+++ b/miaosha-v2/miaosha-service/pom.xml
@@ -15,5 +15,9 @@
com.geekq.v2
miaosha-common
+
+ com.alibaba
+ dubbo
+
\ No newline at end of file
diff --git a/miaosha-v2/miaosha-service/src/main/java/com/geekq/miaosha/service/MiaoshaService.java b/miaosha-v2/miaosha-service/src/main/java/com/geekq/miaosha/service/MiaoshaService.java
index c2acf7b..38dd465 100644
--- a/miaosha-v2/miaosha-service/src/main/java/com/geekq/miaosha/service/MiaoshaService.java
+++ b/miaosha-v2/miaosha-service/src/main/java/com/geekq/miaosha/service/MiaoshaService.java
@@ -29,6 +29,7 @@ public class MiaoshaService {
OrderService orderService;
@Autowired
RedisService redisService;
+
@Reference(version = "${demo.service.version}", retries = 3, timeout = 6000)
private com.geekq.api.service.GoodsService goodsServiceRpc;
diff --git a/pom.xml b/pom.xml
index 7ce2a2e..1d85d20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,6 +54,11 @@
mybatis-paginator
${mybatis.paginator.version}
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.32
+
com.github.pagehelper
pagehelper
@@ -127,7 +132,7 @@
com.alibaba
dubbo
- 2.6.0
+ 2.6.6
org.apache.curator
@@ -152,12 +157,12 @@
org.mybatis
mybatis
- 3.4.6
+ 3.5.6
org.mybatis
mybatis-spring
- 1.2.3
+ 2.0.6
com.alibaba.spring.boot
@@ -181,6 +186,7 @@
mysql
mysql-connector-java
+ 8.0.27