Add rules for "
This commit is contained in:
parent
cb9107bc58
commit
aef778570e
2 changed files with 14 additions and 2 deletions
|
@ -24,7 +24,7 @@ public class AddPuzzle implements Response{
|
||||||
@Route(path = "^/admin/puzzle/$", type = POST, needLogin = true)
|
@Route(path = "^/admin/puzzle/$", type = POST, needLogin = true)
|
||||||
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
|
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
|
||||||
JsonMap json = reader.readJson();
|
JsonMap json = reader.readJson();
|
||||||
Puzzle puzzle = new Puzzle(-1, json.get("name"), json.<String>get("content").replace("206\\", "\n").replace("202\\", "\r"), json.<String>get("soluce").replace("206\\", "\n").replace("202\\", "\r").getBytes(), null, json.<Long>get("scoreMax").intValue(), null, -1, null);
|
Puzzle puzzle = new Puzzle(-1, json.get("name"), clearText(json.get("content")), clearText(json.get("soluce")).getBytes(), null, json.<Long>get("scoreMax").intValue(), null, -1, null);
|
||||||
if(repo.adminAddPuzzle(puzzle, json.<Long>get("chapter").intValue())){
|
if(repo.adminAddPuzzle(puzzle, json.<Long>get("chapter").intValue())){
|
||||||
context.response(200);
|
context.response(200);
|
||||||
}else{
|
}else{
|
||||||
|
@ -32,4 +32,10 @@ public class AddPuzzle implements Response{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String clearText(String value){
|
||||||
|
return value
|
||||||
|
.replace("206\\", "\n")
|
||||||
|
.replace("202\\", "\r")
|
||||||
|
.replace("126\\", "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class EditPuzzle implements Response{
|
||||||
@Route(path = "^/admin/puzzle/(\\d+)$", type = PUT, needLogin = true)
|
@Route(path = "^/admin/puzzle/(\\d+)$", type = PUT, needLogin = true)
|
||||||
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
|
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
|
||||||
JsonMap json = reader.readJson();
|
JsonMap json = reader.readJson();
|
||||||
Puzzle puzzle = new Puzzle(-1, json.get("name"), json.<String>get("content").replace("206\\", "\n").replace("202\\", "\r"), json.<String>get("soluce").replace("206\\", "\n").replace("202\\", "\r").getBytes(), null, json.<Long>get("scoreMax").intValue(), null, -1, null);
|
Puzzle puzzle = new Puzzle(-1, json.get("name"), clearText(json.get("content")), clearText(json.get("soluce")).getBytes(), null, json.<Long>get("scoreMax").intValue(), null, -1, null);
|
||||||
if(repo.adminUpdatePuzzle(Integer.parseInt(matcher.group(1)), puzzle, json.<Long>get("chapter").intValue())){
|
if(repo.adminUpdatePuzzle(Integer.parseInt(matcher.group(1)), puzzle, json.<Long>get("chapter").intValue())){
|
||||||
context.response(200);
|
context.response(200);
|
||||||
}else{
|
}else{
|
||||||
|
@ -32,4 +32,10 @@ public class EditPuzzle implements Response{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String clearText(String value){
|
||||||
|
return value
|
||||||
|
.replace("206\\", "\n")
|
||||||
|
.replace("202\\", "\r")
|
||||||
|
.replace("126\\", "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue