1
1
package com .boylegu .springboot_vue .controller ;
2
2
3
3
import com .boylegu .springboot_vue .entities .Persons ;
4
- import org . springframework . beans . factory . annotation . Autowired ;
4
+
5
5
import org .springframework .web .bind .annotation .RequestMapping ;
6
6
import org .springframework .web .bind .annotation .RequestMethod ;
7
7
import org .springframework .web .bind .annotation .RequestParam ;
8
8
import org .springframework .web .bind .annotation .RestController ;
9
+ import org .springframework .web .bind .annotation .PathVariable ;
9
10
import org .springframework .beans .factory .annotation .Value ;
11
+ import org .springframework .beans .factory .annotation .Autowired ;
10
12
import org .springframework .http .ResponseEntity ;
11
13
import org .springframework .http .HttpStatus ;
12
14
import org .springframework .http .MediaType ;
@@ -32,7 +34,7 @@ public class MainController {
32
34
@ Value (("${com.boylegu.paginatio.max-per-page}" ))
33
35
Integer maxPerPage ;
34
36
35
- @ RequestMapping (value = "/sex" , method = RequestMethod .GET )
37
+ @ RequestMapping (value = "/sex" , method = RequestMethod .GET , produces = MediaType . APPLICATION_JSON_VALUE )
36
38
public ResponseEntity <?> getSexAll () {
37
39
38
40
/*
@@ -116,4 +118,32 @@ public Map<String, PaginationMultiTypeValuesHelper> getPersonsAll(
116
118
return paginInstance .filterQuery (sex , email , pageable );
117
119
}
118
120
121
+ @ RequestMapping (value = "/detail/{id}" , method = RequestMethod .GET , produces = MediaType .APPLICATION_JSON_VALUE )
122
+ public ResponseEntity <Persons > getUser (@ PathVariable Long id ) {
123
+
124
+ /*
125
+ * @api {GET} /api/persons/detail/:id details info
126
+ * @apiName GetPersonDetails
127
+ * @apiGroup Info Manage
128
+ * @apiVersion 1.0.0
129
+ *
130
+ * @apiExample {httpie} Example usage:
131
+ *
132
+ * http /api/persons/detail/1
133
+ *
134
+ * @apiSuccess {String} email
135
+ * @apiSuccess {String} id
136
+ * @apiSuccess {String} phone
137
+ * @apiSuccess {String} sex
138
+ * @apiSuccess {String} username
139
+ * @apiSuccess {String} zone
140
+ */
141
+
142
+
143
+ Persons user = personsRepository .findById (id );
144
+
145
+ return new ResponseEntity <>(user , HttpStatus .OK );
146
+ }
147
+
148
+
119
149
}
0 commit comments