package com.ssj.service.sys.opentest;

import com.ssj.bean.sys.opentest.OpenTestModuleResult;
import com.ssj.dao.sys.opentest.OpenTestModuleResultDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.framework.core.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Mount Liu
 * @date 2020/2/11
 */
@Service
@Transactional
public class OpenTestModuleResultServiceImpl extends BaseServiceImpl<OpenTestModuleResult, String> implements OpenTestModuleResultService {

    @Autowired
    private OpenTestModuleResultDao dao;

    @Override
    public PagingAndSortingRepository<OpenTestModuleResult, String> getDao() {
        return dao;
    }

    @Override
    public List<OpenTestModuleResult> findByResultId(String resultId) {
        return dao.findByResultIdOrderByModuleSort(resultId);
    }

    @Override
    public Double findAvgAccuracyRate(String name, String subject, String grade, String version) {
        if (StringUtil.isBlank(version)) {
            return dao.findAvgAccuracyRate(name, subject, grade);
        } else {
            return dao.findAvgAccuracyRate(name, subject, grade, version);
        }
    }


}
