package com.chenyang.nse.bussiness.jar.db;

import com.chenyang.nse.bussiness.dao.BaseDao;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class TCoreClientIpControlledDao extends BaseDao<TCoreClientIpControlled, String> {
   public List<String> getIpRange(String projectid) {
      List<String> result = new ArrayList();

      try {
         StringBuilder sql = new StringBuilder();
         sql.append("select content from t_core_client_ip_controlled where project_id = '" + projectid + "'");
         result = this.getSession().createNativeQuery(sql.toString()).getResultList();
      } catch (Exception e) {
         e.printStackTrace();
      }

      return result;
   }

   public List<TCoreClientIpControlled> list(String projectId) {
      new ArrayList();

      try {
         StringBuilder sql = new StringBuilder();
         sql.append("select * from t_core_client_ip_controlled where project_id = '" + projectId + "' and is_delete = 0");
         List<TCoreClientIpControlled> result = this.getSession().createNativeQuery(sql.toString(), TCoreClientIpControlled.class).getResultList();
         return result;
      } catch (Exception e) {
         e.printStackTrace();
         return new ArrayList();
      }
   }

   public static void main(String[] args) {
      String ipStart = "192.168.2.2";
      String clientHost = "192.168.2.3";
      String ipEnd = "192.168.2.4";
      System.out.println(clientHost.compareTo(ipStart) >= 0 && clientHost.compareTo(ipEnd) <= 0);
   }
}
