Search in sources :

Example 6 with Group

use of com.ganster.cms.core.pojo.Group in project Ganster-CMS by Gangster-trio.

the class UserController method findAllGroup.

/**
 * 查找所有的用户组
 * @return AjaxData  查找到的信息
 */
@GetMapping("/findgroup")
@ResponseBody
public AjaxData findAllGroup() {
    int number = 0;
    AjaxData ajaxData = new AjaxData();
    GroupExample groupExample = new GroupExample();
    groupService.selectByExample(groupExample);
    List<Group> groupList = groupService.selectByExample(groupExample);
    if (groupList != null && !groupList.isEmpty()) {
        ajaxData.setData((ArrayList) groupList);
        for (Group i : groupList) {
            number++;
        }
        ajaxData.setCode(number);
        return ajaxData;
    }
    ajaxData.setMsg("查找失败");
    return ajaxData;
}
Also used : Group(com.ganster.cms.core.pojo.Group) GroupExample(com.ganster.cms.core.pojo.GroupExample) AjaxData(com.ganster.cms.admin.dto.AjaxData)

Example 7 with Group

use of com.ganster.cms.core.pojo.Group in project Ganster-CMS by Gangster-trio.

the class UserController method index.

public Boolean index() {
    Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
    List<Group> group = groupService.selectByUserId(userId);
    for (Group i : group) {
        if ("admin".equals(i.getGroupName())) {
            return true;
        }
    }
    return false;
}
Also used : Group(com.ganster.cms.core.pojo.Group)

Example 8 with Group

use of com.ganster.cms.core.pojo.Group in project Ganster-CMS by Gangster-trio.

the class GroupController method deleteGroup.

/**
 * 删除用户组
 *
 * @param groupId 用户组id
 */
@RequestMapping("/delete/{groupId}")
@ResponseBody
public void deleteGroup(@PathVariable("groupId") Integer groupId) {
    Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
    List<Group> list = groupService.selectByUserId(userId);
    for (Group flag : list) {
        if ("admin".equals(flag.getGroupName())) {
            groupService.deleteGroup(groupId);
            break;
        }
    }
    LOGGER.info("++++++++++++++delete" + groupId + "+++++++++++++++");
    PermissionUtil.flush((Integer) SecurityUtils.getSubject().getSession().getAttribute("id"));
}
Also used : Group(com.ganster.cms.core.pojo.Group) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with Group

use of com.ganster.cms.core.pojo.Group in project Ganster-CMS by Gangster-trio.

the class GroupController method addGroup.

/**
 * 增加用户组
 *
 * @param group 用户组
 */
@RequestMapping("/add")
@ResponseBody
public Message addGroup(@RequestBody Group group) {
    Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
    List<Group> list = groupService.selectByUserId(userId);
    for (Group flag : list) {
        if ("admin".equals(flag.getGroupName())) {
            int count = groupService.insert(group);
            if (count == 0) {
                return super.buildMessage(1, "false", null);
            }
            if (count == 1) {
                return super.buildMessage(0, "success", count);
            }
            break;
        }
    }
    PermissionUtil.flush(userId);
    return super.buildMessage(2, "no privilege", null);
}
Also used : Group(com.ganster.cms.core.pojo.Group) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with Group

use of com.ganster.cms.core.pojo.Group in project Ganster-CMS by Gangster-trio.

the class GroupController method updateGroup.

/**
 * 更新用户组
 *
 * @param groupId 用户组id
 * @param group   用户组对象
 * @return AjaxData
 */
@RequestMapping("/update/{groupId}")
@ResponseBody
public Message updateGroup(@PathVariable("groupId") Integer groupId, @RequestBody Group group) {
    Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
    List<Group> list = groupService.selectByUserId(userId);
    for (Group flag : list) {
        if ("admin".equals(flag.getGroupName())) {
            group.setGroupId(groupId);
            int count = groupService.updateByPrimaryKeySelective(group);
            if (count == 0) {
                return super.buildMessage(1, "false", null);
            }
            if (count == 1) {
                return super.buildMessage(0, "success", count);
            }
            break;
        }
    }
    PermissionUtil.flush(userId);
    return super.buildMessage(2, "no privilege", null);
}
Also used : Group(com.ganster.cms.core.pojo.Group) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Group (com.ganster.cms.core.pojo.Group)19 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 GroupNotFountException (com.ganster.cms.core.exception.GroupNotFountException)7 InformationException (com.ganster.cms.auth.Exception.InformationException)6 GroupExample (com.ganster.cms.core.pojo.GroupExample)6 ArrayList (java.util.ArrayList)6 Subject (org.apache.shiro.subject.Subject)6 UserNotFoundException (com.ganster.cms.core.exception.UserNotFoundException)5 Permission (com.ganster.cms.core.pojo.Permission)5 PInformationUtil (com.ganster.cms.auth.util.PInformationUtil)4 User (com.ganster.cms.core.pojo.User)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 AjaxData (com.ganster.cms.admin.dto.AjaxData)3 PermissionNotFoundException (com.ganster.cms.core.exception.PermissionNotFoundException)3 RInformationUtil (com.ganster.cms.auth.util.RInformationUtil)2 UserExample (com.ganster.cms.core.pojo.UserExample)2 GroupService (com.ganster.cms.core.service.GroupService)2 UserService (com.ganster.cms.core.service.UserService)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2