57 lines
1.1 KiB
TypeScript
57 lines
1.1 KiB
TypeScript
import { MsgCode } from "../role/EEnum";
|
|
import DB from "../utils/DB";
|
|
|
|
export default class FrozenIPMgr {
|
|
static shared=new FrozenIPMgr();
|
|
frozenlist:any[];
|
|
constructor(){
|
|
this.frozenlist = [];
|
|
}
|
|
|
|
launch(){
|
|
DB.getFrozenList((ret:any, rows:any)=>{
|
|
if (ret == MsgCode.SUCCESS) {
|
|
for (const row of rows) {
|
|
let fip = row.frozen_ip;
|
|
this.addFrozenIP(fip);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
addFrozenIP(fip:any, id: any = 0){
|
|
if (this.frozenlist.indexOf(fip) == -1) {
|
|
this.frozenlist.push(fip);
|
|
}
|
|
if (id != 0){
|
|
let sql = `update qy_account set state = 1 WHERE accountid = ${id}`;
|
|
DB.query(sql, (error: any, rows: any) => {
|
|
if (error) {
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
removeFrozenIP(value:string, id: any = 0){
|
|
let index=this.frozenlist.indexOf(value);
|
|
if(index != -1){
|
|
this.frozenlist.splice(index,1);
|
|
}
|
|
if (id != 0){
|
|
let sql = `update qy_account set state = 0 WHERE accountid = ${id}`;
|
|
DB.query(sql, (error: any, rows: any) => {
|
|
if (error) {
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
checkIP(ip:any):boolean{
|
|
if (this.frozenlist.indexOf(ip) == -1) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
} |