Commit f759fbae by fsn

解决新建用户不能修改自己资料的bug

parent 174e7cfb
...@@ -10,6 +10,8 @@ import com.stylefeng.guns.common.constant.tips.Tip; ...@@ -10,6 +10,8 @@ import com.stylefeng.guns.common.constant.tips.Tip;
import com.stylefeng.guns.common.controller.BaseController; import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.common.exception.BizExceptionEnum; import com.stylefeng.guns.common.exception.BizExceptionEnum;
import com.stylefeng.guns.common.exception.BussinessException; import com.stylefeng.guns.common.exception.BussinessException;
import com.stylefeng.guns.common.persistence.dao.UserMapper;
import com.stylefeng.guns.common.persistence.model.User;
import com.stylefeng.guns.core.db.Db; import com.stylefeng.guns.core.db.Db;
import com.stylefeng.guns.core.listener.ConfigListener; import com.stylefeng.guns.core.listener.ConfigListener;
import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.log.LogObjectHolder;
...@@ -20,9 +22,6 @@ import com.stylefeng.guns.modular.system.dao.UserMgrDao; ...@@ -20,9 +22,6 @@ import com.stylefeng.guns.modular.system.dao.UserMgrDao;
import com.stylefeng.guns.modular.system.factory.UserFactory; import com.stylefeng.guns.modular.system.factory.UserFactory;
import com.stylefeng.guns.modular.system.transfer.UserDto; import com.stylefeng.guns.modular.system.transfer.UserDto;
import com.stylefeng.guns.modular.system.warpper.UserWarpper; import com.stylefeng.guns.modular.system.warpper.UserWarpper;
import com.stylefeng.guns.common.persistence.dao.UserMapper;
import com.stylefeng.guns.common.persistence.model.User;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
...@@ -193,7 +192,6 @@ public class UserMgrController extends BaseController { ...@@ -193,7 +192,6 @@ public class UserMgrController extends BaseController {
*/ */
@RequestMapping("/edit") @RequestMapping("/edit")
@BussinessLog(value = "修改管理员", key = "account", dict = Dict.UserDict) @BussinessLog(value = "修改管理员", key = "account", dict = Dict.UserDict)
@Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Tip edit(@Valid UserDto user, BindingResult result) throws NoPermissionException { public Tip edit(@Valid UserDto user, BindingResult result) throws NoPermissionException {
if (result.hasErrors()) { if (result.hasErrors()) {
...@@ -204,11 +202,11 @@ public class UserMgrController extends BaseController { ...@@ -204,11 +202,11 @@ public class UserMgrController extends BaseController {
return SUCCESS_TIP; return SUCCESS_TIP;
} else { } else {
ShiroUser shiroUser = ShiroKit.getUser(); ShiroUser shiroUser = ShiroKit.getUser();
if (shiroUser.getId() == user.getId()) { if (shiroUser.getId().equals(user.getId())) {
this.userMapper.updateById(UserFactory.createUser(user)); this.userMapper.updateById(UserFactory.createUser(user));
return SUCCESS_TIP; return SUCCESS_TIP;
} else { } else {
throw new AuthenticationException(); throw new BussinessException(BizExceptionEnum.NO_PERMITION);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment