{"id":47997500,"url":"https://github.com/rrohitramsen/ems","last_synced_at":"2026-04-04T12:02:27.744Z","repository":{"id":29486862,"uuid":"121832143","full_name":"rrohitramsen/ems","owner":"rrohitramsen","description":"Generic entity management system with rest end points supporting Http POST, GET, PUT, PATCH, DELETE methods.","archived":false,"fork":false,"pushed_at":"2024-08-26T16:15:23.000Z","size":1187,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-06T21:22:56.289Z","etag":null,"topics":["api-rest","best-practices","crud-application","endpoints","generic-repository","java-8","jpa-entities","junit4","microservice","rest-api","restapi","restful-api","restful-webservices","spring-boot","spring-data-jpa","springboot","swagger-api","swagger-documentation","swagger-ui","swagger2"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rrohitramsen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-17T06:11:00.000Z","updated_at":"2024-06-20T09:56:07.000Z","dependencies_parsed_at":"2022-08-07T14:30:14.960Z","dependency_job_id":null,"html_url":"https://github.com/rrohitramsen/ems","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rrohitramsen/ems","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrohitramsen%2Fems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrohitramsen%2Fems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrohitramsen%2Fems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrohitramsen%2Fems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rrohitramsen","download_url":"https://codeload.github.com/rrohitramsen/ems/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrohitramsen%2Fems/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31398770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-rest","best-practices","crud-application","endpoints","generic-repository","java-8","jpa-entities","junit4","microservice","rest-api","restapi","restful-api","restful-webservices","spring-boot","spring-data-jpa","springboot","swagger-api","swagger-documentation","swagger-ui","swagger2"],"created_at":"2026-04-04T12:02:26.940Z","updated_at":"2026-04-04T12:02:27.667Z","avatar_url":"https://github.com/rrohitramsen.png","language":"Java","readme":"# Generic entity management framework enable writing rest api with minimal code and out of the box swagger docs. It supports POST, GET, PUT, PATCH, DELETE HttpMethods.\n\n## Requirement\nCreate a simple entity management system that provides a REST endpoint to manage any entity (e.g. a product in a catalog, patient information in healthcare etc.).\n\nThe system should allow for the following capabilities:\n\n1.\tIt should be able to adapt to any kind of entity with minimal code changes\n2.\tAdding, removing, modifying the attributes of an entity should be simple\n\n## Benifits\n1. Reduce developement effort by 60% becuase the developer only need to give service implmenetation. Rest of controller, log, swagger docs, workflow will be take care by the framework.\n2. Enforces rest best practices.\n\n\n\n\n## Basic Entity\n\n```java\n@Entity\npublic abstract class BasicEntity implements Serializable {\n\n    static final long serialVersionUID = 1L;\n\n    @Id\n    @GeneratedValue(strategy = GenerationType.AUTO)\n    @Column(name = \"id\", nullable = false, updatable = false)\n    @ApiModelProperty(notes = \"The database generated ID.\")\n    private Long id;\n\n    @Column(name = \"created_time\", insertable=true, updatable=false)\n    @ApiModelProperty(notes = \"The database generated created time.\")\n    private Date createdTime;\n\n    @Column(name = \"updated_time\", insertable=false, updatable=true)\n    @ApiModelProperty(notes = \"The database generated updated time.\")\n    private Date updatedTime;\n}\n\n```\n\n## Generic Entity Controller\n\n```java\n@RestController\n@RequestMapping(\"/entities\")\n@Api(value=\"Entity Management System API\", description=\"CRUD operations on Entity.\")\npublic class EntityController\u003cT extends BasicEntity\u003e\n\n```\n\n### Create Entity using Http Post\n\n```java\n@ApiOperation(value = \"Create entity.\", response = APIResponse.class)\n    @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Success\", response = APIResponse.class),\n            @ApiResponse(code = 400, message = \"Bad Request\"),\n            @ApiResponse(code = 401, message = \"Unauthorized\"),\n            @ApiResponse(code = 403, message = \"Forbidden\"),\n            @ApiResponse(code = 404, message = \"Not Found\"),\n            @ApiResponse(code = 500, message = \"Failure\")})\n    public ResponseEntity\u003cAPIResponse\u003e createEntity(@RequestBody T entity) {\n\n        LOGGER.debug(\"Inside createEntity with param \"+entity);\n        T responseEntity = entityService.createEntity(entity);\n        String message = \"Entity created successfully.\";\n        APIResponse\u003cT\u003e  apiResponse = new APIResponse(message,  HttpStatus.CREATED.value(), responseEntity);\n        LOGGER.debug(message);\n        return new ResponseEntity\u003c\u003e(apiResponse, HttpStatus.CREATED);\n    }\n\n```\n![create_entity](/src/main/resources/images/create_entity.png \"create_entity\")\n\n### Update Entity using Http Put\n\n```java\n@ApiOperation(value = \"Update entity with the given id.\", response = APIResponse.class)\n    @RequestMapping(value = \"{id}\", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Success\", response = APIResponse.class),\n            @ApiResponse(code = 400, message = \"Bad Request\"),\n            @ApiResponse(code = 401, message = \"Unauthorized\"),\n            @ApiResponse(code = 403, message = \"Forbidden\"),\n            @ApiResponse(code = 404, message = \"Not Found\"),\n            @ApiResponse(code = 500, message = \"Failure\")})\n    public ResponseEntity\u003cAPIResponse\u003e updateEntity(@PathVariable(value = \"id\") long id, @RequestBody T entity) {\n\n        LOGGER.debug(\"Inside updateEntity with param \"+entity);\n        T responseEntity = entityService.updateEntity(id, entity);\n        String message;\n        if (Objects.isNull(responseEntity)) {\n            message = \"Entity with id \"+id+\" not found in the database.\";\n            LOGGER.debug(message);\n            APIResponse response = new APIResponse\u003c\u003e(message, HttpStatus.BAD_REQUEST.value(), message);\n            return new ResponseEntity\u003c\u003e(response, HttpStatus.BAD_REQUEST);\n        }\n\n        message = \"Entity Updated successfully.\";\n        APIResponse response = new APIResponse(message, HttpStatus.OK.value(), responseEntity);\n        LOGGER.debug(message);\n        return new ResponseEntity\u003c\u003e(response, HttpStatus.OK);\n    }\n```\n![update_entity](/src/main/resources/images/update_entity.png \"update_entity\")\n\n\n### Partial Update Entity using Http Patch\n\n```java\n@@ApiOperation(value = \"Partial update entity with the given id and the updates.\", response = APIResponse.class)\n     @RequestMapping(value = \"{id}\", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_VALUE)\n     @ApiResponses(value = {\n             @ApiResponse(code = 200, message = \"Success\", response = APIResponse.class),\n             @ApiResponse(code = 400, message = \"Bad Request\"),\n             @ApiResponse(code = 401, message = \"Unauthorized\"),\n             @ApiResponse(code = 403, message = \"Forbidden\"),\n             @ApiResponse(code = 404, message = \"Not Found\"),\n             @ApiResponse(code = 500, message = \"Failure\")})\n     public ResponseEntity\u003cAPIResponse\u003e updatePartialEntity(@PathVariable(value = \"id\") long id, @RequestBody Map\u003cString, Object\u003e updates) {\n\n         LOGGER.debug(\"Inside updatePartialEntity with id \"+id+\" and updates \"+updates);\n         T responseEntity = entityService.partiallyUpdateEntity(id, updates);\n         if (Objects.isNull(responseEntity)) {\n             String message = \"Entity with id \"+id+\" not found in the database.\";\n             LOGGER.debug(message);\n             APIResponse response = new APIResponse\u003c\u003e(message, HttpStatus.BAD_REQUEST.value(), message);\n             return new ResponseEntity\u003c\u003e(response, HttpStatus.BAD_REQUEST);\n         }\n         APIResponse response = new APIResponse(\"Entity partially updated\", HttpStatus.OK.value(), responseEntity);\n         return new ResponseEntity\u003c\u003e(response, HttpStatus.OK);\n     }\n```\n![partial_update_entity](/src/main/resources/images/partial_update_entity.png \"partial_update_entity\")\n\n\n### Delete Entity using Http Delete\n\n```java\n@ApiOperation(value = \"Delete entity with the given id.\", response = APIResponse.class)\n    @RequestMapping(value = \"{id}\", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Success\", response = APIResponse.class),\n            @ApiResponse(code = 400, message = \"Bad Request\"),\n            @ApiResponse(code = 401, message = \"Unauthorized\"),\n            @ApiResponse(code = 403, message = \"Forbidden\"),\n            @ApiResponse(code = 404, message = \"Not Found\"),\n            @ApiResponse(code = 500, message = \"Failure\")})\n    public ResponseEntity\u003cAPIResponse\u003e deleteEntity(@PathVariable(value = \"id\") long id) {\n\n        LOGGER.debug(\"Inside deleteEntity with param \"+id);\n        entityService.deleteEntity(id);\n        String message = \"Entity deleted successfully\";\n        APIResponse response = new APIResponse(message, HttpStatus.OK.value(), message);\n        return new ResponseEntity\u003c\u003e(response, HttpStatus.OK);\n    }\n```\n![delete_entity](/src/main/resources/images/delete_entity.png \"delete_entity\")\n\n\n### Get Entity using Http Get\n\n```java\n@ApiOperation(value = \"Display entity with the given id.\", response = APIResponse.class)\n    @RequestMapping(value = \"{id}\", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Success\", response = APIResponse.class),\n            @ApiResponse(code = 400, message = \"Bad Request\"),\n            @ApiResponse(code = 401, message = \"Unauthorized\"),\n            @ApiResponse(code = 403, message = \"Forbidden\"),\n            @ApiResponse(code = 404, message = \"Not Found\"),\n            @ApiResponse(code = 500, message = \"Failure\")})\n    public ResponseEntity\u003cAPIResponse\u003e displayEntity(@PathVariable(value = \"id\") long id) {\n\n        LOGGER.debug(\"Inside displayEntity with param \"+id);\n        T responseEntity = entityService.getEntity(id);\n\n        if (Objects.isNull(responseEntity)) {\n            String message = \"Entity with id \"+id+\" not found in the database.\";\n            LOGGER.debug(message);\n            APIResponse response = new APIResponse\u003c\u003e(message, HttpStatus.BAD_REQUEST.value(), message);\n            return new ResponseEntity\u003c\u003e(response, HttpStatus.BAD_REQUEST);\n        }\n        String message = \"Entity \"+responseEntity +\" retrieved successfully.\";\n        LOGGER.debug(message);\n        APIResponse response = new APIResponse\u003c\u003e(message, HttpStatus.OK.value(), responseEntity);\n        return new ResponseEntity\u003c\u003e(response, HttpStatus.OK);\n    }\n\n```\n![get_entity](/src/main/resources/images/get_entity.png \"get_entity\")\n\n\n### Get All Entity using Http Get\n\n```java\n@ApiOperation(value = \"List all entities.\", response = APIResponse.class)\n    @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Success\", response = APIResponse.class),\n            @ApiResponse(code = 400, message = \"Bad Request\"),\n            @ApiResponse(code = 401, message = \"Unauthorized\"),\n            @ApiResponse(code = 403, message = \"Forbidden\"),\n            @ApiResponse(code = 404, message = \"Not Found\"),\n            @ApiResponse(code = 500, message = \"Failure\")})\n    public ResponseEntity\u003cAPIResponse\u003e displayAllEntity() {\n\n        LOGGER.debug(\"Inside displayEntity all entity\");\n        List\u003cT\u003e responseEntity = entityService.getAllEntities();\n\n        if (Objects.isNull(responseEntity) || responseEntity.isEmpty()) {\n            String message = \"Entity not found in the database.\";\n            LOGGER.debug(message);\n            APIResponse response = new APIResponse\u003c\u003e(message, HttpStatus.BAD_REQUEST.value(), message);\n            return new ResponseEntity\u003c\u003e(response, HttpStatus.BAD_REQUEST);\n        }\n        String message = \"Entity \"+responseEntity +\" retrieved successfully.\";\n        LOGGER.debug(message);\n        APIResponse response = new APIResponse\u003c\u003e(message, HttpStatus.OK.value(), responseEntity);\n        return new ResponseEntity\u003c\u003e(response, HttpStatus.OK);\n    }\n```\n![get_all_entity](/src/main/resources/images/get_all_entities.png \"get_all_entity\")\n\n### How to create new entities\n\n1. Create the Entity Class, Example Patient\n\n```java\n@Entity\npublic class Patient extends BasicEntity{\n\n\n    @Column(name = \"name\", insertable=true, updatable=false)\n    @ApiModelProperty(notes = \"Name of the patient\")\n    private String name;\n\n    @Column(name = \"address\", insertable=true, updatable=false)\n    @ApiModelProperty(notes = \"Address of the patient\")\n    private String address;\n\n    @Column(name = \"mobile\", insertable=true, updatable=false)\n    @ApiModelProperty(notes = \"Mobile number of the patient\")\n    private String mobile;\n}\n```\n\n2. Create the Repository, Example PatientRepository\n\n```java\n@Repository\npublic interface PatientRepository extends EntityRepository\u003cPatient\u003e {\n}\n```\n\n3. Create the Service, Example PatientService and implement the method, That's the only implementation required.\n\n```java\n@Service\n@Resource(name=\"patientService\")\npublic class PatientService implements EntityService\u003cPatient\u003e\n```\n\n4. Create the Rest Controller, Example PatientController\n\n```java\n@RestController\n@RequestMapping(\"/patients\")\n@Api(value=\"Patient Management System API\", description=\"CRUD operations on Patient.\")\npublic class PatientController extends EntityController\u003cPatient\u003e {\n}\n```\n\n## Now complete, Your Patient Rest API with all the rest api end points are ready.\n![entity_swagger](/src/main/resources/images/entity_swagger.png \"entity_swagger\")\n![patient_swagger](/src/main/resources/images/patient_swagger.png \"patient_swagger\")\n![product_swagger](/src/main/resources/images/product_swagger.png \"product_swagger\")\n![model_swagger](/src/main/resources/images/model_swagger.png \"model_swagger\")\n\n\n\n## How to start ?\n\n```\n$ mvn spring-boot:run\n```\n\n## Swagger-UI\n* After starting the application Click on [Swagger-home](http://localhost:8080/api/swagger-ui.html)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrohitramsen%2Fems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frrohitramsen%2Fems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrohitramsen%2Fems/lists"}