package com.red.circle.game.fruit.infrastructure.database.repository.impl;

import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.game.fruit.infrastructure.database.dao.GameFruitRuleDAO;
import com.red.circle.game.fruit.infrastructure.database.entity.GameFruitRule;
import com.red.circle.game.fruit.infrastructure.database.repository.GameFruitRuleService;
import java.util.Objects;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 摩天轮游戏规则 服务实现类.
 * </p>
 *
 * @author lisizhe on 2023-11-30 19:18
 */
@Service
public class GameFruitRuleServiceImpl extends
    BaseServiceImpl<GameFruitRuleDAO, GameFruitRule> implements GameFruitRuleService {

  @Override
  public GameFruitRule getRule(String sysOrigin) {
    return query().eq(GameFruitRule::getSysOrigin, sysOrigin).last(PageConstant.LIMIT_ONE).getOne();
  }


  @Override
  public void updateRule(GameFruitRule gameFruitRule) {
    if (Objects.isNull(gameFruitRule.getId())) {
      save(gameFruitRule);
    }
    updateSelectiveById(gameFruitRule);
  }
}
