package com.adealink.weparty.order.qrcode

import com.adealink.frame.router.Router
import com.adealink.frame.router.annotation.RouterUri
import com.adealink.frame.router.handler.UriHandler
import com.adealink.frame.router.request.UriRequest
import com.adealink.frame.util.AppUtil
import com.adealink.weparty.module.order.Order
import com.adealink.weparty.router.AppLink

@RouterUri(
    path = [
        AppLink.QRCodeOrder.PATH
    ],
    desc = "AppLink 二维码订单"
)
class QRCodeOrderAppLinkHandler : UriHandler() {
    override fun handle(request: UriRequest) {
        val categoryId = request.intent.getStringExtra(AppLink.QRCodeOrder.EXTRA_CATEGORY_ID)
        val qrCode = request.intent.getStringExtra(AppLink.QRCodeOrder.EXTRA_QR_CODE)
        if (categoryId.isNullOrEmpty() || qrCode.isNullOrEmpty()) {
            return
        }
        val ctx = request.ctx ?: AppUtil.currentActivity
        if (ctx == null) {
            return
        }
        Router.build(ctx, Order.QRCode.PATH)
            .putExtra(Order.QRCode.EXTRA_CATEGORY_ID, categoryId)
            .putExtra(Order.QRCode.EXTRA_QR_CODE, qrCode)
            .start()
    }


}