package cn.muchinfo.rma.business.global

import cn.muchinfo.rma.protobuf.protoclasses.Common
import java.util.*

/**
 * Protobuf头模型
 */
class MessageHeadModel {
    companion object {
        /**
         * 获取通用业务头
         * @param funCode Int 功能码
         * @param userID Int 用户ID
         * @param accountID Long 账户
         * @param goodsID Int
         * @param marketID Int
         * @return Common.MessageHead.Builder
         */
        fun getHead(funCode: Int, userID: Int, accountID: Long, goodsID: Int, marketID: Int): Common.MessageHead.Builder {
            val builder = Common.MessageHead.newBuilder()
            builder.funCode = funCode
            builder.accountID = accountID
            builder.uuid = UUID.randomUUID().toString().
                replace("-", "").substring(0, 16)
            builder.goodsID = goodsID
            builder.marketID = marketID

            // 登录后报文需要

            builder.userID = userID

            return builder
        }
    }
}