package app.action.crud;
import app.logic.CrudLogic;
import com.blogger.tcuri.appserver.Action;
import com.blogger.tcuri.appserver.ActionContext;
import com.blogger.tcuri.appserver.Utils;
import com.blogger.tcuri.appserver.db.DbUtils;
import com.blogger.tcuri.appserver.db.SqlBuilder;
import com.blogger.tcuri.appserver.db.Transactional;
import com.blogger.tcuri.appserver.resolution.Resolution;
@Transactional
public class CreateAction extends Action {
@Override
public Resolution execute(ActionContext context) throws Exception {
String content = context.param("content");
if (Utils.isNotBlank(content)) {
SqlBuilder sql = new SqlBuilder(
"insert into messages (content) values (?)", content);
DbUtils.execute(sql);
}
return CrudLogic.read();
}
}