Search in sources :

Example 6 with PrePermissions

use of com.github.liuweijw.business.commons.web.aop.PrePermissions in project fw-cloud-framework by liuweijw.

the class MenuController method menuTreeList.

// 获取所有菜单列表 以及功能权限
@GetMapping(value = "/menuTreeList/{roleCode}")
@PrePermissions(value = Functional.VIEW)
public R<MenuTreeBean> menuTreeList(@PathVariable("roleCode") String roleCode) {
    MenuTreeBean menuTreeBean = new MenuTreeBean();
    List<MenuTree> menuTree = menuService.findAllMenuTree();
    menuTreeBean.setMenuList(menuTree);
    Set<String> permissions = new HashSet<String>();
    permissions.addAll(permissionService.findMenuPermissions(roleCode));
    menuTreeBean.setPermissions(permissions.toArray(new String[permissions.size()]));
    return new R<MenuTreeBean>().data(menuTreeBean);
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) MenuTreeBean(com.github.liuweijw.business.admin.beans.MenuTreeBean) HashSet(java.util.HashSet) GetMapping(org.springframework.web.bind.annotation.GetMapping) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions)

Example 7 with PrePermissions

use of com.github.liuweijw.business.commons.web.aop.PrePermissions in project fw-cloud-framework by liuweijw.

the class MenuController method menuTreeList.

// 获取所有菜单列表
@GetMapping(value = "/menuTreeAllList")
@PrePermissions(value = Functional.VIEW)
public R<MenuTreeBean> menuTreeList() {
    MenuTreeBean menuTreeBean = new MenuTreeBean();
    List<MenuTree> menuTree = menuService.findAllMenuTreeList();
    menuTreeBean.setMenuList(menuTree);
    return new R<MenuTreeBean>().data(menuTreeBean);
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) MenuTreeBean(com.github.liuweijw.business.admin.beans.MenuTreeBean) GetMapping(org.springframework.web.bind.annotation.GetMapping) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions)

Example 8 with PrePermissions

use of com.github.liuweijw.business.commons.web.aop.PrePermissions in project fw-cloud-framework by liuweijw.

the class UserController method modifyUser.

/**
 * 修改用户密码
 */
@RequestMapping(value = "/modifyUser", method = RequestMethod.POST)
@PrePermissions(value = Functional.UPD)
public R<Boolean> modifyUser(HttpServletRequest request, @RequestBody UserForm userForm) {
    if (null == userForm.getUsername())
        return new R<Boolean>().failure("用户名不存在");
    if (null == userForm.getPassword())
        return new R<Boolean>().failure("请输入旧密码");
    if (null == userForm.getNewpassword())
        return new R<Boolean>().failure("请输入新密码");
    User user = this.userService.findUserByUsername(userForm.getUsername().trim(), false);
    if (null == user)
        return new R<Boolean>().failure("用户名不存在");
    if (!new BCryptPasswordEncoder().matches(userForm.getPassword().trim(), user.getPassword()))
        return new R<Boolean>().failure("旧密码输入错误!");
    user.setPassword(new BCryptPasswordEncoder().encode(userForm.getNewpassword().trim()));
    boolean r = this.userService.updateUser(user);
    return new R<Boolean>().data(r);
}
Also used : R(com.github.liuweijw.core.utils.R) User(com.github.liuweijw.business.admin.domain.User) AuthUser(com.github.liuweijw.core.beans.system.AuthUser) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with PrePermissions

use of com.github.liuweijw.business.commons.web.aop.PrePermissions in project fw-cloud-framework by liuweijw.

the class RoleController method add.

@ApiOperation(value = "新增", notes = "角色", produces = "application/json")
@ApiImplicitParam(name = "role", value = "", required = true, dataType = "Role")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@PrePermissions(value = Functional.ADD)
public R<Boolean> add(HttpServletRequest request, @RequestBody Role role) {
    if (null == role)
        return new R<Boolean>().failure("角色信息为空");
    // 检测权限编码是否存在
    Role exRole = roleService.findRoleByCode(role.getRoleCode());
    if (null != exRole)
        return new R<Boolean>().failure("权限编码已经存在!").data(false);
    if (null == role.getDeptId())
        return new R<Boolean>().failure("请选择角色所属部门");
    role.setCreateTime(new Date());
    role.setUpdateTime(new Date());
    role.setStatu(0);
    Role updateObj = roleService.saveRoleAndDept(role);
    return new R<Boolean>().data(null != updateObj);
}
Also used : Role(com.github.liuweijw.business.admin.domain.Role) R(com.github.liuweijw.commons.base.R) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with PrePermissions

use of com.github.liuweijw.business.commons.web.aop.PrePermissions in project fw-cloud-framework by liuweijw.

the class MenuController method add.

@RequestMapping(value = "/add", method = RequestMethod.POST)
@PrePermissions(value = Functional.ADD)
public R<Boolean> add(HttpServletRequest request, @RequestBody Menu menu) {
    if (null == menu)
        return new R<Boolean>().failure("菜单信息为空");
    if (null == menu.getPid())
        return new R<Boolean>().failure("请选择菜单再点击进行新增");
    menu.setCreateTime(new Date());
    menu.setUpdateTime(new Date());
    menu.setStatu(0);
    Menu menuObj = menuService.saveOrUpdate(menu);
    return new R<Boolean>().data(null != menuObj);
}
Also used : R(com.github.liuweijw.commons.base.R) Menu(com.github.liuweijw.business.admin.domain.Menu) Date(java.util.Date) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PrePermissions (com.github.liuweijw.business.commons.web.aop.PrePermissions)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 R (com.github.liuweijw.commons.base.R)8 Date (java.util.Date)7 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)4 ApiOperation (io.swagger.annotations.ApiOperation)4 User (com.github.liuweijw.business.admin.domain.User)3 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)3 MenuTreeBean (com.github.liuweijw.business.admin.beans.MenuTreeBean)2 Dept (com.github.liuweijw.business.admin.domain.Dept)2 Menu (com.github.liuweijw.business.admin.domain.Menu)2 Role (com.github.liuweijw.business.admin.domain.Role)2 MenuTree (com.github.liuweijw.business.commons.tree.MenuTree)2 AuthUser (com.github.liuweijw.core.beans.system.AuthUser)2 R (com.github.liuweijw.core.utils.R)2 HashSet (java.util.HashSet)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 AuthUser (com.github.liuweijw.system.api.model.AuthUser)1 Method (java.lang.reflect.Method)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1