Search in sources :

Example 1 with UserStyle

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;
    }
}
Also used : UserStyle(com.topcom.cms.yuqing.domain.UserStyle) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with 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;
}
Also used : UserStyle(com.topcom.cms.yuqing.domain.UserStyle) Group(com.topcom.cms.domain.Group) AggPageImpl(com.topcom.cms.es.vo.AggPageImpl) GroupStyle(com.topcom.cms.yuqing.vo.request.GroupStyle) ArrayList(java.util.ArrayList) Page(org.springframework.data.domain.Page) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with UserStyle

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;
}
Also used : UserStyle(com.topcom.cms.yuqing.domain.UserStyle) GroupStyle(com.topcom.cms.yuqing.vo.request.GroupStyle)

Example 4 with UserStyle

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;
}
Also used : UserStyle(com.topcom.cms.yuqing.domain.UserStyle) Group(com.topcom.cms.domain.Group) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with UserStyle

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;
}
Also used : UserStyle(com.topcom.cms.yuqing.domain.UserStyle) Group(com.topcom.cms.domain.Group) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

UserStyle (com.topcom.cms.yuqing.domain.UserStyle)6 ApiOperation (io.swagger.annotations.ApiOperation)5 Group (com.topcom.cms.domain.Group)3 GroupStyle (com.topcom.cms.yuqing.vo.request.GroupStyle)2 Date (java.util.Date)2 AggPageImpl (com.topcom.cms.es.vo.AggPageImpl)1 ArrayList (java.util.ArrayList)1 Page (org.springframework.data.domain.Page)1