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


import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.game.fruit.infrastructure.database.dao.GameFruitBountyConfigDAO;
import com.red.circle.game.fruit.infrastructure.database.entity.GameFruitBountyConfig;
import com.red.circle.game.fruit.infrastructure.database.repository.GameFruitBountyConfigService;
import com.red.circle.game.fruit.inner.model.cmd.GameFruitBountyConfigQryCmd;
import com.red.circle.tool.core.text.StringUtils;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 摩天轮游戏赏金任务配置 服务实现类.
 * </p>
 *
 * @author zongpubin on 2023-12-13 10:38
 */
@Service
public class GameFruitBountyConfigServiceImpl extends
    BaseServiceImpl<GameFruitBountyConfigDAO, GameFruitBountyConfig> implements
    GameFruitBountyConfigService {

  @Override
  public PageResult<GameFruitBountyConfig> getGameFruitBountyConfig(
      GameFruitBountyConfigQryCmd query) {
    return query()
        .eq(StringUtils.isNotBlank(query.getSysOrigin()), GameFruitBountyConfig::getSysOrigin,
            query.getSysOrigin())
        .eq(StringUtils.isNotBlank(query.getBountyType()), GameFruitBountyConfig::getBountyType,
            query.getBountyType())
        .orderByDesc(GameFruitBountyConfig::getCreateTime)
        .page(query.getPageQuery());
  }

  @Override
  public List<GameFruitBountyConfig> getBySysOrigin(String originSys) {
    return query().eq(GameFruitBountyConfig::getSysOrigin, originSys)
        .orderByAsc(GameFruitBountyConfig::getSort).list();
  }
}
