package com.rongyichuang.player.service;
|
|
import com.rongyichuang.player.entity.Player;
|
import com.rongyichuang.player.repository.PlayerRepository;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Optional;
|
|
/**
|
* 学员服务类
|
*/
|
@Service
|
public class PlayerService {
|
|
@Autowired
|
private PlayerRepository playerRepository;
|
|
/**
|
* 根据用户ID获取学员信息
|
*/
|
public Player findByUserId(Long userId) {
|
Optional<Player> player = playerRepository.findByUserId(userId);
|
return player.orElse(null);
|
}
|
|
/**
|
* 根据ID获取学员信息
|
*/
|
public Player findById(Long id) {
|
Optional<Player> player = playerRepository.findById(id);
|
return player.orElse(null);
|
}
|
|
/**
|
* 保存学员信息
|
*/
|
public Player save(Player player) {
|
return playerRepository.save(player);
|
}
|
}
|