Skip to content

Commit 172aecc

Browse files
committed
基础环境搭建
0 parents  commit 172aecc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4242
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Example user template template
2+
### Example user template
3+
4+
# IntelliJ project files
5+
.idea
6+
*.iml
7+
out
8+
gen
9+
# Created by .ignore support plugin (hsz.mobi)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#个人博客
2+
1.core 核心模块 所有的公用部分都放在此模块
3+
2.web 前台显示模块 启动器:WebMain
4+
3.admin 后台管理模块 启动器:AdminMain

admin/pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>xiaomo</artifactId>
7+
<groupId>info.xiaomo</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>admin</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>info.xiaomo</groupId>
17+
<artifactId>core</artifactId>
18+
<version>1.0.0-SNAPSHOT</version>
19+
</dependency>
20+
</dependencies>
21+
22+
<build>
23+
<plugins>
24+
<plugin>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-maven-plugin</artifactId>
27+
</plugin>
28+
</plugins>
29+
</build>
30+
31+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package info.xiaomo.admin;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5+
import org.springframework.boot.orm.jpa.EntityScan;
6+
import org.springframework.context.annotation.ComponentScan;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
9+
import org.springframework.transaction.annotation.EnableTransactionManagement;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
/**
14+
* 把今天最好的表现当作明天最新的起点..~
15+
* いま 最高の表現 として 明日最新の始発..~
16+
* Today the best performance as tomorrow newest starter!
17+
* Created by IntelliJ IDEA.
18+
*
19+
* @author: xiaomo
20+
* @github: https://github.com/qq83387856
21+
* @email: hupengbest@163.com
22+
* @QQ_NO: 83387856
23+
* @Date: 2016/4/1 15:38
24+
* @Description: 后台管理启动器
25+
* @Copyright(©) 2015 by xiaomo.
26+
**/
27+
@Configuration
28+
@EnableAutoConfiguration
29+
@ComponentScan("info.xiaomo")
30+
@EntityScan("info.xiaomo.*.model")
31+
@EnableTransactionManagement
32+
@EnableJpaRepositories("info.xiaomo.*.dao")
33+
@RestController
34+
public class AdminMain {
35+
36+
public static void main(String[] args) throws Exception {
37+
SpringApplication.run(AdminMain.class, args);
38+
}
39+
40+
@RequestMapping("/")
41+
String index() {
42+
return "Hello World! this is admin index";
43+
}
44+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package info.xiaomo.admin.controller;
2+
3+
import info.xiaomo.core.controller.BaseController;
4+
import info.xiaomo.core.model.UserModel;
5+
import info.xiaomo.core.service.UserService;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.web.bind.annotation.PathVariable;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
/**
12+
* 把今天最好的表现当作明天最新的起点..~
13+
* いま 最高の表現 として 明日最新の始発..~
14+
* Today the best performance as tomorrow newest starter!
15+
* Created by IntelliJ IDEA.
16+
*
17+
* @author: xiaomo
18+
* @github: https://github.com/qq83387856
19+
* @email: hupengbest@163.com
20+
* @QQ_NO: 83387856
21+
* @Date: 2016/4/1 17:51
22+
* @Description: 用户控制器
23+
* @Copyright(©) 2015 by xiaomo.
24+
**/
25+
@RestController
26+
@RequestMapping("user")
27+
public class UserController extends BaseController {
28+
29+
@Autowired
30+
private UserService service;
31+
32+
@RequestMapping("findUserById/{id}")
33+
public UserModel findUserById(@PathVariable("id") Long id) {
34+
return service.findUserById(id);
35+
}
36+
37+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
logging.config=classpath:config/logback-dev.xml
2+
server.port=8080
3+
#datasource
4+
spring.datasource.url=jdbc:mysql://115.29.137.34/xiaomo?useUnicode=true&amp;characterEncoding=UTF-8
5+
spring.datasource.username=xiaomo
6+
spring.datasource.password=123456
7+
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
8+
spring.datasource.max-active=100
9+
spring.datasource.max-idle=100
10+
spring.datasource.min-idle=10
11+
#jpa
12+
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
13+
spring.jpa.hibernate.ddl-auto=update
14+
spring.jpa.show-sql=true
15+
#spring.velocity.cache=false
16+
#spring.velocity.dateToolAttribute=MathTool
17+
#spring.velocity.properties.velocimacro.library=macro/macros.vm
18+
#spring.velocity.toolbox-config-location=toolbox.xml
19+
#spring.velocity.enabled=true
20+
#spring.velocity.suffix=.html
21+
#spring.velocity.charset=utf-8
22+
#logging.level.org.apache.velocity=DEBUG
23+
#spring.velocity.properties.input.encoding=UTF-8
24+
#spring.velocity.properties.output.encoding=UTF-8
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<configuration scan="true">
4+
5+
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
6+
<encoder charset="UTF-8">
7+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level - %msg%n</pattern>
8+
</encoder>
9+
</appender>
10+
11+
<root level="INFO">
12+
<appender-ref ref="stdout"/>
13+
</root>
14+
15+
<logger name="info.xiaomo" level="DEBUG"/>
16+
17+
</configuration>

core/pom.xml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>xiaomo</artifactId>
7+
<groupId>info.xiaomo</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>core</artifactId>
13+
<dependencies>
14+
<!-- spring上下文 -->
15+
<dependency>
16+
<groupId>org.springframework</groupId>
17+
<artifactId>spring-context</artifactId>
18+
</dependency>
19+
<!-- spring data jpa -->
20+
<dependency>
21+
<groupId>org.springframework.data</groupId>
22+
<artifactId>spring-data-jpa</artifactId>
23+
</dependency>
24+
<!-- jpa封装 -->
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-data-jpa</artifactId>
28+
</dependency>
29+
<!-- spring-boot -->
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter</artifactId>
33+
</dependency>
34+
<!-- spring-boot-web -->
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-web</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>junit</groupId>
41+
<artifactId>junit</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>mysql</groupId>
46+
<artifactId>mysql-connector-java</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.slf4j</groupId>
50+
<artifactId>slf4j-api</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>commons-io</groupId>
54+
<artifactId>commons-io</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.alibaba</groupId>
58+
<artifactId>fastjson</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.commons</groupId>
62+
<artifactId>commons-lang3</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>commons-beanutils</groupId>
66+
<artifactId>commons-beanutils</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>commons-digester</groupId>
70+
<artifactId>commons-digester</artifactId>
71+
</dependency>
72+
<dependency>
73+
<groupId>commons-logging</groupId>
74+
<artifactId>commons-logging</artifactId>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.springframework</groupId>
78+
<artifactId>spring-context-support</artifactId>
79+
</dependency>
80+
</dependencies>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-maven-plugin</artifactId>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
90+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package info.xiaomo.core.api;
2+
3+
import java.io.IOException;
4+
import java.util.Properties;
5+
6+
/**
7+
* Oauth 授权
8+
*/
9+
public class OathConfig {
10+
11+
private static Properties props = new Properties();
12+
13+
static {
14+
try {
15+
props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config/oauth.properties"));
16+
} catch (IOException e) {
17+
e.printStackTrace();
18+
}
19+
}
20+
21+
public static void setProps(Properties prop) {
22+
props = prop;
23+
}
24+
25+
public static String getValue(String key) {
26+
return props.getProperty(key);
27+
}
28+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package info.xiaomo.core.api;
2+
3+
4+
import info.xiaomo.core.untils.HttpKit;
5+
6+
import java.io.IOException;
7+
import java.io.UnsupportedEncodingException;
8+
import java.security.KeyManagementException;
9+
import java.security.NoSuchAlgorithmException;
10+
import java.security.NoSuchProviderException;
11+
import java.util.Map;
12+
13+
14+
/**
15+
* Oauth 授权
16+
*/
17+
public class Oauth {
18+
19+
private String clientId;
20+
private String clientSecret;
21+
private String redirectUri;
22+
23+
public Oauth() {
24+
}
25+
26+
protected String getAuthorizeUrl(String authorize, Map<String, String> params) throws UnsupportedEncodingException {
27+
return HttpKit.initParams(authorize, params);
28+
}
29+
30+
protected String doPost(String url, Map<String, String> params) throws IOException, KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException {
31+
return HttpKit.post(url, params);
32+
}
33+
34+
protected String doGet(String url, Map<String, String> params) throws IOException, KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException {
35+
return HttpKit.get(url, params);
36+
}
37+
38+
protected String doGetWithHeaders(String url, Map<String, String> headers) throws IOException, KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException {
39+
return HttpKit.get(url, null, headers);
40+
}
41+
42+
public String getClientId() {
43+
return clientId;
44+
}
45+
46+
public void setClientId(String clientId) {
47+
this.clientId = clientId;
48+
}
49+
50+
public String getClientSecret() {
51+
return clientSecret;
52+
}
53+
54+
public void setClientSecret(String clientSecret) {
55+
this.clientSecret = clientSecret;
56+
}
57+
58+
public String getRedirectUri() {
59+
return redirectUri;
60+
}
61+
62+
public void setRedirectUri(String redirectUri) {
63+
this.redirectUri = redirectUri;
64+
}
65+
}

0 commit comments

Comments
 (0)