添加方法级 Caller 锁
This commit is contained in:
@@ -8,11 +8,16 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import quant.rich.emoney.controller.common.BaseController;
|
||||
import quant.rich.emoney.entity.config.PlatformConfig;
|
||||
import quant.rich.emoney.exception.RException;
|
||||
import quant.rich.emoney.pojo.dto.R;
|
||||
import quant.rich.emoney.service.AuthService;
|
||||
import quant.rich.emoney.service.ConfigService;
|
||||
import quant.rich.emoney.util.EncryptUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/v1")
|
||||
@@ -23,29 +28,57 @@ public class IndexControllerV1 extends BaseController {
|
||||
|
||||
@Autowired
|
||||
ConfigService configService;
|
||||
|
||||
@Autowired
|
||||
AuthService authService;
|
||||
|
||||
@GetMapping({ "", "/", "/index" })
|
||||
public String index() {
|
||||
return "admin/v1/index";
|
||||
}
|
||||
|
||||
@GetMapping("/getUserInfo")
|
||||
@ResponseBody
|
||||
public R<?> getUserInfo() {
|
||||
ObjectNode node = new ObjectMapper().valueToTree(platformConfig);
|
||||
node.remove("password");
|
||||
node.remove("isInited");
|
||||
return R.ok(node);
|
||||
}
|
||||
|
||||
@PostMapping("/changeUserInfo")
|
||||
@ResponseBody
|
||||
public R<?> changeUserInfo(String newUsername, String oldPassword, String newPassword) {
|
||||
if (!platformConfig.getPassword().equals(oldPassword)) {
|
||||
throw RException.badRequest("密码错误");
|
||||
}
|
||||
if (StringUtils.isAllEmpty(newUsername, newPassword)) {
|
||||
throw RException.badRequest("未更改任何信息");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(newUsername)) {
|
||||
platformConfig.setUsername(newUsername);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(newPassword)) {
|
||||
public R<?> changeUserInfo(
|
||||
String username,
|
||||
String password,
|
||||
String newPassword,
|
||||
String email) {
|
||||
|
||||
if (passwordIsNotEmpty(newPassword)) {
|
||||
if (!platformConfig.getPassword().equals(password)) {
|
||||
throw RException.badRequest("密码错误");
|
||||
}
|
||||
platformConfig.setPassword(newPassword);
|
||||
}
|
||||
configService.saveOrUpdate(platformConfig);
|
||||
return R.ok();
|
||||
if (StringUtils.isNotEmpty(username)) {
|
||||
platformConfig.setUsername(username);
|
||||
}
|
||||
else {
|
||||
throw RException.badRequest("用户名不能为空");
|
||||
}
|
||||
platformConfig.setEmail(email);
|
||||
return R.judge(() -> {
|
||||
if (configService.saveOrUpdate(platformConfig)) {
|
||||
authService.setLogin(username, platformConfig.getPassword());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
static final String EMPTY_PASSWORD = EncryptUtils.sha3("", 224);
|
||||
|
||||
static boolean passwordIsNotEmpty(String password) {
|
||||
return StringUtils.isNotEmpty(password) && !password.equalsIgnoreCase(EMPTY_PASSWORD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package quant.rich.emoney.controller.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import quant.rich.emoney.controller.common.BaseController;
|
||||
import quant.rich.emoney.entity.config.ProxyConfig;
|
||||
import quant.rich.emoney.pojo.dto.R;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/admin/v1/config/proxy")
|
||||
public class ProxyConfigControllerV1 extends BaseController {
|
||||
|
||||
@Autowired
|
||||
ProxyConfig proxyConfig;
|
||||
|
||||
|
||||
@GetMapping("/refreshIpThroughProxy")
|
||||
@ResponseBody
|
||||
public R<?> refreshIpThroughProxy() {
|
||||
return R.ok(proxyConfig.refreshIpThroughProxy());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user