MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / GetSql

Method GetSql

class/projectModel/proxyModel.py:2011–2129  ·  view source on GitHub ↗
(self, get, result='1,2,3,4,5,8')

Source from the content-addressed store, hash-verified

2009 return data
2010
2011 def GetSql(self, get, result='1,2,3,4,5,8'):
2012 try:
2013 # 判断前端是否传入参数
2014 order = 'id desc'
2015 if hasattr(get, 'order'):
2016 # 验证参数格式
2017 if re.match(r"^[\w\s\-\.]+$", get.order):
2018 order = get.order
2019
2020 search_key = 'get_list'
2021 limit = 20
2022 if hasattr(get, 'limit'):
2023 limit = int(get.limit)
2024 if limit < 1: limit = 20
2025
2026 if hasattr(get, 'result'):
2027 # 验证参数格式
2028 if re.match(r"^[\d\,]+$", get.result):
2029 result = get.result
2030 import db
2031 SQL = db.Sql()
2032 data = {}
2033 # 取查询条件
2034 where = ''
2035 search = ''
2036 param = ()
2037 if hasattr(get, 'search'):
2038 search = get.search
2039 if sys.version_info[0] == 2: get.search = get.search.encode('utf-8')
2040 where, param = self.GetWhere(get.table, get.search)
2041 if get.table == 'sites' and get.search:
2042 conditions = ''
2043 if '_' in get.search:
2044 cs = ''
2045 for i in get.search:
2046 if i == '_':
2047 cs += '/_'
2048 else:
2049 cs += i
2050 get.search = cs
2051 conditions = " escape '/'"
2052 pid = SQL.table('domain').where("name LIKE ?{}".format(conditions),
2053 ("%{}%".format(get.search),)).getField('pid')
2054 if pid:
2055 if where:
2056 where += " or id=" + str(pid)
2057 else:
2058 where += "id=" + str(pid)
2059 if get.table == 'sites':
2060 search_key = 'proxy'
2061 if where:
2062 where = "({}) AND project_type='proxy'".format(where)
2063 else:
2064 where = "project_type='proxy'"
2065
2066 if hasattr(get, 'type'):
2067 try:
2068 type_id = int(get.type)

Callers 1

GetSiteListMethod · 0.95

Calls 15

GetWhereMethod · 0.95
tableMethod · 0.95
GetFieldMethod · 0.95
GetPageMethod · 0.95
matchMethod · 0.45
getFieldMethod · 0.45
whereMethod · 0.45
formatMethod · 0.45
selectMethod · 0.45
fieldMethod · 0.45
orderMethod · 0.45
MMethod · 0.45

Tested by

no test coverage detected