Начал реализацию API Subscribes

This commit is contained in:
Никита Потапов 2024-03-29 14:36:28 +04:00
parent a038c57d1f
commit 4d9ec8408b
6 changed files with 136 additions and 0 deletions

View File

@ -1,7 +1,10 @@
package com.example.nekontakte.posts.model; package com.example.nekontakte.posts.model;
import java.util.Date; import java.util.Date;
import java.util.Objects;
import com.example.nekontakte.core.model.BaseEntity; import com.example.nekontakte.core.model.BaseEntity;
import com.example.nekontakte.users.model.UserEntity;
public class PostEntity extends BaseEntity { public class PostEntity extends BaseEntity {
private Integer userId; private Integer userId;
@ -57,4 +60,27 @@ public class PostEntity extends BaseEntity {
this.html = html; this.html = html;
} }
@Override
public int hashCode() {
return Objects.hash(
id,
userId,
pubDate,
image,
html);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
final PostEntity other = (PostEntity) obj;
return Objects.equals(other.getId(), id) &&
Objects.equals(other.getUserId(), userId) &&
Objects.equals(other.getPubDate(), pubDate) &&
Objects.equals(other.getImage(), image) &&
Objects.equals(other.getHtml(), html);
}
} }

View File

@ -0,0 +1,5 @@
package com.example.nekontakte.subscribes.api;
public class SubscribeController {
}

View File

@ -0,0 +1,36 @@
package com.example.nekontakte.subscribes.api;
import jakarta.validation.constraints.NotNull;
public class SubscribeDTO {
private Integer id;
@NotNull
private Integer userId;
@NotNull
private Integer subscriberId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getSubscriberId() {
return subscriberId;
}
public void setSubscriberId(Integer subscriberId) {
this.subscriberId = subscriberId;
}
}

View File

@ -0,0 +1,59 @@
package com.example.nekontakte.subscribes.model;
import java.util.Objects;
import com.example.nekontakte.core.model.BaseEntity;
import com.example.nekontakte.posts.model.PostEntity;
import com.example.nekontakte.users.model.UserEntity;
public class SubscribeEntity extends BaseEntity {
private UserEntity user;
private UserEntity subscriber;
public SubscribeEntity() {
super();
}
public SubscribeEntity(Integer id, UserEntity user, UserEntity subscriber) {
super(id);
setUser(user);
setSubscriber(subscriber);
}
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
public UserEntity getSubscriber() {
return subscriber;
}
public void setSubscriber(UserEntity subscriber) {
this.subscriber = subscriber;
}
@Override
public int hashCode() {
return Objects.hash(
id,
user,
subscriber);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
final SubscribeEntity other = (SubscribeEntity) obj;
return Objects.equals(other.getId(), id) &&
Objects.equals(other.getUser(), user) &&
Objects.equals(other.getSubscriber(), subscriber);
}
}

View File

@ -0,0 +1,5 @@
package com.example.nekontakte.subscribes.repository;
public class SubscribeRepository {
}

View File

@ -0,0 +1,5 @@
package com.example.nekontakte.subscribes.service;
public class SubscribeService {
}