Commit 9d3a5426 authored by xuxin's avatar xuxin

提供前端查询ip

parent 7e11662a
......@@ -3,10 +3,7 @@ package com.edgec.browserbackend.browser.controller;
import com.edgec.browserbackend.browser.domain.UserCode;
import com.edgec.browserbackend.browser.service.TempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 一些临时执行的代码可以放在这里,方便删除
......@@ -26,4 +23,9 @@ public class TempController {
tempService.save(userCode);
}
@GetMapping("/{ip}")
public String getPaasword(@PathVariable("ip") String ip) {
return tempService.getPaasword(ip);
}
}
......@@ -67,4 +67,6 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
long countAllByOwnerInAndIsDeletedAndValidTimeGreaterThan(List<String> username, boolean isDeleted, long time);
long countAllByOwner(String username);
IpResource findFirstByAddrOrderByPurchasedTimeDesc(String addr);
}
......@@ -41,4 +41,16 @@ public class TempServiceImpl implements TempService {
ipResourceRepository.save(ipResource);
log.info("ip地址为:" + addr + "专线状态更改为:" + flag);
}
@Override
public String getPaasword(String ip) {
IpResource ipResource = ipResourceRepository.findFirstByAddrOrderByPurchasedTimeDesc(ip);
String password;
if ("mainland".equals(ipResource.getRegion())) {
password = ipResource.getPassword();
} else {
password = ipResource.getProxyPassword();
}
return password;
}
}
......@@ -9,4 +9,6 @@ public interface TempService {
void save(UserCode userCode);
void saveIpResource(String addr, String flag);
String getPaasword(String ip);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment