package com.hai.service.impl; import com.hai.dao.ApiIpAddressMapper; import com.hai.entity.ApiIpAddress; import com.hai.entity.ApiIpAddressExample; import com.hai.service.ApiIpAddressService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.Map; @Service("apiIpAddressService") public class ApiIpAddressServiceImpl implements ApiIpAddressService { @Resource private ApiIpAddressMapper apiIpAddressMapper; @Override public void insertApiIpAddress(ApiIpAddress apiIpAddress) { apiIpAddressMapper.insert(apiIpAddress); } @Override public void updateApiIpAddress(ApiIpAddress apiIpAddress) { apiIpAddressMapper.updateByPrimaryKey(apiIpAddress); } @Override public ApiIpAddress findById(Long id) { return apiIpAddressMapper.selectByPrimaryKey(id); } @Override public ApiIpAddress findByMchId(String mchId) { ApiIpAddressExample example = new ApiIpAddressExample(); ApiIpAddressExample.Criteria criteria = example.createCriteria(); criteria.andMchIdEqualTo(mchId); List list = apiIpAddressMapper.selectByExample(example); if (list.size() > 0) { return list.get(0); } return null; } @Override public List getApiIpAddressByList(Map map) { return null; } @Override public Boolean validationIpAddressLegal(String mchId, String ipAddress) { ApiIpAddressExample example = new ApiIpAddressExample(); example.createCriteria().andMchIdEqualTo(mchId).andIpAddressLike("%" + ipAddress + "%"); List list = apiIpAddressMapper.selectByExample(example); return list.size()>0; } }