num lines-num-new"> 86
					<encoding>${encoding}</encoding>
87
					<!-- 通过此方法添加本地jar -->
88
					<compilerArguments>
89
	 					<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
90
	 					<extdirs>${project.basedir}/libs</extdirs>
91
					</compilerArguments>
92
				</configuration>
93
			</plugin>
94
			<plugin>
95
                <groupId>org.apache.maven.plugins</groupId>
96
                <artifactId>maven-surefire-plugin</artifactId>
97
                <configuration>
98
                    <skip>true</skip>
99
                </configuration>
100
            </plugin>
101
            <!-- ==========应用包和依赖包分离的打包方法================ -->
102
				<plugin>
103
	                <groupId>org.apache.maven.plugins</groupId>
104
	                <artifactId>maven-resources-plugin</artifactId>
105
	                <executions>
106
	                    <execution>
107
	                        <id>copy-resources</id>
108
	                        <phase>compile</phase>
109
	                        <goals>
110
	                            <goal>copy-resources</goal>
111
	                        </goals>
112
	                        <configuration>
113
	                            <encoding>${encoding}</encoding>
114
	                            <resources>
115
	                                <resource>
116
	                                    <directory>${project.build.directory}/classes</directory>
117
	                                    <includes>
118
	                                        <include>**/*.properties</include>
119
	                                        <include>**/*.xml</include>
120
	                                        <include>**/*.yaml</include>
121
	                                        <include>**/*.yml</include>
122
	                                        <include>**/*.txt</include>
123
	                                    </includes>
124
	                                </resource>
125
	                            </resources>
126
	                            <!-- 表示把配置文件拷到和jar包同一个路径下 -->
127
	                            <outputDirectory>
128
	                                ${project.build.directory}/config
129
	                            </outputDirectory>
130
	                        </configuration>
131
	                    </execution>
132
	                </executions>
133
	            </plugin>
134
	            <!-- 复制依赖包 -->
135
	            <plugin>
136
	                <groupId>org.apache.maven.plugins</groupId>
137
	                <artifactId>maven-dependency-plugin</artifactId>
138
	                <executions>
139
	                    <execution>
140
	                        <id>copy-dependencies</id>
141
	                        <phase>package</phase>
142
	                        <goals>
143
	                            <goal>copy-dependencies</goal>
144
	                        </goals>
145
	                        <configuration>
146
	                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
147
	                        </configuration>
148
	                    </execution>
149
	                </executions>
150
	            </plugin>
151
	            <plugin>
152
	                <groupId>org.apache.maven.plugins</groupId>
153
	                <artifactId>maven-jar-plugin</artifactId>
154
	                <configuration>
155
	                    <archive>
156
	                        <!--生成的jar中,不要包含pom.xml和pom.properties这两个文件-->
157
	                        <addMavenDescriptor>false</addMavenDescriptor>
158
	                        <manifest>
159
	                            <!--是否要把第三方jar放到manifest的classpath中-->
160
	                            <addClasspath>true</addClasspath>
161
	                            <!--生成的manifest中classpath的前缀,lib存放第三方jar-->
162
	                            <classpathPrefix>lib/</classpathPrefix>
163
	                            <!--应用的main class-->
164
	                            <mainClass>${start-class}</mainClass>
165
	                            <!-- 去掉jar后的时间戳 -->
166
	                            <useUniqueVersions>false</useUniqueVersions>
167
	                        </manifest>
168
	                        <!-- 自定义的MANIFEST.MF参数 -->
169
	                        <manifestEntries>
170
	                        	<!-- 增加classpath目录config -->
171
	                            <Class-Path>./config/</Class-Path>
172
	                        </manifestEntries>
173
	                    </archive>
174
	                    <!--过滤掉不希望包含在jar中的文件-->
175
	                    <excludes>
176
	                        <exclude>**/*.properties</exclude>
177
	                        <exclude>**/*.xml</exclude>
178
	                        <exclude>**/*.yaml</exclude>
179
	                        <exclude>**/*.yml</exclude>
180
	                        <exclude>**/*.txt</exclude>
181
	                    </excludes>
182
	                </configuration>
183
	            </plugin>
184
			
185
				<plugin>
186
	                <groupId>org.apache.maven.plugins</groupId>
187
	                <artifactId>maven-assembly-plugin</artifactId>
188
	                <version>2.4</version>
189
	                <!-- The configuration of the plugin -->
190
	                <configuration>
191
	                    <!-- Specifies the configuration file of the assembly plugin -->
192
	                    <descriptors>
193
	                        <descriptor>src/main/assembly-package.xml</descriptor>
194
	                    </descriptors>
195
	                </configuration>
196
	                <executions>
197
	                    <execution>
198
	                        <id>make-assembly</id>
199
	                        <phase>package</phase>
200
	                        <goals>
201
	                            <goal>single</goal>
202
	                        </goals>
203
	                    </execution>
204
	                </executions>
205
	            </plugin>
206
		</plugins>
207
		<finalName>${project.artifactId}</finalName>
208
	</build>
209
</project>

+ 88 - 0
ebc-restful/pom_full.xml

@ -0,0 +1,88 @@
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<parent>
5
		<groupId>com.ai.ipu.server</groupId>
6
		<artifactId>ipu-rest-libs</artifactId>
7
		<version>3.1-SNAPSHOT</version>
8
	</parent>
9
10
	<artifactId>ebc-restful</artifactId>
11
	<packaging>jar</packaging>
12
	<name>ebc-restful</name>
13
14
	<repositories>
15
		<!-- IPU相关仓库 -->
16
		<repository>
17
			<id>ipu</id>
18
			<name>ipu repository</name>
19
			<url>http://114.215.100.48:9090/nexus/content/groups/public/</url>
20
			<releases>
21
				<enabled>true</enabled>
22
			</releases>
23
			<snapshots>
24
				<enabled>true</enabled>
25
				<updatePolicy>always</updatePolicy>
26
			</snapshots>
27
		</repository>
28
	</repositories>
29
30
	<properties>
31
		<start-class>com.ai.ipu.server.demo.IpuRestDemoStart</start-class>
32
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33
		<ipu>3.1-SNAPSHOT</ipu>
34
		<msgframe>1.9.2</msgframe>
35
		<jms>1.1</jms>
36
	</properties>
37
38
	<dependencies>
39
		<dependency>
40
			<groupId>junit</groupId>
41
			<artifactId>junit</artifactId>
42
			<scope>test</scope>
43
		</dependency>
44
		<dependency>
45
			<groupId>javax.servlet</groupId>
46
			<artifactId>javax.servlet-api</artifactId>
47
			<scope>provided</scope>
48
		</dependency>
49
		<!-- 由于重写了spring的部分类,需要置前引入,提高优先级 -->
50
		<dependency>
51
			<groupId>com.ai.ipu.server</groupId>
52
			<artifactId>ipu-restful</artifactId>
53
		</dependency>
54
		<!-- spring监听,admin-client会引入actuator -->
55
		<dependency>  
56
		    <groupId>de.codecentric</groupId>  
57
		    <artifactId>spring-boot-admin-starter-client</artifactId>
58
		</dependency>
59
		<dependency>
60
			<groupId>com.ai.wade</groupId>
61
			<artifactId>wade-data</artifactId>
62
		</dependency>
63
		<dependency>
64
			<groupId>com.ai.ipu</groupId>
65
			<artifactId>ipu-server-web</artifactId>
66
		</dependency>
67
  		<dependency>
68
		    <groupId>javax.jms</groupId>
69
		    <artifactId>jms</artifactId>
70
		    <version>${jms}</version>
71
		</dependency>
72
		<dependency>
73
		    <groupId>com.ai.ipu</groupId>
74
		    <artifactId>ipu-sql-mgmt</artifactId>
75
		    <version>${ipu}</version>
76
		</dependency>
77
	</dependencies>
78
79
	<build>
80
		<plugins>
81
			<plugin>
82
				<groupId>org.springframework.boot</groupId>
83
				<artifactId>spring-boot-maven-plugin</artifactId>
84
			</plugin>
85
		</plugins>
86
		<finalName>${project.artifactId}</finalName>
87
	</build>
88
</project>

+ 209 - 0
ebc-restful/pom_part.xml

