You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: host.go
    path of file: ./repos/bk-cmdb/src/scene_server/host_server/service
    
    the code of the file until where you have to start completion: /*
 * Tencent is pleased to support the open source community by making 蓝鲸 available.
 * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
 * Licensed under the MIT License (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * http://opensource.org/licenses/MIT
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions and
 * limitations under the License.
 */

package service

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"strconv"
	"strings"
	"sync"

	"configcenter/src/ac"
	"configcenter/src/ac/extensions"
	authmeta "configcenter/src/ac/meta"
	"configcenter/src/common"
	"configcenter/src/common/auditlog"
	"configcenter/src/common/blog"
	"configcenter/src/common/errors"
	"configcenter/src/common/http/rest"
	"configcenter/src/common/mapstr"
	meta "configcenter/src/common/metadata"
	hostParse "configcenter/src/common/paraparse"
	"configcenter/src/common/util"
	"configcenter/src/kube/types"
	"configcenter/src/scene_server/host_server/logics"
	hutil "configcenter/src/scene_server/host_server/util"
)

// AppResult TODO
type AppResult struct {
	Result  bool        `json:"result"`
	Code    int         `json:"code"`
	Message interface{} `json:"message"`
	Data    DataInfo    `json:"data"`
}

// DataInfo TODO
type DataInfo struct {
	Count int                      `json:"count"`
	Info  []map[string]interface{} `json:"info"`
}

// DeleteHostBatchFromResourcePool delete hosts from resource pool
func (s *Service) DeleteHostBatchFro
    
func (s *Service) AddHost(ctx *rest.Contexts) {
	hostList := new(meta.HostList)
	if err := ctx.DecodeInto(&hostList); nil != err {
		ctx.RespAutoError(err)
		return
	}

	if hostList.HostInfo == nil {
		blog.Errorf("add host, but host info is nil.input:%+v,rid:%s", hostList, ctx.Kit.Rid)
		ctx.RespAutoError(ctx.Kit.CCError.CCError(common.CCErrCommParamsNeedSet))
		return
	}

	appID := hostList.ApplicationID
	if appID == 0 {
		// get default app id
		var err error
		appID, err = s.Logic.GetDefaultAppIDWithSupplier(ctx.Kit)
		if err != nil {
			blog.Errorf("add host, but get default app id failed, err: %v,input:%+v,rid:%s", err, hostList, ctx.Kit.Rid)
			ctx.RespAutoError(err)
			return
		}
	}

	// get target biz's idle module ID
	cond := hutil.NewOperation().WithAppID(appID).MapStr()
	cond.Set(common.BKDefaultField, common.DefaultResModuleFlag)
	moduleID, _, err := s.Logic.GetResourcePoolModuleID(ctx.Kit, cond)
	if err != nil {
		blog.Errorf("add host, but get module id failed, err: %v, input: %+v, rid: %s", err, hostList, ctx.Kit.Rid)
		ctx.RespAutoError(err)
		return
	}

	retData := make(map[string]interface{})
	txnErr := s.Engine.CoreAPI.CoreService().Txn().AutoRunTxn(ctx.Kit.Ctx, ctx.Kit.Header, func() error {
		_, success, updateErrRow, errRow, err := s.Logic.AddHost(ctx.Kit, appID, []int64{moduleID},
			ctx.Kit.SupplierAccount, hostList.HostInfo, hostList.InputType)
		if err != nil {
			blog.Errorf("add host failed, success: %v, update: %v, err: %v, %v,input:%+v,rid:%s",
				success, updateErrRow, err, errRow, hostList, ctx.Kit.Rid)
			retData["error"] = errRow
			retData["update_error"] = updateErrRow
			return ctx.Kit.CCError.CCError(common.CCErrHostCreateFail)
		}
		retData["success"] = success
		return nil
	})

	if txnErr != nil {
		ctx.RespEntityWithError(retData, txnErr)
		return
	}
	ctx.RespEntity(retData)
}