package io.hmit.modules.serviceOrder.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.page.PageData;
import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.SubListForPageUtil;
import io.hmit.modules.serviceOrder.dao.PensionEventDao;
import io.hmit.modules.serviceOrder.dto.PensionEventDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.entity.PensionEventEntity;
import io.hmit.modules.serviceOrder.service.PensionEventService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 活动表
 *
 * @author Shen Yuanfeng syf0412@vip.qq.com
 * @since 1.0.0 2021-05-12
 */
@Service
public class PensionEventServiceImpl extends CrudServiceImpl<PensionEventDao, PensionEventEntity, PensionEventDTO> implements PensionEventService {

    @Override
    public QueryWrapper<PensionEventEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<PensionEventEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Autowired
    private PensionEventDao pensionEventDao;

    @Override
    public PageData<PensionEventDTO> getUserPage(Map<String, Object> params) {
        List<PensionEventDTO> list = pensionEventDao.getEventForUser();
        return getPageData(SubListForPageUtil.getSubList(params, list), list.size(), PensionEventDTO.class);
    }
}