获取项目列表 @author baozi <202-02-22> @param: get ( dict ): 请求信息 @return msg : _description_
(self, get)
| 1616 | |
| 1617 | |
| 1618 | def GetProjectList(self, get): |
| 1619 | """获取项目列表 |
| 1620 | @author baozi <202-02-22> |
| 1621 | @param: |
| 1622 | get ( dict ): 请求信息 |
| 1623 | @return msg : _description_ |
| 1624 | """ |
| 1625 | if not self.need_update_project("mod"): |
| 1626 | self.update_all_project() |
| 1627 | if not 'p' in get: get.p = 1 |
| 1628 | if not 'limit' in get: get.limit = 20 |
| 1629 | if not 'callback' in get: get.callback = '' |
| 1630 | if not 'order' in get: get.order = 'id desc' |
| 1631 | type_id = None |
| 1632 | if "type_id" in get: |
| 1633 | try: |
| 1634 | type_id = int(get.type_id) |
| 1635 | except: |
| 1636 | type_id = None |
| 1637 | |
| 1638 | if 'search' in get: |
| 1639 | get.project_name = get.search.strip() |
| 1640 | search = "%{}%".format(get.project_name) |
| 1641 | if type_id is None: |
| 1642 | count = public.M('sites').where('project_type=? AND (name LIKE ? OR ps LIKE ?)', ('Python', search, search)).count() |
| 1643 | data = public.get_page(count, int(get.p), int(get.limit), get.callback) |
| 1644 | data['data'] = public.M('sites').where('project_type=? AND (name LIKE ? OR ps LIKE ?)', ('Python', search, search)).limit(data['shift'] + ',' + data['row']).order(get.order).select() |
| 1645 | else: |
| 1646 | count = public.M('sites').where('project_type=? AND (name LIKE ? OR ps LIKE ?) AND type_id = ?', |
| 1647 | ('Python', search, search, type_id)).count() |
| 1648 | data = public.get_page(count, int(get.p), int(get.limit), get.callback) |
| 1649 | data['data'] = public.M('sites').where('project_type=? AND (name LIKE ? OR ps LIKE ?) AND type_id = ?', ('Python', search, search, type_id)).limit(data['shift'] + ',' + data['row']).order(get.order).select() |
| 1650 | else: |
| 1651 | if type_id is None: |
| 1652 | count = public.M('sites').where('project_type=?', 'Python').count() |
| 1653 | data = public.get_page(count, int(get.p), int(get.limit), get.callback) |
| 1654 | data['data'] = public.M('sites').where('project_type=?', 'Python').limit(data['shift'] + ',' + data['row']).order(get.order).select() |
| 1655 | else: |
| 1656 | count = public.M('sites').where('project_type=? AND type_id = ?', ('Python', type_id)).count() |
| 1657 | data = public.get_page(count, int(get.p), int(get.limit), get.callback) |
| 1658 | data['data'] = public.M('sites').where('project_type=? AND type_id = ?', ('Python', type_id)).limit(data['shift'] + ',' + data['row']).order(get.order).select() |
| 1659 | |
| 1660 | if isinstance(data["data"], str) and data["data"].startswith("error"): |
| 1661 | raise public.PanelError("数据库查询错误:" + data["data"]) |
| 1662 | |
| 1663 | for i in range(len(data['data'])): |
| 1664 | data['data'][i]["ssl"] = self.get_ssl_end_date(data['data'][i]["name"]) |
| 1665 | self._get_project_state(data['data'][i]) |
| 1666 | return data |
| 1667 | |
| 1668 | def _get_project_state(self, project_info): |
| 1669 | """获取项目详情信息 |
nothing calls this directly
no test coverage detected