@Before(Tx.class) public static final boolean create(OrderInfo order) { ModelUtil.generateUUID(order); order.set("createTime", new Date()); for (OrderInfoDetail detail : order.getDetails()) { ModelUtil.generateUUID(detail); detail.setOrderId(order.getStr("uid")); detail.save(); } return order.save(); }
@Before(Tx.class) public static final boolean delete(String uuid) { OrderInfo order = OrderInfo.dao.findFirst("select * from orderInfo where deleted=0 and uuid=?", uuid); if (order != null) { List<OrderInfoDetail> details = OrderInfoDetail.dao.find("select * from product where deleted=0 and orderId=?", uuid); for (OrderInfoDetail detal : details) { ModelUtil.softDelete(detal); } return ModelUtil.softDelete(order); } return false; }