Created
March 28, 2021 19:25
-
-
Save evrentan/7b9d5c60e4851838ed853be6e7a6f42a to your computer and use it in GitHub Desktop.
Service Class Implementing Interface Class
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
package com.tan.example.service; | |
import com.tan.example.entity.EnterpriseEntity; | |
import org.bson.types.ObjectId; | |
import javax.enterprise.context.ApplicationScoped; | |
import javax.transaction.Transactional; | |
import javax.validation.Valid; | |
import java.util.List; | |
@ApplicationScoped | |
@Transactional(Transactional.TxType.REQUIRED) | |
public class EnterpriseService implements EnterpriseInterface { | |
public List<EnterpriseEntity> findAllEnterprises() { | |
return EnterpriseEntity.listAll(); | |
} | |
public EnterpriseEntity findEnterpriseById(String id) { | |
final ObjectId enterpriseId = new ObjectId(id); | |
return EnterpriseEntity.findById(enterpriseId); | |
} | |
public EnterpriseEntity createEnterprise(@Valid EnterpriseEntity enterpriseEntity) { | |
EnterpriseEntity.persist(enterpriseEntity); | |
return enterpriseEntity; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment