package com.ruoyi.integration.barrierGate.model; import com.ruoyi.common.core.utils.MD5Util; import lombok.Data; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; /** * @author zhibing.pu * @Date 2024/9/10 9:45 */ @Slf4j @Data @Accessors(chain = true) public class SwitchwayGate { /** * 停车场appkey */ private String appkey; /** * 开关动作(open:开、close:关) */ private String action; /** * 通道编号 */ private String channel; /** * 当前时间戳 */ private String timestamp; /** * 签名信息:参数升序排序,&拼接所有参数,MD5(参数+&+参数值...+签名密钥)转大写 */ private String sign; public SwitchwayGate build(String secretkey){ String str = String.format("action=%s&appkey=%s&channel=%s×tamp=%s&key=%s", this.getAction(), this.getAppkey(), this.getChannel(), this.getTimestamp(), secretkey); log.info("待签名串:{}", str); //MD5加密 String encoder = MD5Util.getMD5(str); //将签名结果转大写 encoder = encoder.toUpperCase(); log.info("签名结果:{}", encoder); this.setSign(encoder); return this; } }