package com.qqchen.deploy.backend.system.converter;

import com.qqchen.deploy.backend.system.model.RoleDTO;
import com.qqchen.deploy.backend.system.entity.Role;
import com.qqchen.deploy.backend.framework.converter.BaseConverter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;

@Mapper(config = BaseConverter.class)
public interface RoleConverter extends BaseConverter<Role, RoleDTO> {

    @Override
    @Mappings({
        @Mapping(target = "id", ignore = true),
        @Mapping(target = "createTime", ignore = true),
        @Mapping(target = "createBy", ignore = true),
        @Mapping(target = "updateTime", ignore = true),
        @Mapping(target = "updateBy", ignore = true),
        @Mapping(target = "version", ignore = true),
        @Mapping(target = "deleted", ignore = true)
    })
    void updateEntity(@MappingTarget Role entity, RoleDTO dto);

    @Override
    @Mappings({
        @Mapping(target = "tags", source = "tags")
    })
    RoleDTO toDto(Role entity);

    @Override
    @Mappings({
        @Mapping(target = "tags", source = "tags")
    })
    Role toEntity(RoleDTO dto);
}