package com.bonus.canteen.core.device.door.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.device.door.mapper.DcGroupDoorMapper;
import com.bonus.canteen.core.device.door.model.DcGroupDoor;
import com.bonus.canteen.core.device.door.service.DcGroupDoorService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DcGroupDoorServiceImpl extends ServiceImpl<DcGroupDoorMapper, DcGroupDoor> implements DcGroupDoorService {

   @Override
   public List<DcGroupDoor> getDistantDoorIdAndTimeZoneIdByGroupIds(List<Integer> groupIds) {
       return this.list(Wrappers.<DcGroupDoor>lambdaQuery()
               .select(DcGroupDoor::getDoorId, DcGroupDoor::getTimeZoneId)
               .in(DcGroupDoor::getGroupId, groupIds)
               .groupBy(DcGroupDoor::getDoorId, DcGroupDoor::getTimeZoneId)
               .orderByDesc(DcGroupDoor::getTimeZoneId));
   }
}
