package com.mortals.xhx.module.device.service.impl;

import cn.hutool.core.codec.Base64;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceLogDao;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.service.DeviceLogService;

import java.util.List;

/**
 * DeviceLogService
 * 设备日志 service实现
 *
 * @author zxfei
 * @date 2022-06-27
 */
@Service("deviceLogService")
public class DeviceLogServiceImpl extends AbstractCRUDServiceImpl<DeviceLogDao, DeviceLogEntity, Long> implements DeviceLogService {


    @Override
    protected void findAfter(DeviceLogEntity params, PageInfo pageInfo, Context context, List<DeviceLogEntity> list) throws AppException {
        list.stream().forEach(item -> {
            try {
                item.setContent(Base64.decodeStr(item.getContent()));
            } catch (Exception e) {
                log.error("content:" + item.getContent());
            }

        });
    }
}