package com.jsowell.pile.service.impl;

import com.google.common.collect.Lists;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.PileMemberRelation;
import com.jsowell.pile.mapper.PileMemberRelationMapper;
import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.service.IPileMemberRelationService;
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 桩与用户绑定关系Service业务层处理
 *
 * @author jsowell
 * @date 2023-02-21
 */
@Service
public class PileMemberRelationServiceImpl implements IPileMemberRelationService {
	@Autowired
	private PileMemberRelationMapper pileMemberRelationMapper;

	@Autowired
	private IPileConnectorInfoService pileConnectorInfoService;
	/**
	 * 查询桩与用户绑定关系
	 *
	 * @param id 桩与用户绑定关系主键
	 * @return 桩与用户绑定关系
	 */
	@Override
	public PileMemberRelation selectPileMemberRelationById(Integer id) {
		return pileMemberRelationMapper.selectPileMemberRelationById(id);
	}

	/**
	 * 查询桩与用户绑定关系列表
	 *
	 * @param pileMemberRelation 桩与用户绑定关系
	 * @return 桩与用户绑定关系
	 */
	@Override
	public List<PileMemberRelation> selectPileMemberRelationList(PileMemberRelation pileMemberRelation) {
		return pileMemberRelationMapper.selectPileMemberRelationList(pileMemberRelation);
	}

	/**
	 * 条件查询桩与用户绑定关系
	 *
	 * @param pileMemberRelation 桩与用户绑定关系
	 * @return 桩与用户绑定关系对象
	 */
    @Override
    public PileMemberRelation selectPileMemberRelation(PileMemberRelation pileMemberRelation) {
        return pileMemberRelationMapper.selectPileMemberRelation(pileMemberRelation);
    }

    /**
	 * 新增桩与用户绑定关系
	 *
	 * @param pileMemberRelation 桩与用户绑定关系
	 * @return 结果
	 */
	@Override
	public int insertPileMemberRelation(PileMemberRelation pileMemberRelation) {
		pileMemberRelation.setCreateTime(DateUtils.getNowDate());
		return pileMemberRelationMapper.insertPileMemberRelation(pileMemberRelation);
	}

	/**
	 * 修改桩与用户绑定关系
	 *
	 * @param pileMemberRelation 桩与用户绑定关系
	 * @return 结果
	 */
	@Override
	public int updatePileMemberRelation(PileMemberRelation pileMemberRelation) {
		return pileMemberRelationMapper.updatePileMemberRelation(pileMemberRelation);
	}

	/**
	 * 批量删除桩与用户绑定关系
	 *
	 * @param ids 需要删除的桩与用户绑定关系主键
	 * @return 结果
	 */
	@Override
	public int deletePileMemberRelationByIds(Integer[] ids) {
		return pileMemberRelationMapper.deletePileMemberRelationByIds(ids);
	}

	/**
	 * 删除桩与用户绑定关系信息
	 *
	 * @param id 桩与用户绑定关系主键
	 * @return 结果
	 */
	@Override
	public int deletePileMemberRelationById(Integer id) {
		return pileMemberRelationMapper.deletePileMemberRelationById(id);
	}

	@Override
	public List<PileMemberRelation> selectPileMemberRelationByPileSn(String pileSn) {
		PileMemberRelation pileMemberRelation = new PileMemberRelation();
		pileMemberRelation.setPileSn(pileSn);
		return selectPileMemberRelationList(pileMemberRelation);
	}


}
