#Task
Need to realize a console CRUD app, which contains the next entities:
Writer (id,name,List<Post> posts)
Post(id,content,List<Tag> tags, PostStatus status)
Tag(id,name)
PostStatus(enum ACTIVE,DELETED)Entities shall be stored in the next text files:
writers.json, posts.json, tags.json
User shall be able to create, to get, to update and to delete data with console commands.
Layers:
model- POJO classesrepository- classes for access to the text filescontroller- classes for user requestsview- all data for console work
Examples are: Writer, WriterRepository, WriterController, WriterView, etc.
Basic interface shall be used for repository layer:
interface GenericRepository<T, ID>;
interface WriterRepository extends GenericRepository<Writer,Long>
class GsonWriterRepositoryImpl implements WriterRepositoryTask result shall be a separate repository with a README.md file, which contains:
- a task description,
- a project
- and instruction for the app run with console (showed below).
Gson library shall be used for work with JSON.
Maven or Gradle shall be used for dependency injection.
#Instruction
- Download the project
- Open in
Intellij IDEA - Run
src/main/java/view/ConsoleRun.java
In this app you can:
- Create new writer. After creation, it will be stored in
writer.jsonfile. - Change writer's name or delete writer
- Create new post with tags. After creation, it will be stored in
post.jsonandwriter.json(in writer object) files. - Anything else what you can found in submenus (presented below)
You can find it in src/main/java/view package
or look at ViewsPlan.mmd, ViewsPlan.md or ViewsPlan.png in the root package.
From author: It is my first console crud app. It was several times rewrote. Here is many logical mistakes in app 'architecture'. Some methods can be described but never be used.
The main mistake is storage list of posts in writers.json and list of tags list in posts.json instead of their id.
But it works :)