@ -0,0 +1,209 @@
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<parent>
5
		<groupId>com.ai.ipu.server</groupId>
6
		<artifactId>ipu-rest-libs</artifactId>
7
		<version>3.1-SNAPSHOT</version>
8
	</parent>
9
10
	<artifactId>ebc-restful</artifactId>
11
	<packaging>jar</packaging>
12
	<name>ebc-restful</name>
13
14
	<repositories>
15
		<!-- IPU相关仓库 -->
16
		<repository>
17
			<id>ipu</id>
18
			<name>ipu repository</name>
19
			<url>http://114.215.100.48:9090/nexus/content/groups/public/</url>
20
			<releases>
21
				<enabled>true</enabled>
22
			</releases>
23
			<snapshots>
24
				<enabled>true</enabled>
25
				<updatePolicy>always</updatePolicy>
26
			</snapshots>
27
		</repository>
28
	</repositories>
29
30
	<properties>
31
		<start-class>com.ai.ipu.server.demo.IpuRestDemoStart</start-class>
32
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33
		<ipu>3.1-SNAPSHOT</ipu>
34
		<msgframe>1.9.2</msgframe>
35
		<jms>1.1</jms>
36
	</properties>
37
38
	<dependencies>
39
		<dependency>
40
			<groupId>junit</groupId>
41
			<artifactId>junit</artifactId>
42
			<scope>test</scope>
43
		</dependency>
44
		<dependency>
45
			<groupId>javax.servlet</groupId>
46
			<artifactId>javax.servlet-api</artifactId>
47
			<scope>provided</scope>
48
		</dependency>
49
		<!-- 由于重写了spring的部分类,需要置前引入,提高优先级 -->
50
		<dependency>
51
			<groupId>com.ai.ipu.server</groupId>
52
			<artifactId>ipu-restful</artifactId>
53
		</dependency>
54
		<!-- spring监听,admin-client会引入actuator -->
55
		<dependency>  
56
		    <groupId>de.codecentric</groupId>  
57
		    <artifactId>spring-boot-admin-starter-client</artifactId>
58
		</dependency>
59
		<dependency>
60
			<groupId>com.ai.wade</groupId>
61
			<artifactId>wade-data</artifactId>
62
		</dependency>
63
		<dependency>
64
			<groupId>com.ai.ipu</groupId>
65
			<artifactId>ipu-server-web</artifactId>
66
		</dependency>
67
  		<dependency>
68
		    <groupId>javax.jms</groupId>
69
		    <artifactId>jms</artifactId>
70
		    <version>${jms}</version>
71
		</dependency>
72
		<dependency>
73
		    <groupId>com.ai.ipu</groupId>
74
		    <artifactId>ipu-sql-mgmt</artifactId>
75
		    <version>${ipu}</version>
76
		</dependency>
77
	</dependencies>
78
79
	<build>
80
		<plugins>
81
			<plugin>
82
				<artifactId>maven-compiler-plugin</artifactId>
83
				<configuration>
84
					<source>${compiler-version}</source>
85
					<target>${compiler-version}</target>
86
					<encoding>${encoding}</encoding>
87
					<!-- 通过此方法添加本地jar -->
88
					<compilerArguments>
89
	 					<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
90
	 					<extdirs>${project.basedir}/libs</extdirs>
91
					</compilerArguments>
92
				</configuration>
93
			</plugin>
94
			<plugin>
95
                <groupId>org.apache.maven.plugins</groupId>
96
                <artifactId>maven-surefire-plugin</artifactId>
97
                <configuration>
98
                    <skip>true</skip>
99
                </configuration>
100
            </plugin>
101
            <!-- ==========应用包和依赖包分离的打包方法================ -->
102
				<plugin>
103
	                <groupId>org.apache.maven.plugins</groupId>
104
	                <artifactId>maven-resources-plugin</artifactId>
105
	                <executions>
106
	                    <execution>
107
	                        <id>copy-resources</id>
108
	                        <phase>compile</phase>
109
	                        <goals>
110
	                            <goal>copy-resources</goal>
111
	                        </goals>
112
	                        <configuration>
113
	                            <encoding>${encoding}</encoding>
114
	                            <resources>
115
	                                <resource>
116
	                                    <directory>${project.build.directory}/classes</directory>
117
	                                    <includes>
118
	                                        <include>**/*.properties</include>
119
	                                        <include>**/*.xml</include>
120
	                                        <include>**/*.yaml</include>
121
	                                        <include>**/*.yml</include>
122
	                                        <include>**/*.txt</include>
123
	                                    </includes>
124
	                                </resource>
125
	                            </resources>
126
	                            <!-- 表示把配置文件拷到和jar包同一个路径下 -->
127
	                            <outputDirectory>
128
	                                ${project.build.directory}/config
129
	                            </outputDirectory>
130
	                        </configuration>
131
	                    </execution>
132
	                </executions>
133
	            </plugin>
134
	            <!-- 复制依赖包 -->
135
	            <plugin>
136
	                <groupId>org.apache.maven.plugins</groupId>
137
	                <artifactId>maven-dependency-plugin</artifactId>
138
	                <executions>
139
	                    <execution>
140
	                        <id>copy-dependencies</id>
141
	                        <phase>package</phase>
142
	                        <goals>
143
	                            <goal>copy-dependencies</goal>
144
	                        </goals>
145
	                        <configuration>
146
	                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
147
	                        </configuration>
148
	                    </execution>
149
	                </executions>
150
	            </plugin>
151
	            <plugin>
152
	                <groupId>org.apache.maven.plugins</groupId>
153
	                <artifactId>maven-jar-plugin</artifactId>
154
	                <configuration>
155
	                    <archive>
156
	                        <!--生成的jar中,不要包含pom.xml和pom.properties这两个文件-->
157
	                        <addMavenDescriptor>false</addMavenDescriptor>
158
	                        <manifest>
159
	                            <!--是否要把第三方jar放到manifest的classpath中-->
160
	                            <addClasspath>true</addClasspath>
161
	                            <!--生成的manifest中classpath的前缀,lib存放第三方jar-->
162
	                            <classpathPrefix>lib/</classpathPrefix>
163
	                            <!--应用的main class-->
164
	                            <mainClass>${start-class}</mainClass>
165
	                            <!-- 去掉jar后的时间戳 -->
166
	                            <useUniqueVersions>false</useUniqueVersions>
167
	                        </manifest>
168
	                        <!-- 自定义的MANIFEST.MF参数 -->
169
	                        <manifestEntries>
170
	                        	<!-- 增加classpath目录config -->
171
	                            <Class-Path>./config/</Class-Path>
172
	                        </manifestEntries>
173
	                    </archive>
174
	                    <!--过滤掉不希望包含在jar中的文件-->
175
	                    <excludes>
176
	                        <exclude>**/*.properties</exclude>
177
	                        <exclude>**/*.xml</exclude>
178
	                        <exclude>**/*.yaml</exclude>
179
	                        <exclude>**/*.yml</exclude>
180
	                        <exclude>**/*.txt</exclude>
181
	                    </excludes>
182
	                </configuration>
183
	            </plugin>
184
			
185
				<plugin>
186
	                <groupId>org.apache.maven.plugins</groupId>
187
	                <artifactId>maven-assembly-plugin</artifactId>
188
	                <version>2.4</version>
189
	                <!-- The configuration of the plugin -->
190
	                <configuration>
191
	                    <!-- Specifies the configuration file of the assembly plugin -->
192
	                    <descriptors>
193
	                        <descriptor>src/main/assembly-package.xml</descriptor>
194
	                    </descriptors>
195
	                </configuration>
196
	                <executions>
197
	                    <execution>
198
	                        <id>make-assembly</id>
199
	                        <phase>package</phase>
200
	                        <goals>
201
	                            <goal>single</goal>
202
	                        </goals>
203
	                    </execution>
204
	                </executions>
205
	            </plugin>
206
		</plugins>
207
		<finalName>${project.artifactId}</finalName>
208
	</build>
209
</project>

+ 30 - 0
ebc-restful/sql/ipu_db_demo.sql

