package com.huangzj.cross.cmd;

import com.huangzj.base.cmd.AbstractTypedPbCommand;
import com.huangzj.base.cmd.Cmd;
import com.huangzj.base.cmd.CommandContext;
import com.huangzj.base.cmd.CommandSource;
import com.huangzj.cmd.gen.CrossForwardCts;
import com.huangzj.cmd.gen.CrossForwardStc;
import com.huangzj.cmd.gen.PbService;
import com.huangzj.cmd.gen.Service2_Method;
import org.springframework.stereotype.Component;

/** 跨服示例：{@link PbService#Service_2} + {@link Service2_Method#Method2}。 */
@Component
@Cmd(
        source = CommandSource.CROSS_TCP,
        serviceId = PbService.Service_2_VALUE,
        methodId = Service2_Method.Method2_VALUE)
public class CrossForwardCommand extends AbstractTypedPbCommand<CrossForwardCts, CrossForwardStc.Builder> {

    @Override
    protected void run(CommandContext ctx, CrossForwardCts cts, CrossForwardStc.Builder stcBuilder) {
        // Demo：给 trace 加前缀便于区分「跨服加工」；生产可在此落库、转发其它服等
        stcBuilder.setTrace("cross:" + cts.getTrace()).setCrossTimeMs(System.currentTimeMillis());
    }
}
