11package  com .boylegu .springboot_vue .controller ;
22
33import  com .boylegu .springboot_vue .entities .Persons ;
4- import   org . springframework . beans . factory . annotation . Autowired ; 
4+ 
55import  org .springframework .web .bind .annotation .RequestMapping ;
66import  org .springframework .web .bind .annotation .RequestMethod ;
77import  org .springframework .web .bind .annotation .RequestParam ;
88import  org .springframework .web .bind .annotation .RestController ;
9+ import  org .springframework .web .bind .annotation .PathVariable ;
910import  org .springframework .beans .factory .annotation .Value ;
11+ import  org .springframework .beans .factory .annotation .Autowired ;
1012import  org .springframework .http .ResponseEntity ;
1113import  org .springframework .http .HttpStatus ;
1214import  org .springframework .http .MediaType ;
@@ -32,7 +34,7 @@ public class MainController {
3234    @ Value (("${com.boylegu.paginatio.max-per-page}" ))
3335    Integer  maxPerPage ;
3436
35-     @ RequestMapping (value  = "/sex" , method  = RequestMethod .GET )
37+     @ RequestMapping (value  = "/sex" , method  = RequestMethod .GET ,  produces  =  MediaType . APPLICATION_JSON_VALUE )
3638    public  ResponseEntity <?> getSexAll () {
3739
3840        /* 
@@ -116,4 +118,32 @@ public Map<String, PaginationMultiTypeValuesHelper> getPersonsAll(
116118        return  paginInstance .filterQuery (sex , email , pageable );
117119    }
118120
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+ 
119149}
0 commit comments