@ -0,0 +1,30 @@
1
/*
2
Navicat MySQL Data Transfer
3
4
Source Server         : ipu测试-121.42.183.206
5
Source Server Version : 50625
6
Source Host           : 121.42.183.206:3307
7
Source Database       : test
8
9
Target Server Type    : MYSQL
10
Target Server Version : 50625
11
File Encoding         : 65001
12
13
Date: 2019-03-03 00:08:09
14
*/
15
16
SET FOREIGN_KEY_CHECKS=0;
17
18
-- ----------------------------
19
-- Table structure for ipu_db_demo
20
-- ----------------------------
21
DROP TABLE IF EXISTS `ipu_db_demo`;
22
CREATE TABLE `ipu_db_demo` (
23
  `pk` int(255) NOT NULL COMMENT '主键',
24
  `string_type` varchar(255) NOT NULL COMMENT '字符串字段',
25
  `int_type` int(255) NOT NULL COMMENT '整型字段',
26
  `decimal_type` decimal(4,2) NOT NULL COMMENT '小数值字段',
27
  `date_type` date NOT NULL COMMENT '日期字段',
28
  `datetime_type` datetime NOT NULL COMMENT '日期时间字段',
29
  PRIMARY KEY (`pk`)
30
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 24 - 0
ebc-restful/src/main/assembly-package.xml

@ -0,0 +1,24 @@
1
<assembly>
2
    <id>bin</id>
3
    <formats>
4
        <format>zip</format>
5
        <!-- <format>tar.gz</format> -->
6
    </formats>
7
    <!-- 把工程编译的jar打包进zip包的根目录 -->
8
    <files>
9
		<file>
10
			<source>${project.build.directory}/${project.artifactId}.jar</source>
11
			<outputDirectory>/</outputDirectory>
12
		</file>
13
	</files>
14
    <fileSets>
15
        <fileSet>
16
            <directory>${project.build.directory}/lib</directory>
17
            <outputDirectory>/lib</outputDirectory>
18
        </fileSet>
19
        <fileSet>
20
            <directory>${project.build.directory}/config</directory>
21
            <outputDirectory>/config</outputDirectory>
22
        </fileSet>
23
    </fileSets>
24
</assembly>

+ 17 - 0
ebc-restful/src/main/java/com/ai/ipu/server/IpuRestDemoStart.java

@ -0,0 +1,17 @@
1
package com.ai.ipu.server;
2
3
import com.ai.ipu.restful.boot.IpuRestApplication;
4
5
/**
6
 * @author huangbo@asiainfo.com
7
 * @team IPU
8
 * @date 2017年7月30日上午10:03:30
9
 * @desc 启动的时候需要指定参数--server.port=8080
10
 */
11
public class IpuRestDemoStart {
12
    
13
    public static void main(String[] args) {
14
        /*启动SpringBoot服务*/
15
        IpuRestApplication.start(args);
16
    }
17
}

+ 73 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/common/ExceptionController.java

@ -0,0 +1,73 @@
1
package com.ai.ipu.server.control.common;
2
3
import org.springframework.stereotype.Controller;
4
import org.springframework.web.bind.annotation.RequestMapping;
5
6
import com.ai.ipu.basic.util.IpuUtility;
7
import com.ai.ipu.data.JMap;
8
import com.ai.ipu.data.impl.JsonMap;
9
10
/**
11
 * @author huangbo@asiainfo.com
12
 * @team IPU
13
 * @date 2019年1月5日下午18:05:42
14
 * @desc 各类异常处理范例
15
 */
16
@Controller
17
@RequestMapping("/excep")
18
public class ExceptionController {
19
    
20
    /**
21
     * @author huangbo@asiainfo.com
22
     * @title: defaultException
23
     * @desc: 抛出默认异常的范例
24
     */
25
    @RequestMapping("/default")
26
    public JMap defaultException(JMap data) throws Exception {
27
        if(true){
28
            IpuUtility.error("抛出默认异常");
29
        }
30
        return data;
31
    }
32
    
33
    /**
34
     * @author huangbo@asiainfo.com
35
     * @title: customException
36
     * @desc: 抛出定制异常的范例
37
     */
38
    @SuppressWarnings("unused")
39
    @RequestMapping("/custom")
40
    public JMap customException(JMap data) throws Exception {
41
        JMap result = new JsonMap();
42
        if(true){
43
            throw new Exception("抛出定制异常");
44
        }
45
        return result;
46
    }
47
    
48
    /**
49
     * @author huangbo@asiainfo.com
50
     * @title: codeException
51
     * @desc: 抛出异常编码的范例
52
     */
53
    @RequestMapping("/code")
54
    public JMap codeException(JMap data) throws Exception {
55
        if(true){
56
            IpuUtility.errorCode("100");
57
        }
58
        return data;
59
    }
60
    
61
    /**
62
     * @author huangbo@asiainfo.com
63
     * @title: codeMatcherException
64
     * @desc: 抛出有可变参数的异常编码的范例
65
     */
66
    @RequestMapping("/matcher")
67
    public JMap codeMatcherException(JMap data) throws Exception {
68
        if(true){
69
            IpuUtility.errorCode("200", "Request");
70
        }
71
        return data;
72
    }
73
}

+ 59 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/common/LocalExceptionController.java

@ -0,0 +1,59 @@
1
package com.ai.ipu.server.control.common;
2
3
import org.apache.commons.lang3.exception.ExceptionUtils;
4
import org.springframework.stereotype.Controller;
5
import org.springframework.web.bind.annotation.ExceptionHandler;
6
import org.springframework.web.bind.annotation.RequestMapping;
7
import org.springframework.web.servlet.ModelAndView;
8
9
import com.ai.ipu.basic.string.StringUtil;
10
import com.ai.ipu.basic.util.IpuBaseException;
11
import com.ai.ipu.basic.util.IpuUtility;
12
import com.ai.ipu.data.JMap;
13
import com.ai.ipu.restful.util.IpuRestConstant;
14
15
/**
16
 * @author huangbo@asiainfo.com
17
 * @team IPU
18
 * @date 2019年3月1日上午12:18:00
19
 * @desc 局部异常的处理范例
20
 */
21
@Controller
22
@RequestMapping("/excep")
23
public class LocalExceptionController {
24
    
25
    /**
26
     * @author huangbo@asiainfo.com
27
     * @title: localException
28
     * @desc: 抛出局部异常的范例
29
     */
30
    @RequestMapping("/local")
31
    public JMap localException(JMap data) throws Exception {
32
        if(true){
33
            IpuUtility.error("抛出局部异常");
34
        }
35
        return data;
36
    }
37
    
38
    /**
39
     * @author huangbo@asiainfo.com
40
     * @title: localExceptionHandler
41
     * @desc: 捕获局部异常,对应全局异常
42
     */
43
    @ExceptionHandler
44
    public ModelAndView localExceptionHandler(Exception e){
45
        ModelAndView mv = new ModelAndView("/custom"); //ModelAndView只能对应Jsp吗?
46
        if(IpuBaseException.class.isAssignableFrom(e.getClass())){
47
            String resultCode = ((IpuBaseException)e).getCode();
48
            resultCode = StringUtil.isEmpty(resultCode) ? IpuRestConstant.ResultCode.ERROR_CODE : resultCode;
49
            mv.addObject("error_msg", e.getMessage());
50
            mv.addObject("error_code", resultCode);
51
            mv.addObject("error_trace", ExceptionUtils.getStackTrace(e));
52
            return mv;
53
        }else{
54
            mv.addObject("error_msg", e.getMessage());
55
            mv.addObject("error_trace", ExceptionUtils.getStackTrace(e));
56
            return mv;
57
        }
58
    }
59
}

+ 82 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/data/ContextDataController.java

@ -0,0 +1,82 @@
1
package com.ai.ipu.server.control.data;
2
3
import java.util.Iterator;
4
5
import org.springframework.stereotype.Controller;
6
import org.springframework.web.bind.annotation.RequestMapping;
7
import org.springframework.web.bind.annotation.ResponseBody;
8
9
import com.ai.ipu.data.JMap;
10
import com.ai.ipu.data.impl.JsonMap;
11
import com.ai.ipu.restful.frame.context.IpuContextData;
12
import com.ai.ipu.restful.web.ServletManager;
13
14
/**
15
 * @author huangbo@asiainfo.com
16
 * @team IPU
17
 * @date 2018年11月7日下午11:36:42
18
 * @desc 上下文Context操作范例
19
 */
20
@Controller
21
@RequestMapping("/context")
22
public class ContextDataController {
23
    
24
    /**
25
     * @author huangbo@asiainfo.com
26
     * @title: createContext
27
     * @desc: 创建上下文Context的范例
28
     */
29
    @ResponseBody
30
    @RequestMapping("/create")
31
    public JMap createContext(JMap param) {
32
        // TODO Auto-generated method stub
33
        IpuContextData ipuContextData = new IpuContextData();
34
        Iterator<String> it = param.keySet().iterator();
35
        String key;
36
        while(it.hasNext()){
37
            key = it.next();
38
            ipuContextData.put(key, param.get(key).toString());
39
        }
40
        ServletManager.storageContextData(ipuContextData);
41
        JMap result = new JsonMap();
42
        result.put("msg", "创建上下文");
43
        return result;
44
    }
45
    
46
    /**
47
     * @author huangbo@asiainfo.com
48
     * @title: updateContext
49
     * @desc: 修改上下文Context的范例
50
     */
51
    @ResponseBody
52
    @RequestMapping("/update")
53
    public JMap updateContext(JMap param) {
54
        IpuContextData ipuContextData = ServletManager.getContextData();
55
        Iterator<String> it = param.keySet().iterator();
56
        String key;
57
        /*请求结束时,上下文如果有修改,则回写到Session中*/
58
        while(it.hasNext()){
59
            key = it.next();
60
            ipuContextData.put(key, param.get(key).toString());
61
        }
62
        
63
        JMap result = new JsonMap();
64
        result.put("msg", "修改上下文");
65
        return result;
66
    }
67
    
68
    /**
69
     * @author huangbo@asiainfo.com
70
     * @title: takeContext
71
     * @desc: 获取上下文Context的范例
72
     */
73
    @ResponseBody
74
    @RequestMapping("/take")
75
    public JMap takeContext(JMap params) {
76
        IpuContextData ipuContextData = ServletManager.getContextData();
77
        JMap result = new JsonMap();
78
        result.put("context", ipuContextData == null ? "" : ipuContextData.toString());
79
        result.put("msg", "获取上下文");
80
        return result;
81
    }
82
}

+ 60 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/data/DataOtherController.java

@ -0,0 +1,60 @@
1
package com.ai.ipu.server.control.data;
2
3
import java.util.Map;
4
5
import org.springframework.stereotype.Controller;
6
import org.springframework.web.bind.annotation.RequestBody;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.RequestParam;
9
import org.springframework.web.bind.annotation.ResponseBody;
10
11
import com.ai.ipu.data.JMap;
12
import com.ai.ipu.data.impl.JsonMap;
13
14
/**
15
 * @author huangbo@asiainfo.com
16
 * @team IPU
17
 * @date 2018年1月31日上午10:11:03
18
 * @desc 数据请求操作范例
19
 */
20
@Controller
21
@RequestMapping("/data")
22
public class DataOtherController {
23
    /**
24
     * @author huangbo@asiainfo.com
25
     * @title: mapRequest
26
     * @desc: Map类型数据请求范例
27
     */
28
    @ResponseBody
29
    @RequestMapping("/map")
30
    public Map<String, String> mapRequest(@RequestBody Map<String, String> params) {
31
        params.put("msg", "测试post请求传参");
32
        return params;
33
    }
34
    
35
    /**
36
     * @author huangbo@asiainfo.com
37
     * @title: stringRequest
38
     * @desc: 字符串类型数据请求范例
39
     */
40
    @ResponseBody
41
    @RequestMapping("/string")
42
    public String stringRequest(String key) {
43
        return key;
44
    }
45
    
46
    /**
47
     * @author huangbo@asiainfo.com
48
     * @title: stringDataRequest
49
     * @desc: 指定字段的字符串类型数据请求范例
50
     * 通过注解RequestParam获取指定的key的参数
51
     */
52
    @ResponseBody
53
    @RequestMapping(value="/data")
54
    public String stringDataRequest(@RequestParam(value="data")String data) {
55
        JMap param = new JsonMap(data);
56
        param.put("msg", "测试get请求传参");
57
        param.put("data", data);
58
        return param.toString();
59
    }
60
}

+ 40 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/db/DbSqlController.java

@ -0,0 +1,40 @@
1
package com.ai.ipu.server.control.db;
2
3
import java.util.List;
4
import java.util.Map;
5
6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9
10
import com.ai.ipu.data.JMap;
11
import com.ai.ipu.data.impl.JsonMap;
12
import com.ai.ipu.database.dao.IpuDaoManager;
13
import com.ai.ipu.server.dao.BizSqlDao;
14
15
/**
16
 * @author huangbo@asiainfo.com
17
 * @team IPU
18
 * @date 2019年3月2日下午8:35:22
19
 * @desc 基于SQL的操作范例
20
 */
21
@Controller
22
@RequestMapping("/db/sql")
23
public class DbSqlController {
24
    private String connName = "test";
25
    
26
    /**
27
     * @author huangbo@asiainfo.com
28
     * @title: executeSql
29
     * @desc: 执行SQL查询的范例
30
     */
31
    @ResponseBody
32
    @RequestMapping("/execute")
33
    public JMap executeSql(JMap param) throws Exception {
34
        BizSqlDao dao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
35
        List<Map<String, Object>> dataResult = dao.executeSql();
36
        JMap result = new JsonMap();
37
        result.put("result", dataResult);
38
        return result;
39
    }
40
}

+ 75 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/db/DbSqlMgmtController.java

@ -0,0 +1,75 @@
1
package com.ai.ipu.server.control.db;
2
3
import java.util.List;
4
import java.util.Map;
5
6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9
10
import com.ai.ipu.data.JMap;
11
import com.ai.ipu.data.impl.JsonMap;
12
import com.ai.ipu.sql.mgmt.ISqlMgmtDao;
13
import com.ai.ipu.sql.mgmt.SqlManager;
14
import com.ai.ipu.sql.mgmt.SqlMgmtDaoFactory;
15
16
@Controller
17
@RequestMapping("/db/mgmt")
18
public class DbSqlMgmtController {
19
    private String connName = "test";
20
    
21
    @ResponseBody
22
    @RequestMapping("/select")
23
    public JMap executeSqlByFileRepository(JMap param) throws Exception {
24
        // TODO Auto-generated method stub
25
        JMap params = new JsonMap();
26
        params.put("pk", param.getInt("pk", 0));
27
        ISqlMgmtDao dao = SqlMgmtDaoFactory.createFileSqlMgmtDao(connName);
28
        List<Map<String, Object>> dataResult = dao.executeSelect("com.ai.ipu.ipu-db-demo", "select", params);
29
        JMap result = new JsonMap();
30
        result.put("result", dataResult);
31
        return result;
32
    }
33
    
34
    @ResponseBody
35
    @RequestMapping("/insert")
36
    public JMap inertByDbRepository(JMap param) throws Exception {
37
        // TODO Auto-generated method stub
38
        JMap params = new JsonMap();
39
        params.put("pk", 99);
40
        params.put("string_type", "字符串123");
41
        params.put("int_type", 999);
42
        params.put("decimal_type", 9.99);
43
        params.put("date_type", "2019-09-09");
44
        params.put("datetime_type", "2019-07-09 15:10:24");
45
        params.put("null_type", "");
46
        ISqlMgmtDao dao = SqlMgmtDaoFactory.createFileSqlMgmtDao(connName);
47
        int num = dao.executeInsert("com.ai.ipu.ipu-db-demo", "insert", params);
48
        JMap result = new JsonMap();
49
        result.put("result", num);
50
        return result;
51
    }
52
    
53
    @ResponseBody
54
    @RequestMapping("/selectByDb")
55
    public JMap executeSqlByDbRepository(JMap param) throws Exception {
56
        // TODO Auto-generated method stub
57
        JMap params = new JsonMap();
58
        params.put("id", param.getInt("id", 1));
59
        ISqlMgmtDao dao = SqlMgmtDaoFactory.createDbSqlMgmtDao(connName);
60
        List<Map<String, Object>> dataResult = dao.executeSelect("com.ai.ipu.UserMapper", "select", params);
61
        JMap result = new JsonMap();
62
        result.put("result", dataResult);
63
        return result;
64
    }
65
    
66
    @ResponseBody
67
    @RequestMapping("/refresh")
68
    public JMap refreshSqlRepository(JMap param) throws Exception {
69
        // TODO Auto-generated method stub
70
        JMap result = new JsonMap();
71
        SqlManager.refreshSqlCache();
72
        result.put("msg", "刷新成功");
73
        return result;
74
    }
75
}

+ 199 - 0
ebc-restful/src/main/java/com/ai/ipu/server/control/db/DbTableController.java

@ -0,0 +1,199 @@
1
package com.ai.ipu.server.control.db;
2
3
import java.util.List;
4
import java.util.Map;
5
6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9
10
import com.ai.ipu.common.date.TimeUtil;
11
import com.ai.ipu.data.JMap;
12
import com.ai.ipu.data.impl.JsonMap;
13
import com.ai.ipu.database.dao.IpuDaoManager;
14
import com.ai.ipu.server.dao.BizSqlDao;
15
import com.ai.ipu.server.dao.CommonTableDao;
16
import com.ailk.common.data.IData;
17
18
/**
19
 * @author huangbo@asiainfo.com
20
 * @team IPU
21
 * @date 2018年9月13日下午4:14:55
22
 * @desc 基于单表CRUD的操作范例
23
 */
24
@Controller
25
@RequestMapping("/db/table")
26
public class DbTableController {
27
    private String connName = "test";
28
    private String druidConnName = "test_druid";
29
    private String tableName = "ipu_db_demo";
30
    
31
    /**
32
     * @author huangbo@asiainfo.com
33
     * @title: select
34
     * @desc: 基于主键查询数据的范例
35
     */
36
    @ResponseBody
37
    @RequestMapping("/select")
38
    public JMap select(JMap param) throws Exception {
39
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
40
        JMap data = new JsonMap();
41
        data.put("pk", 0);
42
        Map<String, Object> re = dao.select(tableName, data);
43
        JMap result = new JsonMap();
44
        result.put("result", re);
45
        return result;
46
    }
47
    
48
    /**
49
     * @author huangbo@asiainfo.com
50
     * @title: selectByCond
51
     * @desc: 基于条件查询数据的范例
52
     */
53
    @ResponseBody
54
    @RequestMapping("/selectby")
55
    public JMap selectByCond(JMap param) throws Exception {
56
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
57
        JMap condition = new JsonMap();
58
        condition.put("int_type", "0");
59
        List<Map<String, Object>> re = dao.selectByCond(tableName, condition);
60
        JMap result = new JsonMap();
61
        result.put("result", re);
62
        return result;
63
    }
64
    
65
    /**
66
     * @author huangbo@asiainfo.com
67
     * @title: insert
68
     * @desc: 新增数据的范例
69
     */
70
    @ResponseBody
71
    @RequestMapping("/insert")
72
    public JMap insert(JMap param) throws Exception {
73
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
74
        int pk = bizDao.takePK();
75
        
76
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
77
        JMap data = new JsonMap();
78
        data.put("pk", pk);
79
        data.put("string_type", "字符串"+pk);
80
        data.put("int_type", pk);
81
        data.put("decimal_type", "10."+pk);
82
        data.put("date_type", TimeUtil.getSysDate());
83
        data.put("datetime_type", TimeUtil.getSysTime());
84
        int re = dao.insert(tableName, data);
85
        
86
        JMap conds = new JsonMap();
87
        conds.put("pk", pk);
88
        JMap result = new JsonMap();
89
        result.put("result_number", re);
90
        result.put("content", dao.select(tableName, conds));
91
        return result;
92
    }
93
    
94
    /**
95
     * @author huangbo@asiainfo.com
96
     * @title: update
97
     * @desc: 基于主键修改数据的范例
98
     */
99
    @ResponseBody
100
    @RequestMapping("/update")
101
    public JMap update(JMap param) throws Exception {
102
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
103
        JMap data = new JsonMap();
104
        data.put("pk", 0);
105
        data.put("int_type", System.currentTimeMillis()%100);
106
        int re = dao.update(tableName, data);
107
        JMap result = new JsonMap();
108
        result.put("result_number", re);
109
        result.put("content", dao.select(tableName, data));
110
        return result;
111
    }
112
    
113
    /**
114
     * @author huangbo@asiainfo.com
115
     * @title: updateByCond
116
     * @desc: 基于条件修改数据的范例
117
     */
118
    @ResponseBody
119
    @RequestMapping("/updateby")
120
    public JMap updateByCond(JMap param) throws Exception {
121
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
122
        JMap data = new JsonMap();
123
        data.put("int_type", System.currentTimeMillis()%100);
124
        JMap condition = new JsonMap();
125
        condition.put("string_type", "字符串0");
126
        
127
        int re = dao.updateByCond(tableName, data, condition);
128
        JMap result = new JsonMap();
129
        result.put("result_number", re);
130
        condition.put("pk", 0);
131
        result.put("content", dao.select(tableName, condition));
132
        return result;
133
    }
134
    
135
    /**
136
     * @author huangbo@asiainfo.com
137
     * @title: delete
138
     * @desc: 基于主键删除数据的范例
139
     */
140
    @ResponseBody
141
    @RequestMapping("/delete")
142
    public JMap delete(JMap params) throws Exception {
143
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
144
        int pk = bizDao.takePK();
145
        
146
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
147
        JMap data = new JsonMap();
148
        data.put("pk", pk-1);
149
        
150
        Map<String, Object> content = dao.select(tableName, data);
151
        int re = dao.delete(tableName, data);
152
        JMap result = new JsonMap();
153
        result.put("result_number", re);
154
        result.put("content", content);
155
        return result;
156
    }
157
    
158
    /**
159
     * @author huangbo@asiainfo.com
160
     * @title: deleteByCond
161
     * @desc: 基于条件删除数据的范例
162
     */
163
    @ResponseBody
164
    @RequestMapping("/deleteby")
165
    public JMap deleteByCond(JMap params) throws Exception {
166
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
167
        int pk = bizDao.takePK();
168
        
169
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
170
        JMap data = new JsonMap();
171
        data.put("string_type", "字符串"+(pk-1));
172
173
        List<Map<String, Object>> contents = dao.selectByCond(tableName, data);
174
        Map<String, Object> content = (contents!=null&&contents.size()>0)?contents.get(0):null;
175
        int re = dao.deleteByCond(tableName, data);
176
        JMap result = new JsonMap();
177
        result.put("result_number", re);
178
        result.put("content", content);
179
        return result;
180
    }
181
    
182
    /**
183
     * @author huangbo@asiainfo.com
184
     * @title: selectByDruid
185
     * @desc: 基于主键查询数据的范例,使用druid连接池
186
     */
187
    @ResponseBody
188
    @RequestMapping("druid/select")
189
    public JMap selectByDruid(JMap params) throws Exception {
190
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, druidConnName);
191
        JMap data = new JsonMap();
192
        data.put("pk", 0);
193
        
194
        Map<String, Object> re = dao.select(tableName, data);
195
        JMap result = new JsonMap();
196
        result.put("result", re);
197
        return result;
198
    }
199
}

