forked from mtusi2026/mtusi2026lab7
Implement lab7 security and compromised worker recovery evidence
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package ru.mtusi.messenger.mapper;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import ru.mtusi.messenger.dto.ChatDTO;
|
||||
import ru.mtusi.messenger.dto.CreateChatDTO;
|
||||
import ru.mtusi.messenger.model.Chat;
|
||||
import ru.mtusi.messenger.model.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ChatMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "createdAt", ignore = true)
|
||||
@Mapping(target = "members", ignore = true)
|
||||
@Mapping(target = "messages", ignore = true)
|
||||
Chat toChat(CreateChatDTO dto);
|
||||
|
||||
@Mapping(target = "memberIds", source = "members", qualifiedByName = "usersToIds")
|
||||
ChatDTO toChatDto(Chat chat);
|
||||
|
||||
@Named("usersToIds")
|
||||
default List<UUID> usersToIds(Set<User> users) {
|
||||
if (users == null) return new ArrayList<>();
|
||||
List<UUID> ids = new ArrayList<>(users.size());
|
||||
for (User u : users) ids.add(u.getId());
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user