package com.xueyi.system.meeting.service.impl;

import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.api.meeting.domain.dto.DmMeetingRoomsDto;
import com.xueyi.system.api.meeting.domain.po.DmMeetingRoomsPo;
import com.xueyi.system.meeting.domain.query.DmMeetingRoomsQuery;
import com.xueyi.system.meeting.manager.IDmMeetingRoomsManager;
import com.xueyi.system.meeting.mapper.DmMeetingRoomsMapper;
import com.xueyi.system.meeting.service.IDmMeetingRoomsService;
import com.xueyi.system.resource.mapper.DmResourcesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会议室管理 服务层处理
 *
 * @author xueyi
 */
@Service
public class DmMeetingRoomsServiceImpl extends BaseServiceImpl<DmMeetingRoomsQuery, DmMeetingRoomsDto, IDmMeetingRoomsManager> implements IDmMeetingRoomsService {


    @Autowired
    DmMeetingRoomsMapper dmMeetingRoomsMapper;

    @Autowired
    DmResourcesMapper dmResourcesMapper;
    /**
     * 查询会议室对象列表 | 数据权限
     *
     * @param dmMeetingRooms 会议室对象
     * @return 会议室对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"DmMeetingRoomsMapper"})
    public List<DmMeetingRoomsDto> selectListScope(DmMeetingRoomsQuery dmMeetingRooms) {
        return baseManager.selectList(dmMeetingRooms);
    }

    @Override
    public List<DmMeetingRoomsPo> selectRoomList(DmMeetingRoomsPo query) {
        List<DmMeetingRoomsPo> result = dmMeetingRoomsMapper.selectRoomList(query);
//        List<DmMeetingRoomsPo> po = dmMeetingRoomsMapper.selectList(null);
        return result;
    }

    @Override
    public void addImgUrl(DmMeetingRoomsDto dto) {
        if (null != dto.getResourceId()) {
            dto.setUrl(dmResourcesMapper.selectById(dto.getResourceId()).getUrl());
        }
    }
}