package com.cyl.manager.ums.service.impl;

import com.cyl.manager.ums.domain.MemberDoorLock;
import com.cyl.manager.ums.mapper.MemberDoorLockMapper;
import com.cyl.manager.ums.service.MemberDoorLockService;
import com.ruoyi.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 门锁信息Service接口
 * 
 * @author daixiande
 */
@Service
public class MemberDoorLockServiceImpl implements MemberDoorLockService {

    @Autowired
    private MemberDoorLockMapper memberDoorLockMapper;

    @Autowired
    private ISysDictDataService sysDictDataService;

    @Override
    public MemberDoorLock selectMemberDoorLockById(Long id) {
        return memberDoorLockMapper.selectById(id);
    }

    @Override
    public List<MemberDoorLock> selectMemberDoorLockList(MemberDoorLock memberDoorLock) {
        List<MemberDoorLock>  list =  memberDoorLockMapper.selectList(memberDoorLock);
        if(CollectionUtils.isEmpty(list)){
            return list;
        }
        for (MemberDoorLock doorLock : list) {
            doorLock.setHouseType(sysDictDataService.selectDictLabel("house_type",doorLock.getHouseType()));
            doorLock.setLockType(sysDictDataService.selectDictLabel("lock_type",doorLock.getLockType()));
            doorLock.setKeyHandover(sysDictDataService.selectDictLabel("Key_handover",doorLock.getKeyHandover()));
        }
        return list;
    }

    @Override
    public int insertMemberDoorLock(MemberDoorLock memberDoorLock) {
        return memberDoorLockMapper.insert(memberDoorLock);
    }

    @Override
    public int updateMemberDoorLock(MemberDoorLock memberDoorLock) {
        return memberDoorLockMapper.update(memberDoorLock);
    }

    @Override
    public int deleteMemberDoorLockByIds(Long[] ids) {
        return memberDoorLockMapper.deleteByIds(ids);
    }

    @Override
    public int deleteMemberDoorLockById(Long id) {
        return memberDoorLockMapper.deleteById(id);
    }
}
