在登錄的時候 , 對安全性比較高的業務 , 需要進行限制指定IP或IP段才能登錄 , 企郵企業有的就限制只能在本企業內登錄
這個時候設計一下資料庫 , 實作這個功能可以這樣
表結構:
CREATE TABLE `iplimit_list` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ent_id` int(10) unsigned NOT NULL DEFAULT '0', `start` int(10) unsigned NOT NULL DEFAULT '0', `end` int(10) unsigned NOT NULL DEFAULT '0', `time` int(10) unsigned NOT NULL DEFAULT '0', `type` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `idx_user` (`ent_id`,`start`,`end`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
start是ip段的開始
end是ip段的結束
都是int數值型的 , 把ip進行轉換成long型別
查詢的時候可以這樣查
select * from iplimit_list where ent_id=23684 and 182322741>=start and 182322741<=end
182322741這個就是當前ip , 大于等于start的ip段 , 小于等于end的ip段
實作的效果

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/236501.html
標籤:其他