+ 40 - 0
ebc-restful/src/main/java/com/ai/ipu/server/dao/BizSqlDao.java

@ -0,0 +1,40 @@
1
package com.ai.ipu.server.dao;
2
3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6
7
import com.ai.ipu.database.dao.impl.AbstractBizDao;
8
9
/**
10
 * @author huangbo@asiainfo.com
11
 * @team IPU
12
 * @date 2018年1月26日下午5:27:35
13
 * @desc 基于SQL的操作范例
14
 * 业务dao不暴露和业务无关的方法.
15
 */
16
public class BizSqlDao extends AbstractBizDao{
17
18
    public BizSqlDao(String connName) throws IOException {
19
        super(connName);
20
    }
21
22
    public List<Map<String, Object>> executeSql() throws Exception {
23
        String sql = "SELECT * FROM ipu_db_demo";
24
        List<Map<String, Object>> dataResult = getBasicDao().executeSelect(sql);
25
        return dataResult;
26
    }
27
    
28
    public int takePK() throws Exception {
29
        String sql = "SELECT * FROM ipu_db_demo order by datetime_type desc";
30
        Map<String, Object> dataResult = getBasicDao().executeSelectFirst(sql);
31
        int pk;
32
        if(dataResult==null||dataResult.isEmpty()){
33
            pk = 0;
34
        }else{
35
            pk = Integer.parseInt(dataResult.get("pk").toString());
36
            pk++;
37
        }
38
        return pk;
39
    }
40
}

