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.

32 lines
805 B
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
}