@name 为指定项目删除域名 @author hwliang<2021-08-09> @param get { project_name: string<项目名称> domain: string<域名> } @return dict
(self, get)
| 2317 | return project_info |
| 2318 | |
| 2319 | def project_remove_domain(self, get): |
| 2320 | ''' |
| 2321 | @name 为指定项目删除域名 |
| 2322 | @author hwliang<2021-08-09> |
| 2323 | @param get<dict_obj>{ |
| 2324 | project_name: string<项目名称> |
| 2325 | domain: string<域名> |
| 2326 | } |
| 2327 | @return dict |
| 2328 | ''' |
| 2329 | project_find = self.get_project_find(get.project_name) |
| 2330 | if not project_find: |
| 2331 | return public.returnMsg(False, '指定项目不存在') |
| 2332 | last_domain = get.domain |
| 2333 | domain_arr = get.domain.split(':') |
| 2334 | if len(domain_arr) == 1: |
| 2335 | domain_arr.append(80) |
| 2336 | if domain_arr[0] == get.project_name: return public.returnMsg(False, '不能删除当前项目域名') |
| 2337 | project_id = public.M('sites').where('name=?', (get.project_name,)).getField('id') |
| 2338 | if len(public.M('domain').where('pid=?', (project_find['id'],)).select()) == 1: |
| 2339 | return public.returnMsg(False, '项目至少需要一个域名') |
| 2340 | domain_id = public.M('domain').where('name=? AND pid=?', (domain_arr[0], project_id)).getField('id') |
| 2341 | if not domain_id: |
| 2342 | return public.returnMsg(False, '指定域名不存在') |
| 2343 | public.M('domain').where('id=?', (domain_id,)).delete() |
| 2344 | if get.domain in project_find['project_config']['domains']: |
| 2345 | project_find['project_config']['domains'].remove(get.domain) |
| 2346 | if get.domain + ":80" in project_find['project_config']['domains']: |
| 2347 | project_find['project_config']['domains'].remove(get.domain + ":80") |
| 2348 | public.M('sites').where('id=?', (project_id,)).save( |
| 2349 | 'project_config', json.dumps(project_find['project_config']) |
| 2350 | ) |
| 2351 | public.WriteLog(self._log_name, '从项目:{},删除域名{}'.format(get.project_name, get.domain)) |
| 2352 | self.set_config(get.project_name) |
| 2353 | self.del_hosts(domain_arr[0]) |
| 2354 | return public.returnMsg(True, '删除域名成功') |
| 2355 | |
| 2356 | def project_get_domain(self, get): |
| 2357 | ''' |
nothing calls this directly
no test coverage detected