TASK:凭证更新;
This commit is contained in:
@@ -107,4 +107,11 @@ public class ThirdPartyController {
|
|||||||
public Response<String> getRedirectUrl() {
|
public Response<String> getRedirectUrl() {
|
||||||
return Response.success(REDIRECT_URL);
|
return Response.success(REDIRECT_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@ApiOperation(value = "add No Login Required")
|
||||||
|
@PostMapping("/updateNoLoginRequiredNew")
|
||||||
|
public Response<String> updateNoLoginRequiredNew(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) {
|
||||||
|
return Response.success(accountService.updateNoLoginRequiredNew(noLoginRequiredDTO, request));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,4 +157,6 @@ public interface AccountService extends IService<Account> {
|
|||||||
|
|
||||||
IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size);
|
IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size);
|
||||||
List<Account> getByIds(List<Long> ids);
|
List<Account> getByIds(List<Long> ids);
|
||||||
|
|
||||||
|
String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -875,6 +875,57 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
" </html>";
|
" </html>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) {
|
||||||
|
// 验证机房注册序列号(001-100)
|
||||||
|
String id = noLoginRequiredDTO.getId();
|
||||||
|
if (!isStringInRange(id)) {
|
||||||
|
throw new BusinessException("Illegal serial number.");
|
||||||
|
}
|
||||||
|
// 获取真实 IP 地址,考虑了经过代理的情况
|
||||||
|
String ipAddress = request.getHeader("X-Forwarded-For");
|
||||||
|
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getRemoteAddr();
|
||||||
|
}
|
||||||
|
String browserIdentifiers = ipAddress + "," + id;
|
||||||
|
// 构建查询条件,查找已注册的账户数量
|
||||||
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.lambda().eq(Account::getUserName, "PolyU-SFT-" + id);
|
||||||
|
// queryWrapper.lambda().eq(Account::getBrowserIdentifiers, browserIdentifiers);
|
||||||
|
List<Account> existingAccounts = accountMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
|
// 检查序列号是否被注册
|
||||||
|
if (!CollectionUtil.isNotEmpty(existingAccounts)) {
|
||||||
|
throw new BusinessException("Updated serial number not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Account account = existingAccounts.get(0);
|
||||||
|
account.setBrowserIdentifiers(browserIdentifiers);
|
||||||
|
accountMapper.updateById(account);
|
||||||
|
|
||||||
|
return "<!DOCTYPE html>\n" +
|
||||||
|
" <html lang=\"en\">\n" +
|
||||||
|
" <head>\n" +
|
||||||
|
" <meta charset=\"UTF-8\">\n" +
|
||||||
|
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
|
||||||
|
" <title>Document</title>\n" +
|
||||||
|
" <link rel=\"icon\" href=\"https://polyu.aida.com.hk/favicon.ico\">\n" +
|
||||||
|
" </head>\n" +
|
||||||
|
" <body>\n" +
|
||||||
|
" </body>\n" +
|
||||||
|
" <script>\n" +
|
||||||
|
" window.location.href = 'https://polyu.aida.com.hk?" + id + "';\n" +
|
||||||
|
" </script>\n" +
|
||||||
|
" </html>";
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isStringInRange(String input) {
|
public static boolean isStringInRange(String input) {
|
||||||
// 去除字符串两端的空格
|
// 去除字符串两端的空格
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user