package cn.ey.biz.module.system.mq.producer.permission;

import cn.ey.biz.framework.mq.core.RedisMQTemplate;
import cn.ey.biz.module.system.mq.message.permission.PermissionRoleMenuRefreshMessage;
import cn.ey.biz.module.system.mq.message.permission.PermissionUserRoleRefreshMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Permission 权限相关消息的 Producer
 */
@Component
@Slf4j
public class PermissionProducerRedis implements PermissionProducer {

    @Resource
    private RedisMQTemplate redisMQTemplate;

    /**
     * 发送 {@link PermissionRoleMenuRefreshMessage} 消息
     */
    public void sendRoleMenuRefreshMessage() {
        PermissionRoleMenuRefreshMessage message = new PermissionRoleMenuRefreshMessage();
        log.info("[execute][发送 Role 与 Menu 的关联刷新消息]");
        redisMQTemplate.send(message);
    }

    /**
     * 发送 {@link PermissionUserRoleRefreshMessage} 消息
     */
    public void sendUserRoleRefreshMessage() {
        PermissionUserRoleRefreshMessage message = new PermissionUserRoleRefreshMessage();
        redisMQTemplate.send(message);
    }

}