+ 52 - 0
ebc-restful/src/main/java/com/ai/ipu/server/dao/CommonTableDao.java

@ -0,0 +1,52 @@
1
package com.ai.ipu.server.dao;
2
3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6
7
import com.ai.ipu.database.dao.impl.AbstractBizDao;
8
9
/**
10
 * @author huangbo@asiainfo.com
11
 * @team IPU
12
 * @date 2018年9月6日下午10:05:42
13
 * @desc 通用基于单表CRUD的操作范例
14
 */
15
public class CommonTableDao extends AbstractBizDao{
16
17
    public CommonTableDao(String connName) throws IOException {
18
        super(connName);
19
    }
20
21
    public int insert(String tableName, Map<String, Object> data) throws Exception {
22
        return dao.insert(tableName, data);
23
    }
24
25
    public int delete(String tableName, Map<String, Object> data) throws Exception {
26
        return dao.delete(tableName, data);
27
    }
28
    
29
    public int deleteByCond(String tableName, Map<String, Object> condition) throws Exception {
30
        return dao.deleteByCond(tableName, condition);
31
    }
32
33
    public int update(String tableName, Map<String, Object> data, boolean isMatchColumn) throws Exception {
34
        return dao.update(tableName, data, isMatchColumn);
35
    }
36
    
37
    public int update(String tableName, Map<String, Object> data) throws Exception {
38
        return dao.update(tableName, data);
39
    }
40
    
41
    public int updateByCond(String tableName, Map<String, Object> data, Map<String, Object> condition) throws Exception {
42
        return dao.updateByCond(tableName, data, condition);
43
    }
44
45
    public Map<String, Object> select(String tableName, Map<String, Object> data) throws Exception {
46
        return dao.select(tableName, data);
47
    }
48
    
49
    public List<Map<String, Object>> selectByCond(String tableName, Map<String, Object> condition) throws Exception {
50
        return dao.selectByCond(tableName, condition);
51
    }
52
}

