package com.ym.mec.biz.service.impl;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.auth.api.entity.SysUserRole;
import com.ym.mec.biz.dal.dao.EmployeeDao;
import com.ym.mec.biz.dal.entity.Employee;
import com.ym.mec.biz.dal.page.MusicGroupPerformanceQueryInfo;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.exception.BizException;
import com.ym.mec.common.page.PageInfo;
import com.ym.mec.util.collection.MapUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.ym.mec.common.service.impl.BaseServiceImpl;
import com.ym.mec.biz.dal.entity.MusicGroupPerformance;
import com.ym.mec.biz.service.MusicGroupPerformanceService;
import com.ym.mec.biz.dal.dao.MusicGroupPerformanceDao;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class MusicGroupPerformanceServiceImpl extends BaseServiceImpl<Integer, MusicGroupPerformance>  implements MusicGroupPerformanceService {
	
	@Autowired
	private MusicGroupPerformanceDao musicGroupPerformanceDao;
	@Autowired
	private SysUserFeignService sysUserFeignService;
	@Autowired
	private EmployeeDao employeeDao;

	@Override
	public BaseDAO<Integer, MusicGroupPerformance> getDAO() {
		return musicGroupPerformanceDao;
	}

    @Override
    public Object queryNoStartPage(MusicGroupPerformanceQueryInfo queryInfo) {
		PageInfo<MusicGroupPerformance> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
		Map<String, Object> params = new HashMap<String, Object>();
		MapUtil.populateMap(params, queryInfo);
		List<MusicGroupPerformance> dataList = null;
		int count = musicGroupPerformanceDao.countNoStart(params);
		if (count > 0) {
			pageInfo.setTotal(count);
			params.put("offset", pageInfo.getOffset());
			dataList = musicGroupPerformanceDao.queryNoStart(params);
		}
		if (count == 0) {
			dataList = new ArrayList<>();
		}
		pageInfo.setRows(dataList);
		return pageInfo;
    }
}