Esempio n. 1
0
 def get(self):
     nid = request.args.get("nid", "", type=int)
     # status = request.args.get("status", "1", type=int)
     page = request.args.get("page", 1, type=int)
     num = request.args.get("num", per_page, type=int)
     # extra = {"status": status}
     extra = {}
     ftp_user = request.args.get("ftp_user")
     res = BaseResponse()
     if nid:
         extra["nid"] = nid
     if ftp_user:
         extra["ftp_user"] = ftp_user
     ftps = Ftp.search(extra, page, num)
     if not ftps.items:
         page = ftps.pages
         ftps = Ftp.search(extra, page, num)
     res.pages = ftps.pages
     if ftps.has_prev:
         res.prev = page - 1
     if ftps.has_next:
         res.next = page + 1
     res.data = [ftp.to_json() for ftp in ftps.items]
     res.page = page
     res.total = ftps.pages * num
     return res.dict
Esempio n. 2
0
 def get(self):
     nid = request.args.get("nid", "", type=int)
     status = request.args.get("status", 1, type=int)
     page = request.args.get("page", 1, type=int)
     num = request.args.get("num", per_page, type=int)
     extra = {"status": status}
     site_name = request.args.get("site_name")
     bind_domain = request.args.get("bind_domain")
     res = BaseResponse()
     if nid:
         extra["nid"] = nid
     if site_name:
         extra["site_name"] = site_name
     sites = Site.search(extra, bind_domain, page, num)
     if not sites.items:
         page = sites.pages
         sites = Site.search(extra, bind_domain, page, num)
     res.pages = sites.pages
     if sites.has_prev:
         res.prev = page - 1
     if sites.has_next:
         res.next = page + 1
     site_list = []
     for site in sites.items:
         site_dict = site.to_json()
         site_info = SiteInfo.sget(site.nid)
         if site_info:
             site_dict["site_info"] = site_info.to_json()
         site_list.append(site_dict)
     res.page = page
     res.total = sites.pages * num
     res.data = site_list
     return res.dict
Esempio n. 3
0
 def get(self):
     nid = request.args.get("nid", "", type=int)
     status = request.args.get("status", 1, type=int)
     page = request.args.get("page", 1, type=int)
     num = request.args.get("num", per_page, type=int)
     extra = {"status": status}
     mysql_user = request.args.get("mysql_user")
     res = BaseResponse()
     if nid:
         extra["nid"] = nid
     if mysql_user:
         extra["ftp_user"] = mysql_user
     mysqls = Mysql.search(extra, page, num)
     if not mysqls.items:
         page = mysqls.pages
         mysqls = Mysql.search(extra, page, num)
     res.pages = mysqls.pages
     if mysqls.has_prev:
         res.prev = page - 1
     if mysqls.has_next:
         res.next = page + 1
     res.data = [mysql.to_json() for mysql in mysqls.items]
     res.page = page
     res.total = mysqls.pages * num
     return res.dict
Esempio n. 4
0
 def get(self):
     nid = request.args.get("nid", "", type=int)
     page = request.args.get("page", 1, type=int)
     num = request.args.get("num", per_page, type=int)
     extra = {}
     if nid:
         extra["nid"] = nid
     soft_name = request.args.get("soft_name")
     res = BaseResponse()
     if soft_name:
         extra["soft_name"] = soft_name
     softs = Soft.search(extra, page, num)
     if not softs.items:
         page = softs.pages
         softs = Soft.search(extra, page, num)
     res.pages = softs.pages
     if softs.has_prev:
         res.prev = page - 1
     if softs.has_next:
         res.next = page + 1
     res.page = page
     res.total = softs.pages * num
     res.data = [soft.to_json() for soft in softs.items]
     return res.dict