+ 35 - 0
ebc-restful/src/main/java/com/ai/ipu/server/interceptor/DemoInterceptor.java

@ -0,0 +1,35 @@
1
package com.ai.ipu.server.interceptor;
2
3
import javax.servlet.http.HttpServletRequest;
4
import javax.servlet.http.HttpServletResponse;
5
6
import org.springframework.web.servlet.HandlerInterceptor;
7
import org.springframework.web.servlet.ModelAndView;
8
9
public class DemoInterceptor implements HandlerInterceptor {
10
11
	@Override
12
	public boolean preHandle(HttpServletRequest request,
13
			HttpServletResponse response, Object handler) throws Exception {
14
		// TODO Auto-generated method stub
15
		System.out.println("特定拦截器:" + this);
16
		return true;
17
	}
18
19
	@Override
20
	public void postHandle(HttpServletRequest request,
21
			HttpServletResponse response, Object handler,
22
			ModelAndView modelAndView) throws Exception {
23
		// TODO Auto-generated method stub
24
25
	}
26
27
	@Override
28
	public void afterCompletion(HttpServletRequest request,
29
			HttpServletResponse response, Object handler, Exception ex)
30
			throws Exception {
31
		// TODO Auto-generated method stub
32
33
	}
34
35
}

+ 12 - 0
ebc-restful/src/main/java/com/ai/ipu/server/util/IpuRestDemoConstant.java

@ -0,0 +1,12 @@
1
package com.ai.ipu.server.util;
2
3
import com.ai.ipu.basic.doc.NonJavaDoc;
4
5
@NonJavaDoc
6
public class IpuRestDemoConstant {
7
8
    @NonJavaDoc
9
    public static class ResultCode{
10
        public static final String BIZ_CODE = "-100"; //业务异常
11
    }
12
}

+ 33 - 0
ebc-restful/src/main/java/com/ai/ipu/service/IBizService.java

@ -0,0 +1,33 @@
1
package com.ai.ipu.service;
2
3
import com.ailk.common.data.IData;
4
5
/**
6
 * @author huangbo@asiainfo.com
7
 * @team IPU
8
 * @date 2018年10月23日下午7:25:11
9
 * @desc 业务服务调用案例
10
 */
11
public interface IBizService {
12
    
13
    /**
14
     * @author huangbo@asiainfo.com
15
     * @title: queryUserInfo
16
     * @desc: 查询用户信息
17
     */
18
    public IData queryUserInfo(IData param);
19
    
20
    /**
21
     * @author huangbo@asiainfo.com
22
     * @title: queryUserInfo
23
     * @desc: 查询用户列表
24
     */
25
    public IData queryUserList(IData param);
26
    
27
    /**
28
     * @author huangbo@asiainfo.com
29
     * @title: triggerException
30
     * @desc: 触发业务异常
31
     */
32
    public IData triggerException(IData param);
33
}

+ 23 - 0
ebc-restful/src/main/resources/dev/application.properties

