Search in sources :

Example 11 with PrePermissions

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

the class MenuController method upd.

@RequestMapping(value = "/upd", method = RequestMethod.POST)
@PrePermissions(value = Functional.UPD)
public R<Boolean> upd(HttpServletRequest request, @RequestBody Menu menu) {
    if (null == menu)
        return new R<Boolean>().failure("菜单信息为空");
    if (null == menu.getPid() || null == menu.getMenuId())
        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)

Example 12 with PrePermissions

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

the class UserController method modify.

/**
 * 修改用户密码
 */
@RequestMapping(value = "/modify", method = RequestMethod.POST)
@PrePermissions(value = Functional.UPD)
public R<Boolean> modify(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.commons.base.R) User(com.github.liuweijw.business.admin.domain.User) AuthUser(com.github.liuweijw.system.api.model.AuthUser) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) 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