Реализация книги

This commit is contained in:
Филиппов Александр 2017-11-30 17:51:40 +07:00
parent ebbd7c60ab
commit c42cfd18b2
6 changed files with 212 additions and 140 deletions

7
.idea/dictionaries/afilippov.xml generated Normal file
View File

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="afilippov">
<words>
<w>succeful</w>
</words>
</dictionary>
</component>

205
.idea/workspace.xml generated
View File

@ -1,69 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="6452b13b-5b16-420c-9e2d-0c40791a2ae8" name="Default" comment="Init commit">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/compiler.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/encodings.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_11.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_11.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_10.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_10.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_2_0.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__junit_junit_4_12.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__log4j_log4j_1_2_17.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__net_minidev_accessors_smart_1_1.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__net_minidev_json_smart_2_2_1.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_23.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_23.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_23.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_tomcat_annotations_api_8_5_23.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_assertj_assertj_core_2_6_0.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hibernate_hibernate_validator_5_3_6_Final.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_1_Final.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_mockito_mockito_core_1_10_19.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_objenesis_objenesis_2_1.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_ow2_asm_asm_5_0_3.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_4_0.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_25.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_log4j_over_slf4j_1_7_25.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_1_5_9_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_aop_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_beans_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_context_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_core_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_expression_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_test_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_web_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_13_RELEASE.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_yaml_snakeyaml_1_17.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/modules.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/pom.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/restServer.iml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/Main.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/main/resources/log4j.properties" />
<list default="true" id="6452b13b-5b16-420c-9e2d-0c40791a2ae8" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/dictionaries/afilippov.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/BookStatus.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java" afterPath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java" afterPath="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<ignored path="$PROJECT_DIR$/target/" />
@ -148,11 +91,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
<file leaf-file-name="Main.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="24" lean-forward="false" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
<state relative-caret-position="255">
<caret line="15" column="0" lean-forward="true" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -163,8 +106,8 @@
<file leaf-file-name="EmailBookController.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="24" lean-forward="false" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
<state relative-caret-position="221">
<caret line="13" column="0" lean-forward="false" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -172,16 +115,46 @@
</provider>
</entry>
</file>
<file leaf-file-name="EmailBook.java" pinned="false" current-in-tab="false">
<file leaf-file-name="EmailRecord.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailRecord.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="24" lean-forward="false" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" />
<folding>
<element signature="e#292#293#0" expanded="true" />
<element signature="e#317#318#0" expanded="true" />
<element signature="e#351#352#0" expanded="true" />
<element signature="e#379#380#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="BookStatus.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/BookStatus.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459">
<caret line="27" column="16" lean-forward="false" selection-start-line="27" selection-start-column="16" selection-end-line="27" selection-end-column="16" />
<folding>
<element signature="e#147#148#0" expanded="true" />
<element signature="e#177#178#0" expanded="true" />
<element signature="e#486#487#0" expanded="true" />
<element signature="e#515#516#0" expanded="true" />
<element signature="e#560#561#0" expanded="true" />
<element signature="e#596#597#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="EmailBook.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="235">
<caret line="17" column="4" lean-forward="false" selection-start-line="17" selection-start-column="4" selection-end-line="17" selection-end-column="4" />
<state relative-caret-position="459">
<caret line="27" column="75" lean-forward="true" selection-start-line="27" selection-start-column="75" selection-end-line="27" selection-end-column="75" />
<folding>
<element signature="e#288#289#0" expanded="true" />
<element signature="e#313#314#0" expanded="true" />
<element signature="e#347#348#0" expanded="true" />
<element signature="e#375#376#0" expanded="true" />
<element signature="e#915#916#0" expanded="true" />
<element signature="e#954#955#0" expanded="true" />
</folding>
</state>
</provider>
@ -208,12 +181,14 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/emailBook.java" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java" />
<option value="$PROJECT_DIR$/src/main/resources/log4j.properties" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/Main.java" />
<option value="$PROJECT_DIR$/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailRecord.java" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/BookStatus.java" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java" />
<option value="$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java" />
</list>
</option>
</component>
@ -331,15 +306,6 @@
</option>
</component>
<component name="RunManager" selected="Application.runServer">
<configuration name="Jetty" type="JettyRunner-By-GuiKeller" factoryName="Jetty Runner">
<option name="JettyRunnerV112-WebAppPath" value="/restServer" />
<option name="JettyRunnerV112-WebAppFolder" value="" />
<option name="JettyRunnerV112-ClassesDirectory" value="C:\Users\afilippov\IdeaProjects\restServer\target\classes" />
<option name="JettyRunnerV112-RunOnPort" value="8080" />
<option name="JettyRunnerV112-JettyXML" value="" />
<option name="JettyRunnerV112-VmArgs" value="" />
<option name="JettyRunnerV112-PassParentEnvVars" value="true" />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
@ -435,10 +401,6 @@
<module name="restServer" />
<envs />
</configuration>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="Application.runServer" />
<item index="1" class="java.lang.String" itemvalue="Jetty Runner.Jetty" />
</list>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
@ -458,7 +420,14 @@
<option name="project" value="LOCAL" />
<updated>1512033510258</updated>
</task>
<option name="localTasksCounter" value="2" />
<task id="LOCAL-00002" summary="Init commit">
<created>1512034509917</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1512034509917</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="ToolWindowManager">
@ -468,7 +437,7 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32976446" sideWeight="0.4936034" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32976446" sideWeight="0.50959486" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32976446" sideWeight="0.50959486" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32995737" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.254818" sideWeight="0.4978678" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32976446" sideWeight="0.4904051" order="7" side_tool="false" content_ui="tabs" />
@ -631,35 +600,61 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="235">
<caret line="17" column="4" lean-forward="false" selection-start-line="17" selection-start-column="4" selection-end-line="17" selection-end-column="4" />
<state relative-caret-position="255">
<caret line="15" column="0" lean-forward="true" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
<folding>
<element signature="e#288#289#0" expanded="true" />
<element signature="e#313#314#0" expanded="true" />
<element signature="e#347#348#0" expanded="true" />
<element signature="e#375#376#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailRecord.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="24" lean-forward="false" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" />
<folding>
<element signature="e#292#293#0" expanded="true" />
<element signature="e#317#318#0" expanded="true" />
<element signature="e#351#352#0" expanded="true" />
<element signature="e#379#380#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/BookStatus.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459">
<caret line="27" column="16" lean-forward="false" selection-start-line="27" selection-start-column="16" selection-end-line="27" selection-end-column="16" />
<folding>
<element signature="e#147#148#0" expanded="true" />
<element signature="e#177#178#0" expanded="true" />
<element signature="e#486#487#0" expanded="true" />
<element signature="e#515#516#0" expanded="true" />
<element signature="e#560#561#0" expanded="true" />
<element signature="e#596#597#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBookController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="24" lean-forward="false" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
<state relative-caret-position="221">
<caret line="13" column="0" lean-forward="false" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/Main.java">
<entry file="file://$PROJECT_DIR$/src/main/java/ru/cft/task/restServer/EmailBook.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="24" lean-forward="false" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
<state relative-caret-position="459">
<caret line="27" column="75" lean-forward="true" selection-start-line="27" selection-start-column="75" selection-end-line="27" selection-end-column="75" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#915#916#0" expanded="true" />
<element signature="e#954#955#0" expanded="true" />
</folding>
</state>
</provider>

