-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ZhangYinHua
committed
Aug 27, 2018
1 parent
7ed4ba2
commit 2a03e12
Showing
15 changed files
with
655 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#update port :8010 | ||
server: | ||
address: 8010 | ||
|
||
spring: | ||
#config mysql datasource | ||
datasource: | ||
url: jdbc:mysql://127.0.0.1:3306/lance?useUnicode=true&characterEncoding=utf8 | ||
username: root | ||
password: 12345 | ||
driver-class-name: com.mysql.jdbc.Driver | ||
|
||
#mybatis config | ||
mybatis: | ||
mapper-locations: classpath:mapper/*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/build/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
<artifactId>springboot-poi</artifactId> | ||
|
||
<parent> | ||
<groupId>com.lance.learn</groupId> | ||
<artifactId>springbootlearning</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>springboot-poi</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-jdbc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mybatis.spring.boot</groupId> | ||
<artifactId>mybatis-spring-boot-starter</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<!--<scope>runtime</scope>--> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!--poi--> | ||
<dependency> | ||
<groupId>org.apache.poi</groupId> | ||
<artifactId>poi-ooxml</artifactId> | ||
<version>3.9</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-fileupload</groupId> | ||
<artifactId>commons-fileupload</artifactId> | ||
<version>1.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.4</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
<finalName>SpringBoot-Mybatis-${profileActive}</finalName> | ||
</build> | ||
|
||
|
||
</project> |
12 changes: 12 additions & 0 deletions
12
SpringBoot-POI/src/main/java/com/lance/learn/springbootpoi/SpringbootPoiApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.lance.learn.springbootpoi; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringbootPoiApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringbootPoiApplication.class, args); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
SpringBoot-POI/src/main/java/com/lance/learn/springbootpoi/controller/ExcelController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.lance.learn.springbootpoi.controller; | ||
|
||
import com.lance.learn.springbootpoi.service.ExcelService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** | ||
* @Auther: Lance(ZYH) | ||
* @Date: 2018/8/27 14:01 | ||
* @Description: 处理excel文件上传\下载 | ||
*/ | ||
@RestController | ||
@RequestMapping("/excel") | ||
public class ExcelController { | ||
|
||
@Autowired | ||
private ExcelService excelService; | ||
|
||
@PostMapping("/upload") | ||
public String uploadExcel(@RequestParam MultipartFile file){ | ||
String fileName = file.getOriginalFilename(); | ||
try { | ||
excelService.uploadExcel(fileName,file); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return "success"; | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
SpringBoot-POI/src/main/java/com/lance/learn/springbootpoi/entity/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package com.lance.learn.springbootpoi.entity; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @Auther: Lance(ZYH) | ||
* @Date: 2018/8/27 13:56 | ||
* @Description: User实体类 | ||
*/ | ||
public class User implements Serializable { | ||
private Integer id; | ||
private String name; | ||
private String phone; | ||
private String address; | ||
private Date registerDate; | ||
private String desc; | ||
|
||
public User(Integer id, String name, String phone, String address, Date registerDate, String desc) { | ||
this.id = id; | ||
this.name = name; | ||
this.phone = phone; | ||
this.address = address; | ||
this.registerDate = registerDate; | ||
this.desc = desc; | ||
} | ||
|
||
public User() { | ||
super(); | ||
} | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getPhone() { | ||
return phone; | ||
} | ||
|
||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
|
||
public Date getRegisterDate() { | ||
return registerDate; | ||
} | ||
|
||
public void setRegisterDate(Date registerDate) { | ||
this.registerDate = registerDate; | ||
} | ||
|
||
public String getDesc() { | ||
return desc; | ||
} | ||
|
||
public void setDesc(String desc) { | ||
this.desc = desc; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
User user = (User) o; | ||
return Objects.equals(id, user.id) && | ||
Objects.equals(name, user.name) && | ||
Objects.equals(phone, user.phone) && | ||
Objects.equals(address, user.address) && | ||
Objects.equals(registerDate, user.registerDate) && | ||
Objects.equals(desc, user.desc); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); | ||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); | ||
result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode()); | ||
result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode()); | ||
result = prime * result + ((getRegisterDate() == null) ? 0 : getRegisterDate().hashCode()); | ||
result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
", phone='" + phone + '\'' + | ||
", address='" + address + '\'' + | ||
", registerDate=" + registerDate + | ||
", desc='" + desc + '\'' + | ||
'}'; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
SpringBoot-POI/src/main/java/com/lance/learn/springbootpoi/service/ExcelService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.lance.learn.springbootpoi.service; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** | ||
* @Auther: Lance(ZYH) | ||
* @Date: 2018/8/27 14:16 | ||
* @Description: Excel处理业务 | ||
*/ | ||
public interface ExcelService { | ||
|
||
/** | ||
* excel文件上传 | ||
* @param fileName | ||
* @param file | ||
*/ | ||
void uploadExcel(String fileName, MultipartFile file) throws Exception; | ||
|
||
} |
Oops, something went wrong.