Skip to content

Commit 6298583

Browse files
committed
实用小工具
0 parents  commit 6298583

File tree

127 files changed

+45487
-0
lines changed

Some content is hidden

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

127 files changed

+45487
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.iml
2+
.idea
3+
target

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 小工具汇总
2+
3+
这个项目主要存储了一些小工具,包括词库的获取,双拼的解析,使用拼音做搜索等功能
4+
5+
拼音操作使用了`pinyin4j`工具
6+
7+
目录结构:
8+
9+
| 项目名称 | 描述 |
10+
| ----------------------- | --------------------------------------------------------- |
11+
| `baidu-index` | 百度指数 |
12+
| `doc2html-plugin` | `doc``html` (伪转换) |
13+
| `java-ini` | http://javaini.sourceforge.net/ |
14+
| `sougou-scel-operation` | 搜狗细胞词库的下载和解析工作 |
15+
| `udpn-operation` | 双拼的操作工具 |
16+
| 双拼操作的准备工作 | 生成双拼所用的`ini`文件,格式类似于百度拼音输入法双拼方案 |
17+
| 更多功能…… | 尚在更新中…… |
18+

baidu-index/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.iml
2+
.idea
3+
target

baidu-index/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 百度指数API
2+
新版百度指数获取API,Demo版
3+
> 此项目为临时项目,如果需要在此Demo上可以做二次开发

baidu-index/pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.cy</groupId>
8+
<artifactId>baidu-index</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<!-- Inherit defaults from Spring Boot -->
12+
<parent>
13+
<groupId>org.springframework.boot</groupId>
14+
<artifactId>spring-boot-starter-parent</artifactId>
15+
<version>2.1.5.RELEASE</version>
16+
</parent>
17+
18+
<properties>
19+
<java.version>1.8</java.version>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-web</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.alibaba</groupId>
29+
<artifactId>fastjson</artifactId>
30+
<version>1.2.57</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.alibaba</groupId>
34+
<artifactId>easyexcel</artifactId>
35+
<version>1.1.2-beat1</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.projectlombok</groupId>
39+
<artifactId>lombok</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-starter-freemarker</artifactId>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<finalName>baidu-index</finalName>
49+
<plugins>
50+
<plugin>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-maven-plugin</artifactId>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
57+
58+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.cy.index;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* 百度指数查询的主方法
8+
*/
9+
@SpringBootApplication
10+
public class Application {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(Application.class, args);
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.cy.index;
2+
3+
import org.springframework.boot.CommandLineRunner;
4+
import org.springframework.stereotype.Component;
5+
6+
@Component
7+
public class OnApplicationStart implements CommandLineRunner {
8+
@Override
9+
public void run(String... args) throws Exception {
10+
Runtime.getRuntime().exec("cmd /c start http://localhost:9001");
11+
}
12+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.cy.index.controller;
2+
3+
import com.cy.index.data.AppData;
4+
import com.cy.index.service.BaiduIndex2ExcelService;
5+
import com.cy.index.util.DateUtil;
6+
import org.springframework.stereotype.Controller;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
9+
import javax.annotation.Resource;
10+
import javax.servlet.ServletOutputStream;
11+
import javax.servlet.http.HttpServletResponse;
12+
import java.io.IOException;
13+
import java.nio.charset.StandardCharsets;
14+
import java.util.Date;
15+
16+
/**
17+
* 指数控制器
18+
*/
19+
@Controller
20+
public class IndexController {
21+
22+
@Resource
23+
private BaiduIndex2ExcelService baiduIndex2ExcelService;
24+
25+
@GetMapping("downloadExcel")
26+
public void downloadExcel(String word, Date startDate, Date endDate, HttpServletResponse response) throws IOException {
27+
response.setContentType("multipart/form-data");
28+
response.setCharacterEncoding("utf-8");
29+
String fileName = new String(("百度指数-" + word + "-" + DateUtil.getDateString(startDate) + "-" + DateUtil.getDateString(endDate))
30+
.getBytes(), StandardCharsets.ISO_8859_1);
31+
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
32+
ServletOutputStream out = response.getOutputStream();
33+
baiduIndex2ExcelService.downloadIndexExcel(word, startDate, endDate, out);
34+
}
35+
36+
@GetMapping("bduss")
37+
public String bduss(String bduss) {
38+
AppData.bduss = bduss;
39+
return "downloadIndex";
40+
}
41+
42+
@GetMapping("/index.html")
43+
public String toIndex() {
44+
return "index";
45+
}
46+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.cy.index.controller.convert;
2+
3+
import org.springframework.core.convert.converter.Converter;
4+
import org.springframework.stereotype.Component;
5+
6+
import java.text.ParseException;
7+
import java.text.SimpleDateFormat;
8+
import java.util.Date;
9+
10+
@Component
11+
public class DateConvert implements Converter<String, Date> {
12+
13+
@Override
14+
public Date convert(String s) {
15+
try {
16+
return new SimpleDateFormat("yyyy-MM-dd").parse(s);
17+
} catch (ParseException e) {
18+
e.printStackTrace();
19+
}
20+
return null;
21+
}
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.cy.index.data;
2+
3+
public class AppData {
4+
public static String bduss;
5+
}

0 commit comments

Comments
 (0)