View File

@ -0,0 +1,31 @@
package ru.cft.task.restServer;
public class BookStatus {
private boolean status;
private String message;
public String getMessage() {
return message;
}
public BookStatus setMessage(String message) {
this.message = message;
this.status = true;
return this;
}
public BookStatus setError(String message) {
this.message = message;
this.status = false;
return this;
}
public boolean isValid() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
}

View File

@ -1,41 +1,35 @@
package ru.cft.task.restServer;
import java.util.HashMap;
public class EmailBook {
private long id;
private String name;
private String email;
private HashMap<Long, EmailRecord> book;
private BookStatus status;
public EmailBook(long id, String name, String email) {
setId(id);
setName(name);
setEmail(email);
public EmailBook() {
this.book = new HashMap();
this.status.setStatus(true);
}
public long getId() {
return id;
public BookStatus addRecord(EmailRecord rec) {
if (!this.book.containsKey(rec.getId())) {
this.book.put(rec.getId(), rec);
return this.status.setMessage("Запись успешно добавлена");
}else{
return this.status.setError("Запись с таким id уже существует");
}
}
public void setId(long id) {
this.id = id;
public BookStatus removeRecord(Long id) {
if (!this.book.containsKey(id)) {
this.book.remove(id);
return this.status.setMessage("Запись успешно удалена");
}else{
return this.status.setError("Записи с таким id не существует");
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String toString(){
return String.valueOf(getId()).concat(": ").concat(getName()).concat(" - ").concat(getEmail());
public int count() {
return this.book.size();
}
}

View File

@ -2,6 +2,7 @@ package ru.cft.task.restServer;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.atomic.AtomicLong;
@ -10,12 +11,15 @@ import java.util.concurrent.atomic.AtomicLong;
public class EmailBookController {
final static Logger log = Logger.getLogger(EmailBookController.class);
private final AtomicLong new_id = new AtomicLong();
private EmailBook book = new EmailBook();
@RequestMapping("/email")
public EmailBook emailRec(@RequestParam(value = "name", defaultValue = "John Unknown") String name,
@RequestParam(value = "email", defaultValue = "john@unknown.ru") String email) {
EmailBook emailBook = new EmailBook(new_id.incrementAndGet(), name, email);
log.debug(emailBook.toString());
return emailBook;
@RequestMapping(value = "/email", method = RequestMethod.POST)
public BookStatus emailRec(@RequestParam(value = "name", defaultValue = "John Unknown") String name,
@RequestParam(value = "email", defaultValue = "john@unknown.ru") String email) {
EmailRecord rec = new EmailRecord(new_id.incrementAndGet(), name, email);
return this.book.addRecord(rec);
}
//@RequestMapping(value = "/email", method = RequestMethod.DELETE)
//public em
}

View File

@ -0,0 +1,41 @@
package ru.cft.task.restServer;
public class EmailRecord {
private long id;
private String name;
private String email;
public EmailRecord(long id, String name, String email) {
setId(id);
setName(name);
setEmail(email);
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String toString() {
return String.valueOf(getId()).concat(": ").concat(getName()).concat(" - ").concat(getEmail());
}
}