Commit efe4ba98 by ethanlamzs

refactor 业务层

1 parent 94314d9d
Showing 44 changed files with 124 additions and 292 deletions
package com.zhzf.fpj.xcx.api.demo;
public interface DemoService {
public interface DemoProvider {
String sayHello(String name);
......
package com.zhzf.fpj.xcx.api.demo;
public interface DemoServiceOther {
public interface DemoProviderOther {
String sayHelloOther(String name);
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo-sec</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-dao-demo-sec</artifactId>
<name>buiness-dao-demo-sec</name>
<description>buiness-dao-demo-sec</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>io.shardingjdbc</groupId>
<artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo-sec</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-service-demo-sec</artifactId>
<name>buiness-service-demo-sec</name>
<description>buiness-service-demo-sec</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo-sec</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DemoServiceIn {
@Autowired(required = false)
private DemoService demoService;
public void testExecute(String appfrom){
System.out.println("#######demo-sec-testExecute ["+ appfrom+"] #########");
demoService.demo(appfrom);
}
}
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
//@ComponentScan("com.zhzf.fpj.xcx.demo")
public class SpringBootDataServiceMain {
// CHECKSTYLE:OFF
public static void main(final String[] args) {
// CHECKSTYLE:ON
Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class;
ApplicationContext applicationContext = SpringApplication.run(starts, args);
//ApplicationContext applicationContext = SpringApplication.run(com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain.class, args);
//applicationContext.getBean(DemoServiceIn.class).testExecute();
}
}
......@@ -8,17 +8,31 @@
</parent>
<artifactId>core-buiness-demo-sec</artifactId>
<name>core-buiness-demo-sec</name>
<description>core-buiness-demo-sec 业务代码的输出</description>
<packaging>pom</packaging>
<modules>
<module>buiness-service-demo-sec</module>
<module>buiness-dao-demo-sec</module>
</modules>
<description>core-buiness-demo-sec</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>io.shardingjdbc</groupId>
<artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -49,7 +49,6 @@ public class SpringBootDataMybatisMain {
//app.addListeners(new ApplicationListener2());
ApplicationContext applicationContext = app.run(args);
//applicationContext.getBean(DemoService.class).demo("local_dao-demo-sec");
//OrchestrationDataSourceCloseableUtil.closeQuietly(applicationContext.getBean(OrchestrationShardingDataSource.class));
......
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package com.zhzf.fpj.xcx.demo.mybatis.service;
public interface DemoService {
public void demo(String fromapp) ;
}
......@@ -15,12 +15,13 @@
* </p>
*/
package com.zhzf.fpj.xcx.demo.mybatis.service;
package com.zhzf.fpj.xcx.demo.mybatis.service.impl;
import com.zhzf.fpj.xcx.demo.mybatis.entity.Order;
import com.zhzf.fpj.xcx.demo.mybatis.entity.OrderItem;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderItemRepository;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderRepository;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import com.zhzf.fpj.xcx.utils.DateUtil;
import org.springframework.stereotype.Service;
......@@ -29,7 +30,7 @@ import java.util.ArrayList;
import java.util.List;
@Service
public class DemoService {
public class DemoServiceImpl implements DemoService {
@Resource
private OrderRepository orderRepository;
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-dao-demo</artifactId>
<name>buiness-dao-demo</name>
<description>buiness-dao-demo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>common-fk-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-service-demo</artifactId>
<name>buiness-service-demo</name>
<description>buiness-service-demo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DemoServiceIn {
@Autowired(required = false)
private DemoService demoService;
public void testExecute(String appfrom){
System.out.println("#######demo-testExecute ["+ appfrom+"] #########");
demoService.demo(appfrom);
}
}
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
//@ComponentScan("com.zhzf.fpj.xcx.demo")
public class SpringBootDataServiceMain {
// CHECKSTYLE:OFF
public static void main(final String[] args) {
// CHECKSTYLE:ON
Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class;
ApplicationContext applicationContext = SpringApplication.run(starts, args);
//ApplicationContext applicationContext = SpringApplication.run(com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain.class, args);
//applicationContext.getBean(DemoServiceIn.class).testExecute();
}
}
......@@ -7,14 +7,9 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>core-buiness-demo</artifactId>
<name>core-buiness</name>
<description>core-buiness-demo 业务代码的输出</description>
<packaging>pom</packaging>
<modules>
<module>buiness-service-demo</module>
<module>buiness-dao-demo</module>
</modules>
<name>core-buiness-demo</name>
<description>core-buiness-demo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
......@@ -24,4 +19,21 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -37,12 +37,8 @@ public class SpringBootDataMybatisMain {
public static void main(final String[] args) {
// CHECKSTYLE:ON
// ApplicationContext applicationContext = SpringApplication.run(SpringBootDataMybatisMain.class, args);
// applicationContext.getBean(DemoService.class).demo();
Object[] starts = new Object[1];
starts[0] = SpringBootDataMybatisMain.class;
SpringApplication app = new SpringApplication(starts);
app.addListeners(new ApplicationEnvironmentPreparedEventListener());
app.addListeners(new ApplicationListener2());
......
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package com.zhzf.fpj.xcx.demo.mybatis.service;
import org.springframework.stereotype.Service;
@Service
public interface DemoService {
public void demo(String fromapp);
}
......@@ -15,12 +15,13 @@
* </p>
*/
package com.zhzf.fpj.xcx.demo.mybatis.service;
package com.zhzf.fpj.xcx.demo.mybatis.service.impl;
import com.zhzf.fpj.xcx.demo.mybatis.entity.Order;
import com.zhzf.fpj.xcx.demo.mybatis.entity.OrderItem;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderItemRepository;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderRepository;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import com.zhzf.fpj.xcx.utils.DateUtil;
import org.springframework.stereotype.Service;
......@@ -29,7 +30,7 @@ import java.util.ArrayList;
import java.util.List;
@Service
public class DemoService {
public class DemoServiceImpl implements DemoService {
@Resource
private OrderRepository orderRepository;
......
......@@ -22,15 +22,10 @@
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-service-demo-sec</artifactId>
<artifactId>core-buiness-demo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo-sec</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
package com.zhzf.fpj.xcx.bootstart;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain;
import com.zhzf.fpj.xcx.envir.ApplicationEnvironmentPreparedEventListener;
import com.zhzf.fpj.xcx.envir.ApplicationListener2;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
......@@ -16,10 +15,9 @@ public class ServiceBootStartApplication {
public static void main(String[] args) {
Object[] starts = new Object[3];
Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class;
starts[2] = ServiceBootStartApplication.class;
starts[1] = ServiceBootStartApplication.class;
SpringApplication app = new SpringApplication(starts);
app.addListeners(new ApplicationEnvironmentPreparedEventListener());
......
package com.zhzf.fpj.xcx.service;
import com.alibaba.dubbo.config.annotation.Service;
import com.zhzf.fpj.xcx.api.demo.DemoService;
import com.zhzf.fpj.xcx.demo.service.DemoServiceIn;
import com.zhzf.fpj.xcx.api.demo.DemoProvider;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
@Service(
......@@ -11,13 +11,13 @@ import org.springframework.beans.factory.annotation.Autowired;
protocol = "${dubbo.protocol.id}",
registry = "${dubbo.registry.id}"
)
public class TestDemoService implements DemoService {
public class TestDemoProvider implements DemoProvider {
@Autowired(required = false)
private DemoServiceIn demoServiceIn;
private DemoService demoService;
public String sayHello(String name) {
demoServiceIn.testExecute("core-service-demo");
demoService.demo("core-service-demo");
return "Hello, " + name + " (from Spring Boot)";
}
......
......@@ -22,15 +22,10 @@
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-service-demo</artifactId>
<artifactId>core-buiness-demo-sec</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
package com.zhzf.fpj.xcx.bootstart;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain;
import com.zhzf.fpj.xcx.envir.ApplicationEnvironmentPreparedEventListener;
import com.zhzf.fpj.xcx.envir.ApplicationListener2;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
......@@ -16,10 +15,9 @@ public class ServiceBootStartApplication {
public static void main(String[] args) {
Object[] starts = new Object[3];
Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class;
starts[2] = ServiceBootStartApplication.class;
starts[1] = ServiceBootStartApplication.class;
SpringApplication app = new SpringApplication(starts);
app.addListeners(new ApplicationEnvironmentPreparedEventListener());
......
package com.zhzf.fpj.xcx.service;
import com.alibaba.dubbo.config.annotation.Service;
import com.zhzf.fpj.xcx.api.demo.DemoService;
import com.zhzf.fpj.xcx.api.demo.DemoServiceOther;
import com.zhzf.fpj.xcx.demo.service.DemoServiceIn;
import com.zhzf.fpj.xcx.api.demo.DemoProvider;
import com.zhzf.fpj.xcx.api.demo.DemoProviderOther;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
@Service(
......@@ -12,13 +12,13 @@ import org.springframework.beans.factory.annotation.Autowired;
protocol = "${dubbo.protocol.id}",
registry = "${dubbo.registry.id}"
)
public class TestDemoService implements DemoServiceOther {
public class TestDemoProvider implements DemoProviderOther {
@Autowired(required = false)
private DemoServiceIn demoServiceIn;
private DemoService demoService;
public String sayHelloOther(String name) {
demoServiceIn.testExecute("notice");
demoService.demo("notice");
return "Hello, " + name + " (from Spring Boot)";
}
......
......@@ -3,8 +3,8 @@ package com.zhzf.fpj.xcx.web.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.zhzf.fpj.xcx.api.demo.DemoService;
import com.zhzf.fpj.xcx.api.demo.DemoServiceOther;
import com.zhzf.fpj.xcx.api.demo.DemoProvider;
import com.zhzf.fpj.xcx.api.demo.DemoProviderOther;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -17,14 +17,14 @@ public class DemoConsumerController {
application = "${dubbo.application.id}",
registry = "${dubbo.registry.id}",
check = false )
private DemoService demoService;
private DemoProvider demoService;
@Reference(version = "1.0.0",
application = "${dubbo.application.id}",
registry = "${dubbo.registry.id}",
check = false )
private DemoServiceOther demoServiceOther;
private DemoProviderOther demoServiceOther;
@RequestMapping("/sayHello")
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!