-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from smartSenseSolutions/add-new-endpoints-for-…
…user-chat-and-edc-registration feat: add curd operation endpoints for user, chat and edc registration.
- Loading branch information
Showing
35 changed files
with
813 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
chat-api/src/main/java/com/smartsense/api/model/request/ChatRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.smartsense.api.model.request; | ||
|
||
import java.util.UUID; | ||
|
||
public record ChatRequest(UUID senderId, | ||
UUID receiverId, | ||
String message, | ||
String messageType) { | ||
} |
6 changes: 6 additions & 0 deletions
6
chat-api/src/main/java/com/smartsense/api/model/request/EDCRegisterRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.smartsense.api.model.request; | ||
|
||
import java.util.UUID; | ||
|
||
public record EDCRegisterRequest(String edcUrl, UUID userId) { | ||
} |
6 changes: 6 additions & 0 deletions
6
chat-api/src/main/java/com/smartsense/api/model/request/EDCUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.smartsense.api.model.request; | ||
|
||
import java.util.UUID; | ||
|
||
public record EDCUpdateRequest(UUID edcId, EDCRegisterRequest request) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
chat-api/src/main/java/com/smartsense/api/model/response/ChatResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.smartsense.api.model.response; | ||
|
||
import java.util.UUID; | ||
|
||
public record ChatResponse(String id, | ||
UUID senderId, | ||
UUID receiverId, | ||
String message, | ||
String messageType, | ||
String createdAt) { | ||
} |
10 changes: 10 additions & 0 deletions
10
chat-api/src/main/java/com/smartsense/api/model/response/EDCRegisterResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.smartsense.api.model.response; | ||
|
||
import java.util.UUID; | ||
|
||
public record EDCRegisterResponse( | ||
UUID id, | ||
String edcUrl, | ||
UserResponse userId | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
chat-api/src/main/java/com/smartsense/api/model/response/UsersEDCResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.smartsense.api.model.response; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public record UsersEDCResponse(UUID userId, | ||
List<String> edcUrl) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
chat-dao/src/main/java/com/smartsense/dao/entity/ChatMaster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.smartsense.dao.entity; | ||
|
||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Document(collection = "chat_master") | ||
@Builder | ||
public class ChatMaster extends BaseAuditEntity { | ||
|
||
@Id | ||
private String id; | ||
private UUID senderId; | ||
private UUID receiverId; | ||
private String message; | ||
private String messageType; | ||
} |
40 changes: 40 additions & 0 deletions
40
chat-dao/src/main/java/com/smartsense/dao/entity/EDCRegisterMaster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.smartsense.dao.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Entity | ||
@Table(name = "edc_register_master") | ||
public class EDCRegisterMaster extends BaseAuditEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@Column(name = "id", nullable = false, updatable = false, insertable = false) | ||
private UUID id = UUID.randomUUID(); | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id_id", nullable = false) | ||
private UserMaster userId; | ||
|
||
private String edcUrl; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
chat-dao/src/main/java/com/smartsense/dao/repository/ChatMasterRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.smartsense.dao.repository; | ||
|
||
import com.smartsense.dao.entity.ChatMaster; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ChatMasterRepository extends MongoRepository<ChatMaster, String> { | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
chat-dao/src/main/java/com/smartsense/dao/repository/EDCRegisterMasterRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.smartsense.dao.repository; | ||
|
||
|
||
import com.smartsense.dao.entity.EDCRegisterMaster; | ||
import com.smartsensesolutions.commons.dao.base.BaseRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Repository | ||
public interface EDCRegisterMasterRepository extends BaseRepository<EDCRegisterMaster, UUID> { | ||
|
||
boolean existsByEdcUrl(String edcUrl); | ||
|
||
@Query("select e from EDCRegisterMaster e where e.userId.id = ?1") | ||
List<EDCRegisterMaster> findByUserId(UUID id); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
chat-service-impl/src/main/java/com/smartsense/service/entity/EDCService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.smartsense.service.entity; | ||
|
||
import com.smartsense.api.constant.ContMessage; | ||
import com.smartsense.api.model.request.EDCRegisterRequest; | ||
import com.smartsense.api.model.response.UsersEDCResponse; | ||
import com.smartsense.api.utils.Validate; | ||
import com.smartsense.dao.entity.EDCRegisterMaster; | ||
import com.smartsense.dao.entity.UserMaster; | ||
import com.smartsense.dao.repository.EDCRegisterMasterRepository; | ||
import com.smartsensesolutions.commons.dao.base.BaseRepository; | ||
import com.smartsensesolutions.commons.dao.specification.SpecificationUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Service | ||
public class EDCService extends BaseEntityService<EDCRegisterMaster, UUID> { | ||
|
||
@Autowired | ||
private EDCRegisterMasterRepository edcRegisterMasterRepository; | ||
@Autowired | ||
private SpecificationUtil<EDCRegisterMaster> specificationUtil; | ||
|
||
public EDCRegisterMaster createEDC(EDCRegisterRequest request, UserMaster user) { | ||
Validate.isTrue(edcRegisterMasterRepository.existsByEdcUrl(request.edcUrl())).launch(ContMessage.VALIDATE_EDC_CREATE_URL_EXIST); | ||
EDCRegisterMaster edcRegisterMaster = EDCRegisterMaster.builder() | ||
.edcUrl(request.edcUrl()) | ||
.userId(user) | ||
.build(); | ||
return create(edcRegisterMaster); | ||
} | ||
|
||
|
||
@Override | ||
protected BaseRepository<EDCRegisterMaster, UUID> getRepository() { | ||
return edcRegisterMasterRepository; | ||
} | ||
|
||
public UsersEDCResponse getEDCByUserid(UUID userId) { | ||
List<EDCRegisterMaster> edcList = edcRegisterMasterRepository.findByUserId(userId); | ||
List<String> edcUrls = edcList.stream().map(EDCRegisterMaster::getEdcUrl).toList(); | ||
return new UsersEDCResponse(userId, edcUrls); | ||
} | ||
} |
Oops, something went wrong.