UserEventConverters.java 1.36 KB
package com.diligrp.assistant.logging.util;

import com.diligrp.assistant.logging.domain.UserEventDTO;
import com.diligrp.assistant.logging.model.UserEventDo;
import org.springframework.core.convert.converter.Converter;

public final class UserEventConverters {
    public static final Converter<UserEventDTO, UserEventDo> DTO2DO = new DTO2DO();

    public static final Converter<UserEventDo, UserEventDTO> DO2DTO = new DO2DTO();

    private static class DTO2DO implements Converter<UserEventDTO, UserEventDo> {
        @Override
        public UserEventDo convert(UserEventDTO source) {
            return (UserEventDo) source;
        }
    }

    private static class DO2DTO implements Converter<UserEventDo, UserEventDTO> {
        @Override
        public UserEventDTO convert(UserEventDo source) {
            UserEventDTO dto = new UserEventDTO();
            dto.setGroupId(source.getGroupId());
            dto.setModuleId(source.getModuleId());
            dto.setAction(source.getAction());
            dto.setObjectId(source.getObjectId());
            dto.setObjectName(source.getObjectName());
            dto.setEvent(source.getEvent());
            dto.setWhen(source.getWhen());
            dto.setUserId(source.getUserId());
            dto.setUserName(source.getUserName());
            dto.setCreatedTime(source.getCreatedTime());

            return dto;
        }
    }
}