package cn.newfeifan.mall.module.trade.utils.wechat;

import cn.newfeifan.mall.module.trade.api.wechat.WcChatMessageUtilsApi;
import cn.newfeifan.mall.module.trade.utils.push.JPushUtils;
import cn.newfeifan.mall.module.trade.utils.push.pojo.RequestBody;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

@Service
@Validated
public class WcChatMessageUtilsApiImpl implements WcChatMessageUtilsApi {

    @Resource
    private WcChatMessageUtils wcChatMessageUtils;
    @Resource
    private JPushUtils jPushUtils;

    @Override
    public void sendWcChatMessage(String templateId, List<String> params, Long systemUserId, Long objectId) {
        wcChatMessageUtils.sendWcChatMessage(templateId, params, systemUserId, objectId);
    }

    @Override
    public void jPush(List<String> rsgIds, String alert, String title, String url, Long memberUserId, Long systemUserId, Long objectId){
        RequestBody requestBody = jPushUtils.getRequestBody(rsgIds, alert, title, url);
        jPushUtils.jPush(requestBody, memberUserId, systemUserId, objectId);
    }

    @Override
    public String getUrl(String title, Long objectId, Long systemUserId) {
        return jPushUtils.getUrl(title, objectId, systemUserId);
    }

    @Override
    public Boolean isHavePermission(Long userId, String messageName) {
        return jPushUtils.isHavePermission(userId, messageName);
    }
}
