[REV] update plugin delete api

This commit is contained in:
barnett 2018-05-11 15:54:55 +08:00
parent 93027efb09
commit 305c5eb92f
3 changed files with 17 additions and 5 deletions

View File

@ -96,7 +96,20 @@ func (p *PluginAction) UpdatePluginAct(pluginID, tenantID string, cps *api_model
//DeletePluginAct DeletePluginAct
func (p *PluginAction) DeletePluginAct(pluginID, tenantID string) *util.APIHandleError {
tx := db.GetManager().Begin()
err := db.GetManager().TenantPluginDaoTransactions(tx).DeletePluginByID(pluginID, tenantID)
//step1: delete service plugin relation
err := db.GetManager().TenantServicePluginRelationDaoTransactions(tx).DeleteALLRelationByPluginID(pluginID)
if err != nil {
tx.Rollback()
return util.CreateAPIHandleErrorFromDBError("delete plugin relation", err)
}
//step2: delete plugin build version
err = db.GetManager().TenantPluginBuildVersionDaoTransactions(tx).DeleteBuildVersionByPluginID(pluginID)
if err != nil {
tx.Rollback()
return util.CreateAPIHandleErrorFromDBError("delete plugin build version", err)
}
//step3: delete plugin
err = db.GetManager().TenantPluginDaoTransactions(tx).DeletePluginByID(pluginID, tenantID)
if err != nil {
tx.Rollback()
return util.CreateAPIHandleErrorFromDBError("delete plugin", err)

View File

@ -64,10 +64,8 @@ func (t *PluginDaoImpl) GetPluginByID(id, tenantID string) (*model.TenantPlugin,
//DeletePluginByID DeletePluginByID
func (t *PluginDaoImpl) DeletePluginByID(id, tenantID string) error {
relation := &model.TenantPlugin{
PluginID: id,
}
if err := t.DB.Where("plugin_id=? and tenant_id=?", id, tenantID).Delete(relation).Error; err != nil {
var plugin model.TenantPlugin
if err := t.DB.Where("plugin_id=? and tenant_id=?", id, tenantID).Delete(&plugin).Error; err != nil {
return err
}
return nil

View File

@ -137,6 +137,7 @@ func (n *NodeCluster) UpdateNode(node *model.HostNode) {
n.nodes[node.ID] = node
n.client.Put(option.Config.NodePath+"/"+node.ID, node.String())
}
func (n *NodeCluster) getNodeFromKV(kv *mvccpb.KeyValue) *model.HostNode {
var node model.HostNode
if err := ffjson.Unmarshal(kv.Value, &node); err != nil {