package com.td.Dawa.game.excelcharactercreate.service;

import com.td.Dawa.common.service.*;
import com.td.Dawa.game.excelcharactercreate.pojo.ExcelCharacterCreate;
import com.td.Dawa.game.excelcharactercreate.vo.ExcelCharacterCreateVo;
import com.td.Dawa.game.excelcharactercreate.repository.ExcelCharacterCreateRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

@Service
@Transactional
public class ExcelCharacterCreateServiceImpl extends CommonServiceImpl<ExcelCharacterCreateVo, ExcelCharacterCreate, Integer> implements ExcelCharacterCreateService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private ExcelCharacterCreateRepository excelCharacterCreateRepository;

    @Override
    public List<ExcelCharacterCreate> findRoleIdInByDESC(List<Integer> roleIds) {
        // excelCharacterCreateRepository.findALlByRoleIdIn(roleIds,Sort.by(Sort.Direction.DESC,"roleId"))
        return null;
    }

    @Override
    public List<ExcelCharacterCreate> findIdInByDESC(List<Integer> ids) {
        return excelCharacterCreateRepository.findAllByIdIn(ids,Sort.by(Sort.Direction.ASC,"position"));
    }

    @Override
    public List<ExcelCharacterCreate> findAll() {
        //Sort.by(Sort.Direction.ASC,"id")
        return excelCharacterCreateRepository.findAll();
    }

    @Override
    public List<ExcelCharacterCreate> findByModelIn(Integer[] models) {
        //
        return excelCharacterCreateRepository.findAllByModelIn(models, Sort.by(Sort.Direction.ASC,"position"));
    }


}
