(self, get, result='1,2,3,4,5,8')
| 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) |
no test coverage detected