Commit 76d3136d authored by 刘文胜's avatar 刘文胜

111

parent 6fb1d4d3
...@@ -22,6 +22,16 @@ ...@@ -22,6 +22,16 @@
<version>3.8.1</version> <version>3.8.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
...@@ -62,6 +72,11 @@ ...@@ -62,6 +72,11 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.5</version> <version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.14</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jaxen</groupId> <groupId>jaxen</groupId>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.hdp.customerservice; package com.hdp;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; ...@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
...@@ -45,6 +46,7 @@ import com.hdp.pi.wechat.Subscriber; ...@@ -45,6 +46,7 @@ import com.hdp.pi.wechat.Subscriber;
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableWebMvc @EnableWebMvc
@EnableWebSocket @EnableWebSocket
@ImportResource({"classpath*:META-INF/spring/applicationContext.xml"})
public class APP extends WebMvcAutoConfiguration public class APP extends WebMvcAutoConfiguration
implements WebSocketConfigurer { implements WebSocketConfigurer {
......
...@@ -8,10 +8,15 @@ ...@@ -8,10 +8,15 @@
*/ */
package com.hdp.customerservice.api; package com.hdp.customerservice.api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import com.hdp.customerservice.repository.MemberRepository;
import com.hdp.customerservice.service.MemberService;
@Controller @Controller
public class TestController { public class TestController {
/** /**
...@@ -22,8 +27,11 @@ public class TestController { ...@@ -22,8 +27,11 @@ public class TestController {
* @date 2015年6月3日 下午4:01:53 * @date 2015年6月3日 下午4:01:53
* @version V1.0 * @version V1.0
*/ */
@Autowired
private MemberService memberService;
@RequestMapping("/test") @RequestMapping("/test")
public @ResponseBody String test(){ public @ResponseBody String test(){
return "woshiyizhixiaoxiaoyayiyayiyayo"; return JSONArray.toJSONString(memberService.getAllList());
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd"
default-lazy-init="true">
<context:property-placeholder
ignore-resource-not-found="true"
location="classpath*:/application.development.properties" />
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
destroy-method="close">
<!-- 基本属性 url、user、password -->
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="${jdbc.pool.initialSize}" />
<property name="minIdle" value="${jdbc.pool.minIdle}" />
<property name="maxActive" value="${jdbc.pool.maxActive}" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="validationQuery" value="SELECT 'x'" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat" />
</bean>
<context:component-scan base-package="com.hdp.customerservice" />
<jpa:repositories base-package="com.hdp.customerservice.repository" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.hdp.customerservice"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${jpa.showsql}" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
</beans>
\ No newline at end of file
...@@ -3,4 +3,15 @@ redis.port = 6379 ...@@ -3,4 +3,15 @@ redis.port = 6379
redis.pass = future123456 redis.pass = future123456
redis.idle = 1 redis.idle = 1
redis.maxActive= 20 redis.maxActive= 20
redis.channel = __http_weixin__ redis.channel = __http_weixin__
\ No newline at end of file
#mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/customerservice?autoReconnect=true&zeroDateTimeBehavior=convertToNull&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=liuwensheng
jdbc.pool.maxActive=20
jdbc.pool.initialSize=1
jdbc.pool.minIdle=1
jpa.showsql=true
...@@ -86,7 +86,7 @@ websocketApp.controller('MessagesCtrl', ...@@ -86,7 +86,7 @@ websocketApp.controller('MessagesCtrl',
function($scope, $rootScope, $location, $resource, $stateParams,$sce,WebSocketService) { function($scope, $rootScope, $location, $resource, $stateParams,$sce,WebSocketService) {
$scope.message = ""; $scope.message = "";
var messages = $scope.messages = []; var messages = $scope.messages = [];
var openId = '';
var tplMessage={ var tplMessage={
touser:'ogoz1t65VSnKQQvYrD9-SLBL2KIk', touser:'ogoz1t65VSnKQQvYrD9-SLBL2KIk',
msgtype:'text', msgtype:'text',
...@@ -115,6 +115,7 @@ websocketApp.controller('MessagesCtrl', ...@@ -115,6 +115,7 @@ websocketApp.controller('MessagesCtrl',
m.message = $sce.trustAsHtml(data.content); m.message = $sce.trustAsHtml(data.content);
$resource('http://sandbox.wxpai.cn/open/user/info?appId=wx3e055e220ddde820&openId='+data.openId) $resource('http://sandbox.wxpai.cn/open/user/info?appId=wx3e055e220ddde820&openId='+data.openId)
.get({},function(res){ .get({},function(res){
console.log(res);
m.headimgurl=res.data.headimgurl; m.headimgurl=res.data.headimgurl;
m.openid=res.data.openid; m.openid=res.data.openid;
},function(res){ },function(res){
......
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