Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Smith-Cruise committed Mar 1, 2018
1 parent 4c90149 commit 6930989
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public class CacheController {

private static Cache<Integer, Object> leaderboardCache;

private static Cache<String, String> captchaCache;

static {
CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(true);
authCache = cacheManager
Expand All @@ -43,8 +41,9 @@ public class CacheController {
CacheConfigurationBuilder.newCacheConfigurationBuilder(
String.class,
JudgeResult.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, MemoryUnit.MB))
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(100, MemoryUnit.MB))
.withExpiry(Expirations.timeToLiveExpiration(Duration.of(1, TimeUnit.HOURS)))
.withSizeOfMaxObjectGraph(5000)
.build());
leaderboardCache = cacheManager
.createCache("leaderboardCache",
Expand All @@ -54,16 +53,6 @@ public class CacheController {
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(20, MemoryUnit.MB))
.withExpiry(Expirations.timeToLiveExpiration(Duration.of(DefaultConfig.LEADERBOARD_REFRESH_TIME, TimeUnit.MINUTES)))
.build());

captchaCache = cacheManager
.createCache("captchaCache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(
String.class,
String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(5, MemoryUnit.MB))
.withExpiry(Expirations.timeToLiveExpiration(Duration.of(DefaultConfig.CAPTCHA_EXPIRED_TIME, TimeUnit.MINUTES)))
.build()
);
}

public static Cache<String, String> getAuthCache() {
Expand All @@ -76,7 +65,4 @@ public static Cache<Integer, Object> getLeaderboard() {
return leaderboardCache;
}

public static Cache<String, String> getCaptchaCache() {
return captchaCache;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public ResponseEntity getAuditingProblems(@RequestParam("page") int page,
}

@ApiOperation("导出题目")
@RequiresRoles("9")
@RequiresRoles(value = {"8", "9"}, logical = Logical.OR)
@PostMapping("/export")
public ResponseEntity exportProblems(@RequestBody @Valid ImportProblemsFormat format) {
JSONArray pidList = format.getPidList();
Expand All @@ -128,7 +128,7 @@ public ResponseEntity exportProblems(@RequestBody @Valid ImportProblemsFormat fo
}

@ApiOperation("导入题目")
@RequiresRoles("9")
@RequiresRoles(value = {"8", "9"}, logical = Logical.OR)
@PostMapping("/import")
public ResponseEntity importProblems(@RequestParam("file") MultipartFile uploadFile) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@ public boolean importProblems(int uid, JSONArray list) {
JSONArray samples = obj.getJSONArray("samples");
int time = obj.getInteger("time");
int memory = obj.getInteger("memory");
save(tagsList, uid, title, description, inputFormat, outputFormat, difficult, samples, time, memory, ProblemStatus.SHARING);
int pid = save(tagsList, uid, title, description, inputFormat, outputFormat, difficult, samples, time, memory, ProblemStatus.SHARING);
// save test cases
JSONArray testCases = obj.getJSONArray("test_cases");
for (int j=0; j<testCases.size(); j++) {
JSONObject testCase = testCases.getJSONObject(j);
testCasesService.save(pid, testCase.getString("stdin"), testCase.getString("stdout"),
testCase.getInteger("strength"));
}
}
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions eagle-oj-web/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
spring.profiles.active=dev
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.http.multipart.max-file-size=10
spring.http.encoding.force=true

mybatis.config-location=classpath:mybatis-config.xml
mybatis.mapper-locations=classpath:mapping/*.xml

0 comments on commit 6930989

Please sign in to comment.