package org.springblade.swzdr.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.swzdr.excel.RyXfxxExcel;
import org.springblade.swzdr.mapper.RyXfxxMapper;
import org.springblade.swzdr.pojo.entity.RyXflsEntity;
import org.springblade.swzdr.pojo.entity.RyXfxxEntity;
import org.springblade.swzdr.pojo.vo.RyXfxxVO;
import org.springblade.swzdr.pojo.vo.XfxxDjVO;
import org.springblade.swzdr.service.IRyXflsService;
import org.springblade.swzdr.service.IRyXfxxService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 人员_信访信息 服务实现类
 *
 * @author BladeX
 * @since 2024-09-12
 */
@Service
@AllArgsConstructor
public class RyXfxxServiceImpl extends BaseServiceImpl<RyXfxxMapper, RyXfxxEntity> implements IRyXfxxService {

	private final IRyXflsService xflsService;

	@Override
	public IPage<RyXfxxVO> selectRyXfxxPage(IPage<RyXfxxVO> page, RyXfxxVO ryXfxx) {
		return page.setRecords(baseMapper.selectRyXfxxPage(page, ryXfxx));
	}

	@Override
	public List<RyXfxxExcel> exportRyXfxx(Wrapper<RyXfxxEntity> queryWrapper) {
		List<RyXfxxExcel> ryXfxxList = baseMapper.exportRyXfxx(queryWrapper);
		//ryXfxxList.forEach(ryXfxx -> {
		//	ryXfxx.setTypeName(DictCache.getValue(DictEnum.YES_NO, RyXfxx.getType()));
		//});
		return ryXfxxList;
	}

	@Override
	public List<XfxxDjVO> getByUserId(Long id) {
		List<XfxxDjVO> xfxxDjVOList = baseMapper.getByUserId(id);
		if (null != xfxxDjVOList && !xfxxDjVOList.isEmpty()) {
			for (XfxxDjVO xfxxDjVO : xfxxDjVOList) {
				QueryWrapper<RyXflsEntity> queryWrapper = new QueryWrapper<>();
				queryWrapper.eq("is_deleted", 0);
				queryWrapper.eq("is_deleted", 0);
				List<RyXflsEntity> xflsList = xflsService.list(queryWrapper);
				xfxxDjVO.setXflsList(xflsList);
			}
		}
		return xfxxDjVOList;
	}

}
