Exemplo n.º 1
0
func (this *EndpointController) Delete() {
	jsonResult := g.JsonResult{}

	id, _ := this.GetInt64("Id")
	hostname := this.GetString("Hostname")
	item := models.Endpoint{Id: id}
	result, err := item.DeleteByPK()
	if nil != err {
		jsonResult.Message = err.Error()
	} else if result > 0 {
		store.HostAgents.Delete(hostname)
		jsonResult.Success = true
	} else {
		jsonResult.Message = "更新失败,数据不存在"
	}

	this.Data["json"] = &jsonResult
	this.ServeJSON()
}
Exemplo n.º 2
0
func convertHeartbeatReq2Endpoint(req *cmodel.HeartbeatRequest, strIp string) *models.Endpoint {
	endpoint := models.Endpoint{}
	endpoint.Hostname = req.Hostname
	if "" == req.Ip {
		endpoint.Ip = strIp
	} else {
		endpoint.Ip = req.Ip
	}
	endpoint.UpdaterVersion = req.UpdaterVersion
	endpoint.RunUser = req.RunUser
	return &endpoint
}