From 65927a06cd8882fd915cd62af0b77811c6977b1f Mon Sep 17 00:00:00 2001 From: evan Date: Wed, 18 Oct 2017 20:23:18 +1100 Subject: [PATCH 1/2] asdf --- Dockerfile | 4 ++-- evan | 1 + out/production/classes/hello/Application.class | Bin 0 -> 2209 bytes .../classes/hello/HelloController.class | Bin 0 -> 595 bytes out/test/classes/hello/HelloControllerIT.class | Bin 0 -> 2381 bytes out/test/classes/hello/HelloControllerTest.class | Bin 0 -> 2536 bytes 6 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 evan create mode 100644 out/production/classes/hello/Application.class create mode 100644 out/production/classes/hello/HelloController.class create mode 100644 out/test/classes/hello/HelloControllerIT.class create mode 100644 out/test/classes/hello/HelloControllerTest.class diff --git a/Dockerfile b/Dockerfile index 31adc77..89ba190 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM openjdk:8-jdk-alpine -VOLUME /tmp -ADD build/docker/target/spring-boot-microservice-1.0-SNAPSHOT.jar app.jar + +ADD target/spring-boot-microservice-1.0-SNAPSHOT.jar app.jar ENV JAVA_OPTS="" ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] \ No newline at end of file diff --git a/evan b/evan new file mode 100644 index 0000000..2363607 --- /dev/null +++ b/evan @@ -0,0 +1 @@ +er diff --git a/out/production/classes/hello/Application.class b/out/production/classes/hello/Application.class new file mode 100644 index 0000000000000000000000000000000000000000..df3b6d1bc98d1d4f3d932a8fa8b305032d9a4093 GIT binary patch literal 2209 zcmb7FT~`}b6x}x@ObDq^Xh5oBtkfncFtk=$o7xI#vDH9pgVc|;TeEb@O1_m6b+Oz zxQzJ;%C3yyD&9}yS_U6rc@)=iBZCid(?D5Z_?G2Z!EJ$|LUBtVS#g_6V6196YNOk( zD{oWQZAvDpZbRBz(zEorCrk!AmM<__-BGsfnk$`-Z8ce0G}H8EQ>1E z8MV*e!}?Qt6Igt;HsuWTeY|8vGr{g;+5oIORbdFt8R!Ezao) zOQ8on7K36vXXOkw@Gye}9vw@*cHjr9O(1TU6yzctmTNxZv<4h|CEM)oDAVI&0YjHO zu$e$EoXRc5jkl+!rZeZEwis#7#swREcBedfWQjetK zmVwW+c#N$q-o#r17y2c!oIQ6}nbmME*;;a2HUif>5EyOuPX@l^Yg%>P-EK!9`#`^0 z6NKvz0#=8J1(^>t!F495dWJ=%~2*|G$hvo^D$_8MY#AyJiKd zY~U+_izoOQl#jsd>3VpFjg;Y!6p#c7MV8+)Jegbt*Hq~@h@ZJh;5B}SLtz$U+-p@T zU>s+;j$i_llxX8+YU{i7M51(vp(lNN-M65%L94!xG|nMMIhzC1)X+Z4JZW9y@-sri zPu#{KoD0pTB9$HlD&uv`(C|F9HPknN@r-V$p3_6F2JdeCg4D$DuP{o#BQ3B#e~6L! zjfLmS$)V*`E|p9Efa!%?>gvs5D$Z!d?^EK(7k}wQhC(7{LqAhUGvXLyPBLbZ@vd;a zj@b}hiNK50n8n*f!>A!TZn)D4^LL*2dF~Rd18A9eL9oLHE*N+>`V-{wZ{E!DURUTM kzwdFMz$HqfEDKz};D3hqH9Wy4@htGH3$#eQCYE6S3ql1^vj6}9 literal 0 HcmV?d00001 diff --git a/out/production/classes/hello/HelloController.class b/out/production/classes/hello/HelloController.class new file mode 100644 index 0000000000000000000000000000000000000000..2955dd10b86e1e69d848e9a292f463ef440a446b GIT binary patch literal 595 zcmb7BO-lnY5Pj*l^}Duy;HAB(pt*Pu6hRB>VO6lwi>GW&Yw9+s*=+02(v#r9AK;G? zCv8y?FD_(;mwE5aWcK~z^$ox-){4lWQowQ^D|xIkZoFR>dB^x6}cX1ZJcn*XfoXkjP3Ba@2PDodU9y&Js--Dhh)md z7nfhjheXEiT=e^6+w4F@3C+wnL$P5J+ma{BKcf6=!W}=;|60ZF#{*}OMUG+p)Jo~7 zcU)~-)2lW{LsyTDaW#g@pUYub_+H3m*p)4Z8q)N4{Fegl4mpZ>LYy+AoZWf>dmfbw z6nz;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ITLz?Zd*s>lqUZ1M&VLqXXzP)OQizFSJBTWxZ zqbbe?wQb9*>`~iFDriIlNw}FvLWJrElVQSe8Y>4~>Ou^=iL*Eq%cL)HgqPGRVf%H6 zb|tC9BFZQ=SjinZ;=V@~&jtRsjgCq8sLPzBTA@Z`*fp17Zn(FMG?JHLWbRZ|7ORQg zvllinhGG=jS7;K}-iWV@xI%w18TzYXNClr2n%|~XmgaLbr)Z`x4vpt&rPIu49-I3U z?6>gv0*%3C5bPq2T66)^xI`<4_XwO0!QKA7g}FbF%B9oKkvYOx<~g!Y(!WEg9%B3u z6Gu=FapoDc6prvl?#&~dJ;Y?V-X1XKLdnx){Sxvt-o@o1_JuzCWm1qK4ey`0G($Tn Zayb~UhPzXw?i$^>ZsG%cNCzJQF90y79oPT> literal 0 HcmV?d00001 From d3032a4bc863f227a3454b58020edf9eb22208fb Mon Sep 17 00:00:00 2001 From: evan Date: Thu, 19 Oct 2017 20:01:26 +1100 Subject: [PATCH 2/2] added new service to update user information, get user by id, and delete user --- .../classes/hello/Application.class | Bin 2209 -> 0 bytes .../classes/hello/HelloController.class | Bin 595 -> 0 bytes .../classes/hello/HelloControllerIT.class | Bin 2381 -> 0 bytes .../classes/hello/HelloControllerTest.class | Bin 2536 -> 0 bytes .../controller/UserController.java | 23 ++++++++++++++++++ src/main/resources/application.properties | 5 ++-- 6 files changed, 25 insertions(+), 3 deletions(-) delete mode 100644 out/production/classes/hello/Application.class delete mode 100644 out/production/classes/hello/HelloController.class delete mode 100644 out/test/classes/hello/HelloControllerIT.class delete mode 100644 out/test/classes/hello/HelloControllerTest.class diff --git a/out/production/classes/hello/Application.class b/out/production/classes/hello/Application.class deleted file mode 100644 index df3b6d1bc98d1d4f3d932a8fa8b305032d9a4093..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2209 zcmb7FT~`}b6x}x@ObDq^Xh5oBtkfncFtk=$o7xI#vDH9pgVc|;TeEb@O1_m6b+Oz zxQzJ;%C3yyD&9}yS_U6rc@)=iBZCid(?D5Z_?G2Z!EJ$|LUBtVS#g_6V6196YNOk( zD{oWQZAvDpZbRBz(zEorCrk!AmM<__-BGsfnk$`-Z8ce0G}H8EQ>1E z8MV*e!}?Qt6Igt;HsuWTeY|8vGr{g;+5oIORbdFt8R!Ezao) zOQ8on7K36vXXOkw@Gye}9vw@*cHjr9O(1TU6yzctmTNxZv<4h|CEM)oDAVI&0YjHO zu$e$EoXRc5jkl+!rZeZEwis#7#swREcBedfWQjetK zmVwW+c#N$q-o#r17y2c!oIQ6}nbmME*;;a2HUif>5EyOuPX@l^Yg%>P-EK!9`#`^0 z6NKvz0#=8J1(^>t!F495dWJ=%~2*|G$hvo^D$_8MY#AyJiKd zY~U+_izoOQl#jsd>3VpFjg;Y!6p#c7MV8+)Jegbt*Hq~@h@ZJh;5B}SLtz$U+-p@T zU>s+;j$i_llxX8+YU{i7M51(vp(lNN-M65%L94!xG|nMMIhzC1)X+Z4JZW9y@-sri zPu#{KoD0pTB9$HlD&uv`(C|F9HPknN@r-V$p3_6F2JdeCg4D$DuP{o#BQ3B#e~6L! zjfLmS$)V*`E|p9Efa!%?>gvs5D$Z!d?^EK(7k}wQhC(7{LqAhUGvXLyPBLbZ@vd;a zj@b}hiNK50n8n*f!>A!TZn)D4^LL*2dF~Rd18A9eL9oLHE*N+>`V-{wZ{E!DURUTM kzwdFMz$HqfEDKz};D3hqH9Wy4@htGH3$#eQCYE6S3ql1^vj6}9 diff --git a/out/production/classes/hello/HelloController.class b/out/production/classes/hello/HelloController.class deleted file mode 100644 index 2955dd10b86e1e69d848e9a292f463ef440a446b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 595 zcmb7BO-lnY5Pj*l^}Duy;HAB(pt*Pu6hRB>VO6lwi>GW&Yw9+s*=+02(v#r9AK;G? zCv8y?FD_(;mwE5aWcK~z^$ox-){4lWQowQ^D|xIkZoFR>dB^x6}cX1ZJcn*XfoXkjP3Ba@2PDodU9y&Js--Dh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A?#_|o0C1aFYp>^;k|yrY#e_O4(zA*VCDSU(6%MpL^;+oY@hJA zW8)GA*(90#KAFCHGG4jf|7^$0>jim`$-uvEXT3&ZzV!3Qpme!tx}w9dmycEZN;+PO zdqVk}-1BW&FvFfhAulA7DMHks+5#ITLz?Zd*s>lqUZ1M&VLqXXzP)OQizFSJBTWxZ zqbbe?wQb9*>`~iFDriIlNw}FvLWJrElVQSe8Y>4~>Ou^=iL*Eq%cL)HgqPGRVf%H6 zb|tC9BFZQ=SjinZ;=V@~&jtRsjgCq8sLPzBTA@Z`*fp17Zn(FMG?JHLWbRZ|7ORQg zvllinhGG=jS7;K}-iWV@xI%w18TzYXNClr2n%|~XmgaLbr)Z`x4vpt&rPIu49-I3U z?6>gv0*%3C5bPq2T66)^xI`<4_XwO0!QKA7g}FbF%B9oKkvYOx<~g!Y(!WEg9%B3u z6Gu=FapoDc6prvl?#&~dJ;Y?V-X1XKLdnx){Sxvt-o@o1_JuzCWm1qK4ey`0G($Tn Zayb~UhPzXw?i$^>ZsG%cNCzJQF90y79oPT> diff --git a/src/main/java/spaceshuttle/controller/UserController.java b/src/main/java/spaceshuttle/controller/UserController.java index 7cab56e..66b9383 100644 --- a/src/main/java/spaceshuttle/controller/UserController.java +++ b/src/main/java/spaceshuttle/controller/UserController.java @@ -5,6 +5,8 @@ import spaceshuttle.model.User; import spaceshuttle.repository.UserRepository; +import java.util.List; + @RestController @RequestMapping(path = "/users") // This means URL's start with /user (after Application path) @@ -46,4 +48,25 @@ User addUser(@RequestBody User newUser) { // @RequestParam means it is a parameter from the GET or POST request return userRepository.save(newUser); } + + @GetMapping("user") + public @ResponseBody + Iterable getUserByID(@RequestParam String username){ + return userRepository.findByUsername(username); + } + + @PutMapping("save") + public @ResponseBody + String updateUser(@RequestBody User user) { + user = userRepository.save(user); + return "update successfully"; + } + + @DeleteMapping("delete") + public @ResponseBody + String deleteUser(@RequestParam String username){ + Iterable user = userRepository.findByUsername(username); + userRepository.delete(user); + return "delete successfully"; + } } \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a96e416..a5c9368 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,5 @@ #spring.jpa.hibernate.ddl-auto=create spring.jpa.hibernate.ddl-auto=update spring.datasource.url=jdbc:mysql://localhost:3306/spaceshuttle -spring.datasource.username=spaceshuttle -spring.datasource.password=spaceshuttle -thisisgood=true \ No newline at end of file +spring.datasource.username=root +spring.datasource.password=