Browse Source

tomcat配置修改

zhh 6 years ago
parent
commit
c4cb28cf29

+ 32 - 0
mall-portal/src/main/java/com/macro/mall/portal/config/TomcatConfig.java

@@ -0,0 +1,32 @@
+package com.macro.mall.portal.config;
+
+import org.apache.catalina.connector.Connector;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
+import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * tomcat相关配置
+ * Created by macro on 2018/8/7.
+ */
+@Configuration
+public class TomcatConfig {
+    @Value("${http.port}")
+    private Integer port;
+
+    @Bean
+    public EmbeddedServletContainerFactory servletContainer() {
+        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
+        tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http
+        return tomcat;
+    }
+
+    //配置http
+    private Connector createStandardConnector() {
+        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
+        connector.setPort(port);
+        return connector;
+    }
+}

+ 4 - 3
mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsCartItemServiceImpl.java

@@ -26,14 +26,15 @@ public class OmsCartItemServiceImpl implements OmsCartItemService {
 
     @Override
     public int add(OmsCartItem cartItem) {
+        int count;
         OmsCartItem existCartItem = getCartItem(cartItem);
         if (existCartItem == null) {
-            cartItemMapper.insert(cartItem);
+            count = cartItemMapper.insert(cartItem);
         } else {
             existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
-            cartItemMapper.updateByPrimaryKey(existCartItem);
+            count = cartItemMapper.updateByPrimaryKey(existCartItem);
         }
-        return 1;
+        return count;
     }
 
     /**