@ -0,0 +1,23 @@
1
######设置服务器端口
2
######也可以通过启动命令行参数实现:java -jar myproject.jar --server.port=9084
3
server.port=unknown
4
5
web.root=webapp/
6
#会影响拦截器的配置exclude-mapping
7
spring.mvc.static-path-pattern=/**
8
#spring.resources.static-locations=file:${web.root}
9
spring.resources.static-locations=classpath:/${web.root}
10
11
######默认/
12
server.context-path=/ipu
13
######默认/。注册DispatcherServlet对应path,亦可通过dispatcherRegistration方法配置
14
server.servlet-path=/
15
#使用maven中的变量替换
16
logging.file=target/logs/${project.artifactId}.log
17
spring.application.name=${project.artifactId}
18
19
######查看spring错误日志
20
#logging.level.org.springframework=DEBUG
21
22
######session使用默认
23
spring.session.store-type=none

+ 54 - 0
ebc-restful/src/main/resources/dev/ipu-mybatis-config.xml

@ -0,0 +1,54 @@
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE configuration
3
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
4
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
5
6
<configuration>
7
    <settings>
8
		<setting name="defaultFetchSize" value="1000" /> <!-- 结果集获取数量提示值,分批传输 -->
9
	</settings>
10
    <plugins>
11
        <!-- 分页插件,可根据参数定制化 -->
12
	    <plugin interceptor="com.github.pagehelper.PageInterceptor">
13
	        <!-- config params as the following -->
14
		</plugin>
15
		<plugin interceptor="com.ai.ipu.sql.mgmt.mybatis.SqlMgmtPlugin">
16
		</plugin>
17
	</plugins>
18
	<environments default="test">
19
		<environment id="test">
20
			<transactionManager type="JDBC" />
21
			<dataSource type="com.ai.ipu.database.datasource.DruidDataSourceFactory">
22
				<property name="jdbcUrl" value="jdbc:mysql://121.42.183.206:3307/test" />
23
				<property name="username" value="ipu" />
24
				<property name="password" value="ipumysql" />
25
			</dataSource>
26
		</environment>
27
		
28
		<environment id="test_druid">
29
			<transactionManager type="JDBC" />
30
			<dataSource type="com.ai.ipu.database.datasource.DruidDataSourceFactory">
31
				<property name="jdbcUrl" value="jdbc:mysql://121.42.183.206:3307/test" />
32
				<property name="username" value="ipu" />
33
				<property name="password" value="ipumysql" />
34
				
35
				<!-- 配置获取连接的等待超时时间 -->
36
                <property name="maxWait" value="60000" />
37
				<!-- 配置初始化大小、最小、最大 -->
38
                <property name="initialSize" value="1" />
39
                <property name="minIdle" value="1" />
40
                <property name="maxActive" value="20" />
41
                <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
42
                <property name="minEvictableIdleTimeMillis" value="300000" />
43
                <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
44
                <property name="timeBetweenEvictionRunsMillis" value="60000" />
45
				<property name="validationQuery" value="SELECT 'x'" />
46
                <property name="testWhileIdle" value="true" />
47
                <property name="testOnBorrow" value="false" />
48
                <property name="testOnReturn" value="false" />
49
                <!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
50
                <property name="filters" value="stat" />
51
			</dataSource>
52
		</environment>
53
	</environments>
54
</configuration>

+ 25 - 0
ebc-restful/src/main/resources/dev/log4j.properties

@ -0,0 +1,25 @@
1
### set log levels ###
2
log4j.rootLogger=DEBUG
3
4
### direct log messages to stdout ###
5
log4j.appender.Console=org.apache.log4j.ConsoleAppender
6
log4j.appender.Console.Target=System.out
7
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
8
log4j.appender.Console.layout.ConversionPattern=%-5p(%10c{1}) %m%n
9
10
### direct messages to file framework.log ###
11
log4j.appender.Offline=org.apache.log4j.DailyRollingFileAppender
12
log4j.appender.Offline.File=logs/mobile.log
13
log4j.appender.Offline.DatePattern='.'yyyy-MM-dd
14
log4j.appender.Offline.layout=org.apache.log4j.PatternLayout
15
log4j.appender.Offline.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
16
17
### error log file ###
18
log4j.appender.Error=org.apache.log4j.DailyRollingFileAppender
19
log4j.appender.Error.DatePattern='.'yyyy-MM-dd
20
log4j.appender.Error.File=logs/mobile_error.log
21
log4j.appender.Error.layout=org.apache.log4j.PatternLayout
22
log4j.appender.Error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p(%10c{1}) %m%n 
23
24
### application log config ###
25
log4j.logger.com.ai=DEBUG,Console

+ 29 - 0
ebc-restful/src/main/resources/dev/sql_mgmt_mybatis.xml

@ -0,0 +1,29 @@
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE configuration
3
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
4
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
5
<!-- <!DOCTYPE configuration SYSTEM "mybatis-ipu-3-config.dtd"> -->
6
7
<configuration>
8
    <settings>
9
		<setting name="defaultFetchSize" value="1000" /> <!-- 结果集获取数量提示值,分批传输 -->
10
	</settings>
11
    <plugins>
12
        <!-- 分页插件,可根据参数定制化 -->
13
        <plugin interceptor="com.github.pagehelper.PageInterceptor">
14
	        <!-- config params as the following -->
15
		</plugin>
16
	</plugins>
17
	<environments default="ipu_sql_mgmt">
18
		<environment id="ipu_sql_mgmt">
19
			<transactionManager type="JDBC" />
20
			<dataSource type="com.ai.ipu.database.datasource.DruidDataSourceFactory">
21
				<property name="jdbcUrl" value="jdbc:mysql://121.42.183.206:3307/ipu_sql_mgmt" />
22
				<property name="username" value="ipu" />
23
				<property name="password" value="ipumysql" />
24
				<!-- 配置获取连接的等待超时时间 -->
25
				<property name="maxWait" value="5000" />
26
			</dataSource>
27
		</environment>
28
	</environments>
29
</configuration>

+ 2 - 0
ebc-restful/src/main/resources/exception_messages_zh_CN.properties

@ -0,0 +1,2 @@
1
100=条件参数不能为空
2
200=[%v]参数异常

+ 14 - 0
ebc-restful/src/main/resources/ipu-spring-mvc.xml

@ -0,0 +1,14 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
4
	xmlns:context="http://www.springframework.org/schema/context"
5
	xmlns:mvc="http://www.springframework.org/schema/mvc"
6
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
7
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
8
           http://www.springframework.org/schema/context  
9
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
10
        http://www.springframework.org/schema/mvc
11
		http://www.springframework.org/schema/mvc/spring-mvc.xsd">
12
	<!-- 自定义的control扫描目录 -->
13
    <context:component-scan base-package="com.ai.ipu.server" />
14
</beans> 

+ 43 - 0
ebc-restful/src/main/resources/pro/application.properties

@ -0,0 +1,43 @@
1
######设置服务器端口
2
######也可以通过启动命令行参数实现:java -jar myproject.jar --server.port=9084
3
server.port=unknown
4
5
web.root=webapp/
6
#会影响拦截器的配置exclude-mapping
7
spring.mvc.static-path-pattern=/**
8
#spring.resources.static-locations=file:${web.root}
9
spring.resources.static-locations=classpath:/${web.root}
10
11
######context-path默认/
12
server.context-path=/ipu
13
######注册DispatcherServlet对应path,亦可通过dispatcherRegistration方法配置
14
#server.servlet-path=/ipu1
15
#使用maven中的变量替换
16
logging.file=target/logs/${project.artifactId}.log
17
spring.application.name=${project.artifactId}
18
19
######sba监控
20
management.security.enabled=false
21
spring.boot.admin.url=http://www.aiipu.com:8888
22
security.user.name=ipu
23
security.user.password=ipu
24
spring.boot.admin.client.metadata.user.name=${security.user.name}
25
spring.boot.admin.client.metadata.user.password=${security.user.password}
26
27
######查看spring错误日志
28
#logging.level.org.springframework=DEBUG
29
30
######session使用redis
31
spring.session.store-type=redis
32
######redis集群和连接池相关配置
33
spring.redis.cluster.nodes=123.57.35.51:11001,123.57.35.51:11002,123.57.35.51:11003,123.57.35.51:11004,123.57.35.51:11005,123.57.35.51:11006
34
spring.redis.cluster.timeout=5
35
spring.redis.cluster.max-redirects=3
36
spring.redis.password=ipu
37
spring.redis.pool.max-active=8
38
spring.redis.pool.max-idle=8
39
spring.redis.pool.max-wait=-1
40
#默认0,不回收
41
spring.redis.pool.min-idle=8
42
  
43

+ 28 - 0
ebc-restful/src/main/resources/pro/ipu-mybatis-config.xml

@ -0,0 +1,28 @@
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE configuration
3
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
4
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
5
6
<configuration>
7
    <settings>
8
		<setting name="defaultFetchSize" value="1000" /> <!-- 结果集获取数量提示值,分批传输 -->
9
	</settings>
10
    <plugins>
11
        <!-- 分页插件,可根据参数定制化 -->
12
	    <plugin interceptor="com.github.pagehelper.PageInterceptor">
13
	        <!-- config params as the following -->
14
		</plugin>
15
	</plugins>
16
	<environments default="test">
17
		<environment id="test">
18
			<transactionManager type="JDBC" />
19
			<dataSource type="com.ai.ipu.database.datasource.DruidDataSourceFactory">
20
				<property name="jdbcUrl" value="jdbc:mysql://121.42.183.206:3307/test" />
21
				<property name="username" value="ipu" />
22
				<property name="password" value="ipumysql" />
23
				<!-- 配置获取连接的等待超时时间 -->
24
				<property name="maxWait" value="5000" />
25
			</dataSource>
26
		</environment>
27
	</environments>
28
</configuration>

+ 25 - 0
ebc-restful/src/main/resources/pro/log4j.properties

@ -0,0 +1,25 @@
1
### set log levels ###
2
log4j.rootLogger=DEBUG
3
4
### direct log messages to stdout ###
5
log4j.appender.Console=org.apache.log4j.ConsoleAppender
6
log4j.appender.Console.Target=System.out
7
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
8
log4j.appender.Console.layout.ConversionPattern=%-5p(%10c{1}) %m%n
9
10
### direct messages to file framework.log ###
11
log4j.appender.Offline=org.apache.log4j.DailyRollingFileAppender
12
log4j.appender.Offline.File=logs/mobile.log
13
log4j.appender.Offline.DatePattern='.'yyyy-MM-dd
14
log4j.appender.Offline.layout=org.apache.log4j.PatternLayout
15
log4j.appender.Offline.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
16
17
### error log file ###
18
log4j.appender.Error=org.apache.log4j.DailyRollingFileAppender
19
log4j.appender.Error.DatePattern='.'yyyy-MM-dd
20
log4j.appender.Error.File=logs/mobile_error.log
21
log4j.appender.Error.layout=org.apache.log4j.PatternLayout
22
log4j.appender.Error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p(%10c{1}) %m%n 
23
24
### application log config ###
25
log4j.logger.com.ai=DEBUG,Console

+ 26 - 0
ebc-restful/src/main/resources/sql/com/ai/ipu/ipu-db-demo.xml

@ -0,0 +1,26 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<sqls>
3
	<sql name="select">
4
		<![CDATA[
5
		<select id="select" resultType="java.util.Map">
6
	        SELECT * FROM  ipu_db_demo WHERE pk=#{pk}
7
		</select>
8
		]]>
9
	</sql>
10
	
11
	<sql name="insert">
12
		<![CDATA[
13
		<insert id="insert" resultType="java.util.Map">
14
	        INSERT INTO ipu_db_demo VALUES(
15
	        	#{pk},
16
				#{string_type},
17
				#{int_type},
18
				#{decimal_type},
19
				#{date_type},
20
				#{datetime_type},
21
				#{null_type}
22
	        )
23
		</insert>
24
		]]>
25
	</sql>
26
</sqls>

+ 16 - 0
ebc-restful/src/main/resources/sql/com/ai/ipu/user/user.xml

@ -0,0 +1,16 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<sqls>
3
	<sql name="select">
4
		<![CDATA[
5
		<select id="select" resultType="java.util.Map" useCache="true">
6
	        select id, name from user 
7
	        <where>
8
	            <if test="id == 1">
9
	                id = #{id}
10
	            </if>
11
	        </where>
12
	        order by name
13
		</select>
14
		]]>
15
	</sql>
16
</sqls>

+ 43 - 0
ebc-restful/src/main/resources/test/application.properties

@ -0,0 +1,43 @@
1
######设置服务器端口
2
######也可以通过启动命令行参数实现:java -jar myproject.jar --server.port=9084
3
server.port=unknown
4
5
web.root=webapp/
6
#会影响拦截器的配置exclude-mapping
7
spring.mvc.static-path-pattern=/**
8
#spring.resources.static-locations=file:${web.root}
9
spring.resources.static-locations=classpath:/${web.root}
10
11
######context-path默认/
12
server.context-path=/ipu
13
######注册DispatcherServlet对应path,亦可通过dispatcherRegistration方法配置
14
#server.servlet-path=/ipu1
15
#使用maven中的变量替换
16
logging.file=target/logs/${project.artifactId}.log
17
spring.application.name=${project.artifactId}
18
19
######sba监控
20
management.security.enabled=false
21
spring.boot.admin.url=http://127.0.0.1:8888
22
security.user.name=ipu
23
security.user.password=ipu
24
spring.boot.admin.client.metadata.user.name=${security.user.name}
25
spring.boot.admin.client.metadata.user.password=${security.user.password}
26
27
######查看spring错误日志
28
#logging.level.org.springframework=DEBUG
29
30
######session使用redis
31
spring.session.store-type=redis
32
######redis集群和连接池相关配置
33
spring.redis.cluster.nodes=123.57.35.51:11001,123.57.35.51:11002,123.57.35.51:11003,123.57.35.51:11004,123.57.35.51:11005,123.57.35.51:11006
34
spring.redis.cluster.timeout=5
35
spring.redis.cluster.max-redirects=3
36
spring.redis.password=ipu
37
spring.redis.pool.max-active=8
38
spring.redis.pool.max-idle=8
39
spring.redis.pool.max-wait=-1
40
#默认0,不回收
41
spring.redis.pool.min-idle=8
42
  
43

+ 39 - 0
ebc-restful/src/main/resources/test/ipu-mybatis-config.xml

@ -0,0 +1,39 @@
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE configuration
3
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
4
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
5
6
<configuration>
7
    <settings>
8
		<setting name="defaultFetchSize" value="1000" /> <!-- 结果集获取数量提示值,分批传输 -->
9
	</settings>
10
    <plugins>
11
        <!-- 分页插件,可根据参数定制化 -->
12
	    <plugin interceptor="com.github.pagehelper.PageInterceptor">
13
	        <!-- config params as the following -->
14
		</plugin>
15
	</plugins>
16
	<environments default="test">
17
		<environment id="test">
18
			<transactionManager type="JDBC" />
19
			<dataSource type="com.ai.ipu.database.datasource.C3P0DataSourceFactory">
20
				<property name="driverClass" value="com.mysql.jdbc.Driver" />
21
				<property name="jdbcUrl" value="jdbc:mysql://121.42.183.206:3307/test" />
22
				<property name="user" value="ipu" />
23
				<property name="password" value="ipumysql" />
24
				<!-- 连接池用完时,等待获取新连接的时间 (毫秒) -->
25
				<property name="checkoutTimeout" value="5000" />
26
				<!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->
27
				<property name="acquireRetryAttempts" value="5" />
28
				<!--两次连接中间隔时间,单位毫秒。Default: 1000 -->
29
				<property name="acquireRetryDelay" value="1000" />
30
				<property name="initialPoolSize" value="3" />
31
				<property name="minPoolSize" value="3" />
32
				<property name="maxPoolSize" value="3" />
33
				<property name="maxIdleTime" value="600" />
34
				<property name="idleConnectionTestPeriod" value="60" />
35
				<property name="preferredTestQuery" value="SELECT 1" />
36
			</dataSource>
37
		</environment>
38
	</environments>
39
</configuration>

+ 25 - 0
ebc-restful/src/main/resources/test/log4j.properties

@ -0,0 +1,25 @@
1
### set log levels ###
2
log4j.rootLogger=DEBUG
3
4
### direct log messages to stdout ###
5
log4j.appender.Console=org.apache.log4j.ConsoleAppender
6
log4j.appender.Console.Target=System.out
7
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
8
log4j.appender.Console.layout.ConversionPattern=%-5p(%10c{1}) %m%n
9
10
### direct messages to file framework.log ###
11
log4j.appender.Offline=org.apache.log4j.DailyRollingFileAppender
12
log4j.appender.Offline.File=logs/mobile.log
13
log4j.appender.Offline.DatePattern='.'yyyy-MM-dd
14
log4j.appender.Offline.layout=org.apache.log4j.PatternLayout
15
log4j.appender.Offline.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
16
17
### error log file ###
18
log4j.appender.Error=org.apache.log4j.DailyRollingFileAppender
19
log4j.appender.Error.DatePattern='.'yyyy-MM-dd
20
log4j.appender.Error.File=logs/mobile_error.log
21
log4j.appender.Error.layout=org.apache.log4j.PatternLayout
22
log4j.appender.Error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p(%10c{1}) %m%n 
23
24
### application log config ###
25
log4j.logger.com.ai=DEBUG,Console

common-ui - Nuosi Git Service

AIoT前端公共UI

components.d.ts 3.0KB

    // generated by unplugin-vue-components // We suggest you to commit this file into source control // Read more: https://github.com/vuejs/core/pull/3399 import '@vue/runtime-core' export {} declare module '@vue/runtime-core' { export interface GlobalComponents { ElAside: typeof import('element-plus/es')['ElAside'] ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem'] ElButton: typeof import('element-plus/es')['ElButton'] ElCascader: typeof import('element-plus/es')['ElCascader'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCol: typeof import('element-plus/es')['ElCol'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElForm: typeof import('element-plus/es')['ElForm'] ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElHeader: typeof import('element-plus/es')['ElHeader'] ElIcon: typeof import('element-plus/es')['ElIcon'] ElImage: typeof import('element-plus/es')['ElImage'] ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElMain: typeof import('element-plus/es')['ElMain'] ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElOption: typeof import('element-plus/es')['ElOption'] ElRadio: typeof import('element-plus/es')['ElRadio'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] ElRow: typeof import('element-plus/es')['ElRow'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabs: typeof import('element-plus/es')['ElTabs'] ElTag: typeof import('element-plus/es')['ElTag'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTree: typeof import('element-plus/es')['ElTree'] ElUpload: typeof import('element-plus/es')['ElUpload'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] } }
common-ui - Nuosi Git Service

AIoT前端公共UI

index.html 511B

    <!-- * @Author: Devin * @Date: 2023-01-11 16:29:53 * @LastEditors: Devin * @LastEditTime: 2023-02-22 10:46:55 * @Description: entry --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> --> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>common-ui</title> </head> <body> <div id="app"></div> <script type="module" src="/examples/main.ts"></script> </body> </html>