mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-18 13:01:02 +08:00
feat: add dedicated mappers
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.openisle.mapper;
|
||||
|
||||
import com.openisle.dto.ReactionDto;
|
||||
import com.openisle.model.Reaction;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/** Mapper for reactions. */
|
||||
@Component
|
||||
public class ReactionMapper {
|
||||
|
||||
public ReactionDto toDto(Reaction reaction) {
|
||||
ReactionDto dto = new ReactionDto();
|
||||
dto.setId(reaction.getId());
|
||||
dto.setType(reaction.getType());
|
||||
dto.setUser(reaction.getUser().getUsername());
|
||||
if (reaction.getPost() != null) {
|
||||
dto.setPostId(reaction.getPost().getId());
|
||||
}
|
||||
if (reaction.getComment() != null) {
|
||||
dto.setCommentId(reaction.getComment().getId());
|
||||
}
|
||||
dto.setReward(0);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user