-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
12 changed files
with
241 additions
and
103 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
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
72 changes: 72 additions & 0 deletions
72
src/main/java/com/mewhz/paste/controller/ListController.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,72 @@ | ||
package com.mewhz.paste.controller; | ||
|
||
import cn.hutool.db.Entity; | ||
import com.mewhz.paste.utils.CodeSQL; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
@Controller | ||
public class ListController { | ||
|
||
@ResponseBody | ||
@RequestMapping("/list") | ||
public String list(@RequestParam String id){ | ||
String htmlBegin = "<!DOCTYPE html>\n" + | ||
"<html lang=\"en\">\n" + | ||
"<head>\n" + | ||
" <meta charset=\"UTF-8\">\n" + | ||
" <title>Title</title>\n" + | ||
" <link href=\"css/prism.css\" rel=\"stylesheet\">\n" + | ||
"</head>\n" + | ||
"<body>"; | ||
String summaryBegin = "<details>\n" + | ||
" <summary>"; | ||
String summaryEnd = "</summary>\n" + | ||
" <pre>\n" + | ||
" <code class=\"language-"; | ||
String detailsEnd = " </code>\n" + | ||
" </pre>\n" + | ||
" </details>\n"; | ||
String htmlEnd = " <script src=\"js/prism.js\"></script>\n" + | ||
" <script src=\"js/prism-c.min.js\"></script>\n" + | ||
" <script src=\"js/prism-cpp.min.js\"></script>\n" + | ||
" <script src=\"js/prism-java.min.js\"></script>\n" + | ||
"</body>\n" + | ||
"</html>"; | ||
StringBuilder html = new StringBuilder(htmlBegin); | ||
|
||
CodeSQL codeSQL = new CodeSQL(); | ||
|
||
List<Entity> list = codeSQL.findIdentifyingCode(id); | ||
|
||
for (Entity e : list){ | ||
html.append(summaryBegin); | ||
html.append(e.get("date")); | ||
html.append(" "); | ||
html.append(e.get("time_id")); | ||
html.append(summaryEnd); | ||
html.append(e.get("type")); | ||
html.append("\">"); | ||
|
||
String text = (String) e.get("text"); | ||
|
||
text = text.replaceAll("<", "<"); | ||
text = text.replaceAll(">", ">"); | ||
text = text.replaceAll("\n", "<br>"); | ||
text = text.replaceAll(" ", " "); | ||
|
||
html.append(text); | ||
html.append(detailsEnd); | ||
} | ||
html.append(htmlEnd); | ||
|
||
return html.toString(); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,62 @@ | ||
package com.mewhz.paste.model; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
public class IdentifyingCode { | ||
private int icId; | ||
private String identifying; | ||
private String timeId; | ||
|
||
public IdentifyingCode(){ | ||
|
||
} | ||
|
||
public IdentifyingCode(String identifying){ | ||
this.identifying = identifying; | ||
} | ||
|
||
public IdentifyingCode(String identifying, String timeId) { | ||
this.identifying = identifying; | ||
this.timeId = timeId; | ||
} | ||
|
||
public IdentifyingCode(int icId, String identifying, String timeId) { | ||
this.icId = icId; | ||
this.identifying = identifying; | ||
this.timeId = timeId; | ||
} | ||
|
||
public int getIcId() { | ||
return icId; | ||
} | ||
|
||
public void setIcId(int icId) { | ||
this.icId = icId; | ||
} | ||
|
||
public String getIdentifying() { | ||
return identifying; | ||
} | ||
|
||
public void setIdentifying(String identifying) { | ||
this.identifying = identifying; | ||
} | ||
|
||
public String getTimeId() { | ||
return timeId; | ||
} | ||
|
||
public void setTimeId(String timeId) { | ||
this.timeId = timeId; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "IdentifyingCode{" + | ||
"icId=" + icId + | ||
", identifying='" + identifying + '\'' + | ||
", timeId='" + timeId + '\'' + | ||
'}'; | ||
} | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.