package com.YuyeTech.HeartRate.game.TP_WxInfo.service;

import com.YuyeTech.HeartRate.common.service.CommonServiceImpl;
import com.YuyeTech.HeartRate.game.TP_WxInfo.projo.WxInfo;
import com.YuyeTech.HeartRate.game.TP_WxInfo.repository.WxInfoRepository;
import com.YuyeTech.HeartRate.game.TP_WxInfo.vo.WxInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author:slambb
 * @date:2019/12/13
 */
@Service
@Transactional
public class WxInfoServicelmpl extends CommonServiceImpl<WxInfoVo, WxInfo, String> implements WxInfoService {
    @Autowired
    private WxInfoRepository wxInfoRepository;

    @Override
    public WxInfo findWxInfoByOpenid(String openid) {
        return wxInfoRepository.findByOpenid(openid).orElse(null);
    }

    @Override
    public WxInfo findWxInfoByUnionid(String unionid) {
        return wxInfoRepository.findByUnionid(unionid).orElse(null);
    }

    @Override
    public WxInfo addWxInfo(WxInfo wxInfo) {
        return wxInfoRepository.save(wxInfo);
    }

    @Override
    public WxInfo findWxInfoById(String userId) {
        return wxInfoRepository.findById(userId).orElse(null);
    }
}
