You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
package com.rehome.getremoteipjpa.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.rehome.getremoteipjpa.dao.CmIpRepository;
|
|
|
|
|
|
import com.rehome.getremoteipjpa.entity.CmIp;
|
|
|
|
|
|
import com.rehome.getremoteipjpa.service.CmIpService;
|
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取本地公网IP,然后保存到服务器
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class CmIpServiceImpl implements CmIpService {
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
private CmIpRepository cmIpRepository;
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void saveCmIp(CmIp cmIp) {
|
|
|
|
|
|
cmIpRepository.save(cmIp);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public CmIp getIpAddressById(Long id) {
|
|
|
|
|
|
Optional<CmIp> cmIp = cmIpRepository.findById(id);
|
|
|
|
|
|
if(cmIp.isPresent()){
|
|
|
|
|
|
return cmIp.get();
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|