package com.maxiee.heartbeat.database.api;

import android.content.Context;

import com.maxiee.heartbeat.database.tables.EventThoughtRelationTable;
import com.maxiee.heartbeat.database.tables.ThoughtsTable;

/**
 * Created by maxiee on 15-7-8.
 */
public class DeleteThoughtByKeyApi extends BaseDBApi{
    private int mThoughtKey;

    public DeleteThoughtByKeyApi(Context context, int thoughtKey) {
        super(context);
        mThoughtKey = thoughtKey;
    }

    public void exec() {
        mDatabaseHelper.getWritableDatabase().delete(
                EventThoughtRelationTable.NAME,
                EventThoughtRelationTable.THOUGHT_ID + "=?",
                new String[] {String.valueOf(mThoughtKey)}
        );
        mDatabaseHelper.getWritableDatabase().delete(
                ThoughtsTable.NAME,
                ThoughtsTable.ID + "=?",
                new String[] {String.valueOf(mThoughtKey)}
        );
    }
}

@@ -141,16 +141,77 @@
 nTable;%0A
+import com.maxiee.heartbeat.database.tables.ThoughtResTable;%0A
 import c
@@ -974,20 +974,233 @@
 %0A        );%0A
+        mDatabaseHelper.getWritableDatabase().delete(%0A                ThoughtResTable.NAME,%0A                ThoughtResTable.THOUGHT_ID + %22=?%22,%0A                new String%5B%5D %7BString.valueOf(mThoughtKey)%7D%0A        );%0A
     %7D%0A%7D%0A

delete thought_res table as well.