package org.jeecg.modules.utils;

import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.hanHaiMember.entity.HanHaiMember;

/**
 * @author java996.icu
 * @title: SubmitUtil
 * @projectName blind-box-api
 * @description: TODO
 * @date 2021/11/23 16:18
 * @Version V1.0
 */
public class SubmitUtil {

    public static void submit(HanHaiMember member, String name, RedisUtil redisUtil) {
        Long time = (Long) redisUtil.get("submit::" + member.getId() + "::" + name);
        if (time != null) {
            throw new JeecgBootException("请勿重复点击");
        }
        redisUtil.set("submit::" + member.getId() + "::" + name, System.currentTimeMillis(), 10);
    }

    public static void loginSubmit(String phone, String name, RedisUtil redisUtil) {
        Long time = (Long) redisUtil.get("submit::" + phone + "::" + name);
        if (time != null) {
            throw new JeecgBootException("请勿重复点击");
        }
        redisUtil.set("submit::" + phone + "::" + name, System.currentTimeMillis(), 10);
    }
}
