use of com.topcom.cms.yuqing.domain.UserStyle in project topcom-cloud by 545314690.
the class UserStyleController method setGroupUserStyle.
@ApiOperation("group保存userStyle")
@RequestMapping(value = { "setGroupUserStyle" }, method = { RequestMethod.POST }, produces = { "application/json" }, consumes = { "application/json" })
@ResponseBody
public UserStyle setGroupUserStyle(@RequestBody UserStyle userStyle) {
UserStyle us = this.userStyleManager.findByGroupId(userStyle.getGroupId());
if (us == null) {
Date date = new Date();
userStyle.setDateCreated(date);
userStyle.setDateModified(date);
userStyle = this.manager.save(userStyle);
return userStyle;
} else {
userStyle.setId(us.getId());
userStyle.setDateModified(new Date());
userStyle = this.manager.save(userStyle);
return userStyle;
}
}
use of com.topcom.cms.yuqing.domain.UserStyle in project topcom-cloud by 545314690.
the class UserStyleController method findAllGroupAndUsersyle.
@ApiOperation("查询group列表")
@RequestMapping(value = { "findAllGroupAndUsersyle" }, method = { RequestMethod.POST }, produces = { "application/json" }, consumes = { "application/json" })
@ResponseBody
public Page findAllGroupAndUsersyle(@RequestBody PageRequest page) {
Page<Group> groupPage = groupManager.findAll(page.pageable());
List<GroupStyle> contentList = new ArrayList<>();
for (Group group : groupPage.getContent()) {
Long groupId = group.getId();
UserStyle userStyle = this.userStyleManager.findByGroupId(groupId);
GroupStyle groupStyle;
if (userStyle != null) {
groupStyle = new GroupStyle(group, userStyle);
} else {
groupStyle = new GroupStyle(group);
}
contentList.add(groupStyle);
}
Page result = new AggPageImpl<>(contentList, groupPage.getTotalPages(), groupPage.getTotalElements(), page.pageable());
return result;
}
use of com.topcom.cms.yuqing.domain.UserStyle in project topcom-cloud by 545314690.
the class UserStyleController method addUserStyleToGroup.
private GroupStyle addUserStyleToGroup(Group group) {
Long groupId = group.getId();
UserStyle userStyle = this.userStyleManager.findByGroupId(groupId);
GroupStyle result = new GroupStyle(group, userStyle);
// result.put("text",group.getText());
return result;
}
use of com.topcom.cms.yuqing.domain.UserStyle in project topcom-cloud by 545314690.
the class UserStyleController method updateGroupAndStyle.
@ApiOperation("更新group列表")
@RequestMapping(value = { "updateGroupAndStyle" }, method = { RequestMethod.POST }, produces = { "application/json" }, consumes = { "application/json" })
@ResponseBody
public GroupStyle updateGroupAndStyle(@RequestBody GroupStyle groupStyle) {
Group group = groupStyle.getGroup();
UserStyle style = groupStyle.getStyle();
groupManager.saveGroup(group);
if (style != null) {
style.setGroupId(group.getId());
UserStyle userStyle = this.setGroupUserStyle(style);
groupStyle.setStyle(userStyle);
// userStyleManager.save(style);
}
return groupStyle;
}
use of com.topcom.cms.yuqing.domain.UserStyle in project topcom-cloud by 545314690.
the class UserStyleController method findUserStyleByUser.
/**
* 当user的userStyle不存在的时候返回group的
* @param user
* @param request
* @param response
* @return
*/
@ApiOperation("findUserStyleByUser")
@RequestMapping(value = { "findUserStyleByUser" }, method = { RequestMethod.GET })
@ResponseBody
public UserStyle findUserStyleByUser(@CurrentUser User user, HttpServletRequest request, HttpServletResponse response) {
UserStyle userStyle = this.userStyleManager.findByUserId(user.getId());
user = userManager.findById(user.getId());
if (userStyle == null) {
Set<Group> groups = user.getGroups();
if (groups == null || groups.isEmpty()) {
return null;
}
Group group = groups.iterator().next();
userStyle = this.userStyleManager.findByGroupId(group.getId());
}
return userStyle;
}
Aggregations