package com.xueyi.system.digitalmans.manager.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xueyi.common.web.annotation.TenantIgnore;
import com.xueyi.common.web.entity.manager.impl.BaseManagerImpl;
import com.xueyi.system.api.digitalmans.domain.po.DmManDevicePo;
import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto;
import com.xueyi.system.digitalmans.domain.model.DmManDeviceConverter;
import com.xueyi.system.digitalmans.domain.query.DmManDeviceQuery;
import com.xueyi.system.digitalmans.manager.IDmManDeviceManager;
import com.xueyi.system.digitalmans.mapper.DmManDeviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 数字人设备管理管理 数据封装层处理
 *
 * @author xueyi
 */
@Component
public class DmManDeviceManager extends BaseManagerImpl<DmManDeviceQuery, DmManDeviceDto, DmManDevicePo, DmManDeviceMapper, DmManDeviceConverter> implements IDmManDeviceManager {
    @Autowired
    DmManDeviceMapper manDeviceMapper;
    @Override
    public List<DmManDeviceDto> selectList(DmManDeviceQuery query) {
        return super.selectList(query);
    }

    @Override
    public DmManDeviceDto selectInfoByDevId(String devId) {
//        DmManDeviceDto dto = mapperDto(manDeviceMapper.selectOne(Wrappers.<DmManDevicePo>query().lambda()
//                .eq(DmManDevicePo::getDeviceId,devId)));
        DmManDeviceDto dto = mapperDto(manDeviceMapper.selectInfoByDevId(devId));
        return dto;
    }

    @Override
    public DmManDeviceDto selectInfoByManCode(String secret) {
        return mapperDto(manDeviceMapper.selectInfoBySecret(secret));
    }

    @Override
    public Integer updateInfoByManual(DmManDeviceDto dto) {
        return manDeviceMapper.updateInfoByManual(dto);
    }

    @TenantIgnore(tenantLine = true)
    @Override
    public List<DmManDeviceDto> selectListByManual(DmManDeviceQuery query) {
        return mapperDto(manDeviceMapper.selectListByManual(query));
    }

    @Override
    public List<DmManDeviceDto> selectManDeviceListNotNullByTenantId(Long tenantId) {
        return mapperDto(manDeviceMapper.selectListByManualDeviceIdNotNullByTenantId(tenantId));
    }
}