Search in sources :

Example 6 with Group

use of com.topcom.cms.domain.Group 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 7 with Group

use of com.topcom.cms.domain.Group 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 8 with Group

use of com.topcom.cms.domain.Group 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)

Example 9 with Group

use of com.topcom.cms.domain.Group in project topcom-cloud by 545314690.

the class GroupController method checkModuleName.

@RequestMapping(value = "/checkGroupName", method = RequestMethod.POST)
@ResponseBody
public Map<String, Boolean> checkModuleName(HttpServletRequest request) {
    Map<String, Boolean> ret = new HashMap<>();
    ret.put("success", true);
    String name = request.getParameter("groupName");
    Group m = this.manager.findByName(name);
    if (m != null) {
        // 组已存在
        ret.put("success", false);
    }
    return ret;
}
Also used : Group(com.topcom.cms.domain.Group) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Group (com.topcom.cms.domain.Group)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 User (com.topcom.cms.domain.User)3 CurrentUser (com.topcom.cms.web.bind.annotation.CurrentUser)3 UserStyle (com.topcom.cms.yuqing.domain.UserStyle)3 ApiOperation (io.swagger.annotations.ApiOperation)3 SearchWord (com.topcom.cms.domain.SearchWord)2 PageRequest (org.springframework.data.domain.PageRequest)2 Pageable (org.springframework.data.domain.Pageable)2 Sort (org.springframework.data.domain.Sort)2 AggPageImpl (com.topcom.cms.es.vo.AggPageImpl)1 GroupStyle (com.topcom.cms.yuqing.vo.request.GroupStyle)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 Page (org.springframework.data.domain.Page)1