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

import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto;
import com.xueyi.system.emcs.domain.dto.DmExceptionLogDto;
import com.xueyi.system.emcs.domain.query.DmExceptionLogQuery;
import com.xueyi.system.emcs.manager.IDmExceptionLogManager;
import com.xueyi.system.emcs.service.IDmExceptionLogService;
import com.xueyi.system.organize.service.ISysEnterpriseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 数字人状态事件上报日志管理 服务层处理
 *
 * @author xueyi
 */
@Service
public class DmExceptionLogServiceImpl extends BaseServiceImpl<DmExceptionLogQuery, DmExceptionLogDto, IDmExceptionLogManager> implements IDmExceptionLogService {

    @Autowired
    private ISysEnterpriseService enterpriseService;
    /**
     * 查询数字人状态事件上报日志对象列表 | 数据权限
     *
     * @param exceptionLog 数字人状态事件上报日志对象
     * @return 数字人状态事件上报日志对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"DmExceptionLogMapper"})
    public List<DmExceptionLogDto> selectListScope(DmExceptionLogQuery exceptionLog) {
        List<DmExceptionLogDto> exceptionLogDtos = baseManager.selectList(exceptionLog);
        exceptionLogDtos.forEach(dto->{
            Long tId = dto.getTId();
            if (tId!= null) {
                SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tId);
                dto.setTenantName(enterpriseDto.getName());
            }
        });
        return exceptionLogDtos;
    }

    @Override
    public List<DmExceptionLogDto> selectListRangeByCreateTime(String start,String end) {
        return super.baseManager.selectListRangeByCreateTime(start,end);
    }

    @Override
    public List<DmExceptionLogDto> selectListRangeByCreateTimeAndDevId(String start, String end, String devId) {
        return super.baseManager.selectListRangeByCreateTimeAndDevId(start, end, devId);
    }
}