1
2
3
4
5 package gboat2.web.action;
6
7 import gboat2.base.core.web.BaseActionSupport;
8 import gboat2.base.core.web.JsonResultSupport;
9 import gboat2.base.bridge.GboatAppContext;
10 import gboat2.web.Constants;
11 import gboat2.web.business.IProfileBusiness;
12 import gboat2.web.model.Profile;
13
14 import org.apache.commons.lang3.StringUtils;
15 import org.springframework.beans.factory.annotation.Autowired;
16
17
18
19
20
21
22
23
24
25 public class ProfileAction extends BaseActionSupport {
26
27
28
29 private static final long serialVersionUID = 1L;
30
31 private String theme;
32
33 private String stretch;
34
35 private String wallpaper;
36
37 @Autowired
38 private IProfileBusiness profileService;
39
40 public String saveOrUpdateProfile() {
41 String userId = GboatAppContext.getUserSession().getUserId();
42 Profile profile = profileService.getProfileByUserId(userId);
43
44 if(null != profile) {
45 if(StringUtils.isNotEmpty(theme)) {
46 profile.setTheme(theme);
47 }
48 if(StringUtils.isNotEmpty(stretch)) {
49 profile.setStretch(stretch);
50 }
51 if(StringUtils.isNotEmpty(wallpaper)) {
52 profile.setWallPaper(wallpaper);
53 }
54 profileService.update(profile);
55 } else {
56 profile = new Profile();
57 profile.setUserId(userId);
58 if(StringUtils.isNotEmpty(theme)) {
59 profile.setTheme(theme);
60 } else {
61 profile.setTheme(Constants.DEFAULT_THEME);
62 }
63 if(StringUtils.isNotEmpty(stretch)) {
64 profile.setStretch(stretch);
65 } else {
66 profile.setStretch("0");
67 }
68 if(StringUtils.isNotEmpty(wallpaper)) {
69 profile.setWallPaper(wallpaper);
70 } else {
71 profile.setWallPaper(Constants.DEFAULT_WALLPAPER);
72 }
73 profileService.save(profile);
74 }
75 JsonResultSupport.outputSuccess();
76 return null;
77 }
78
79 public String getStretch() {
80 return stretch;
81 }
82
83 public void setStretch(String stretch) {
84 this.stretch = stretch;
85 }
86
87 public String getTheme() {
88 return theme;
89 }
90
91 public void setTheme(String theme) {
92 this.theme = theme;
93 }
94
95 public String getWallpaper() {
96 return wallpaper;
97 }
98
99 public void setWallpaper(String wallpaper) {
100 this.wallpaper = wallpaper;
101 }
102
103 }