parameters: (self,get)
return_statement: return public.return_data(True,"[{}] domain names added successfully, [{}] failed!".format(len(success_list),len(error_list)),error_msg=error_list)
docstring: @name 为指定项目添加域名
              @author hwliang<2021-08-09>
              @param get<dict_obj>{
                  project_name: string<项目名称>
                  domains: list<域名列表>
              }
              @return dict
function: def project_add_domain(self,get):
          '''
              @name 为指定项目添加域名
              @author hwliang<2021-08-09>
              @param get<dict_obj>{
                  project_name: string<项目名称>
                  domains: list<域名列表>
              }
              @return dict
          '''
          project_find = self.get_project_find(get.project_name)
          if not project_find: 
              return public.return_error('The specified item does not exist')
          project_id = project_find['id']
          
          domains = get.domains
          success_list = []
          error_list = []
          for domain in domains:
              domain = domain.strip()
              domain_arr = domain.split(':')
              if len(domain_arr) == 1: 
                  domain_arr.append(80)
                  domain += ':80'
              if not public.M('domain').where('name=?',(domain_arr[0],)).count():
                  public.M('domain').add('name,pid,port,addtime',(domain_arr[0],project_id,domain_arr[1],public.getDate()))
                  if not domain in project_find['project_config']['domains']:
                      project_find['project_config']['domains'].append(domain)
                  public.WriteLog(self._log_name,'Successfully added the domain [{}] to the project [{}]'.format(domain,get.project_name))
                  success_list.append(domain)
              else:
                  public.WriteLog(self._log_name,'Domain [{}] already exists'.format(domain))
                  error_list.append(domain)
  
          if success_list:
              public.M('sites').where('id=?',(project_id,)).save('project_config',json.dumps(project_find['project_config']))
              self.set_config(get.project_name)
  
          return public.return_data(True,"[{}] domain names added successfully, [{}] failed!".format(len(success_list),len(error_list)),error_msg=error_list)
function_tokens: def project_add_domain ( self , get ) : project_find = self . get_project_find ( get . project_name ) if not project_find : return public . return_error ( 'The specified item does not exist' ) project_id = project_find [ 'id' ] domains = get . domains success_list = [ ] error_list = [ ] for domain in domains : domain = domain . strip ( ) domain_arr = domain . split ( ':' ) if len ( domain_arr ) == 1 : domain_arr . append ( 80 ) domain += ':80' if not public . M ( 'domain' ) . where ( 'name=?' , ( domain_arr [ 0 ] , ) ) . count ( ) : public . M ( 'domain' ) . add ( 'name,pid,port,addtime' , ( domain_arr [ 0 ] , project_id , domain_arr [ 1 ] , public . getDate ( ) ) ) if not domain in project_find [ 'project_config' ] [ 'domains' ] : project_find [ 'project_config' ] [ 'domains' ] . append ( domain ) public . WriteLog ( self . _log_name , 'Successfully added the domain [{}] to the project [{}]' . format ( domain , get . project_name ) ) success_list . append ( domain ) else : public . WriteLog ( self . _log_name , 'Domain [{}] already exists' . format ( domain ) ) error_list . append ( domain ) if success_list : public . M ( 'sites' ) . where ( 'id=?' , ( project_id , ) ) . save ( 'project_config' , json . dumps ( project_find [ 'project_config' ] ) ) self . set_config ( get . project_name ) return public . return_data ( True , "[{}] domain names added successfully, [{}] failed!" . format ( len ( success_list ) , len ( error_list ) ) , error_msg = error_list )