forked from Realhedin/topjava02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfileRestController.java
More file actions
43 lines (35 loc) · 1.34 KB
/
ProfileRestController.java
File metadata and controls
43 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package ru.javawebinar.topjava.web.user;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ru.javawebinar.topjava.LoggedUser;
import ru.javawebinar.topjava.model.User;
import ru.javawebinar.topjava.to.UserTo;
/**
* GKislin
* 06.03.2015.
*/
@RestController
@RequestMapping(ProfileRestController.REST_URL)
public class ProfileRestController extends AbstractUserController {
public static final String REST_URL = "/rest/profile";
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public User get() {
return super.get(LoggedUser.id());
}
@RequestMapping(method = RequestMethod.DELETE)
public void delete() {
super.delete(LoggedUser.id());
}
@RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void update(@RequestBody UserTo userTo) {
LoggedUser.get().updateUserTo(userTo);
super.update(userTo, LoggedUser.id());
}
@RequestMapping(value = "/text", method = RequestMethod.GET)
public String testUTF() {
return "Русский текст";
}
}