package io.renren.service.impl;

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

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.EmergencyContactDao;
import io.renren.dto.EmergencyContactDTO;
import io.renren.entity.EmergencyContactEntity;
import io.renren.service.EmergencyContactService;

/**
 * 
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-05-11
 */
@Service
public class EmergencyContactServiceImpl extends CrudServiceImpl<EmergencyContactDao, EmergencyContactEntity, EmergencyContactDTO> implements EmergencyContactService {
   
	@Override
    public QueryWrapper<EmergencyContactEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Long userId = (Long)params.get("userId");

        QueryWrapper<EmergencyContactEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);
        wrapper.eq(null != userId, "user_id", userId);

        return wrapper;
    }

	@Override
	public List<EmergencyContactEntity> getContactByUserId(Long userId) {
		return baseDao.selectList(new QueryWrapper<EmergencyContactEntity>().eq("user_id", userId));
	}


}