Create getEnvironments api.

pull/146/head
ruibaby 2019-05-03 23:56:31 +08:00
parent ff7ecc9d09
commit 41793365e2
2 changed files with 14 additions and 1 deletions

View File

@ -10,6 +10,10 @@ import run.halo.app.security.token.AuthToken;
import run.halo.app.service.AdminService;
import javax.validation.Valid;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.HashMap;
import java.util.Map;
/**
* Admin controller.
@ -39,6 +43,15 @@ public class AdminController {
return adminService.getCount();
}
@GetMapping("environments")
@ApiOperation("Gets environments info")
public Map<String, Object> getEnvironments() {
Map<String, Object> result = new HashMap<>();
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
result.put("startTime", runtimeMXBean.getStartTime());
return result;
}
@PostMapping("login")
@ApiOperation("Login")
@CacheLock(autoDelete = false)

View File

@ -85,7 +85,7 @@ public class AdminServiceImpl implements AdminService {
if (!userService.passwordMatch(user, loginParam.getPassword())) {
// If the password is mismatch
throw new BadRequestException("Username or password is incorrect");
throw new BadRequestException("用户名或者密码不正确");
}
if (SecurityContextHolder.getContext().isAuthenticated()) {