use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class DictFieldWarpperFactory method createFieldWarpper.
public static Object createFieldWarpper(Object field, String methodName) {
IConstantFactory me = ConstantFactory.me();
try {
Method method = IConstantFactory.class.getMethod(methodName, field.getClass());
Object result = method.invoke(me, field);
return result;
} catch (Exception e) {
try {
Method method = IConstantFactory.class.getMethod(methodName, Integer.class);
Object result = method.invoke(me, Integer.parseInt(field.toString()));
return result;
} catch (Exception e1) {
throw new BussinessException(BizExceptionEnum.ERROR_WRAPPER_FIELD);
}
}
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class MenuController method edit.
/**
* 修该菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/edit")
@BussinessLog(value = "修改菜单", key = "name", dict = Dict.MenuDict)
@ResponseBody
public Tip edit(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
// 设置父级菜单编号
menuSetPcode(menu);
this.menuMapper.updateById(menu);
if (!menu.getCode().equals("0") && menu.getIsmenu().intValue() == 1) {
Wrapper<Menu> wrapper = new EntityWrapper<>();
wrapper.eq("pcode", menu.getCode());
List<Menu> submenus = menuMapper.selectList(wrapper);
Map<String, Boolean> map = new HashMap<String, Boolean>();
map.put(menu.getUrl() + "/add", false);
map.put(menu.getUrl() + "/update", false);
map.put(menu.getUrl() + "/delete", false);
map.put(menu.getUrl() + "/detail", false);
map.put(menu.getUrl() + "/list", false);
map.put(menu.getUrl() + "/" + menu.getCode() + "_add", false);
map.put(menu.getUrl() + "/" + menu.getCode() + "_update", false);
for (Menu m : submenus) {
if (map.get(m.getUrl()) != null) {
map.put(m.getUrl(), true);
}
}
for (String key : map.keySet()) {
if (!map.get(key)) {
Menu subMenu = new Menu();
if (key.equals(menu.getUrl() + "/add")) {
subMenu.setName(menu.getName() + "添加");
subMenu.setCode(menu.getCode() + "_add");
} else if (key.equals(menu.getUrl() + "/update")) {
subMenu.setName(menu.getName() + "修改");
subMenu.setCode(menu.getCode() + "_update");
} else if (key.equals(menu.getUrl() + "/delete")) {
subMenu.setName(menu.getName() + "删除");
subMenu.setCode(menu.getCode() + "_delete");
} else if (key.equals(menu.getUrl() + "/detail")) {
subMenu.setName(menu.getName() + "详情");
subMenu.setCode(menu.getCode() + "_detail");
} else if (key.equals(menu.getUrl() + "/list")) {
subMenu.setName(menu.getName() + "查询");
subMenu.setCode(menu.getCode() + "_list");
} else if (key.equals(menu.getUrl() + "/" + menu.getCode() + "_add")) {
subMenu.setName(menu.getName() + "跳转添加");
subMenu.setCode("to_" + menu.getCode() + "_add");
} else if (key.equals(menu.getUrl() + "/" + menu.getCode() + "_update")) {
subMenu.setName(menu.getName() + "跳转修改");
subMenu.setCode("to_" + menu.getCode() + "_update");
}
subMenu.setIsmenu(0);
subMenu.setPcode(menu.getId().toString());
subMenu.setNum(1);
subMenu.setUrl(key);
subMenu.setStatus(1);
// 判断是否存在该编号
String existedMenuName = ConstantFactory.me().getMenuNameByCode(subMenu.getCode());
if (ToolUtil.isNotEmpty(existedMenuName)) {
throw new BussinessException(BizExceptionEnum.EXISTED_THE_MENU);
}
// 设置父级菜单编号
menuSetPcode(subMenu);
subMenu.setStatus(MenuStatus.ENABLE.getCode());
this.menuMapper.insert(subMenu);
}
}
}
return SUCCESS_TIP;
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class UserMgrController method userInfo.
/**
* 跳转到查看用户详情页面
*/
@RequestMapping("/user_info")
public String userInfo(Model model) {
Integer userId = ShiroKit.getUser().getId();
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
User user = this.userMapper.selectById(userId);
model.addAttribute(user);
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
LogObjectHolder.me().set(user);
return PREFIX + "user_view.html";
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class UserMgrController method changePwd.
/**
* 修改当前用户的密码
*/
@RequestMapping("/changePwd")
@ResponseBody
public Object changePwd(@RequestParam String oldPwd, @RequestParam String newPwd, @RequestParam String rePwd) {
if (!newPwd.equals(rePwd)) {
throw new BussinessException(BizExceptionEnum.TWO_PWD_NOT_MATCH);
}
Integer userId = ShiroKit.getUser().getId();
User user = userMapper.selectById(userId);
String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt());
if (user.getPassword().equals(oldMd5)) {
String newMd5 = ShiroKit.md5(newPwd, user.getSalt());
user.setPassword(newMd5);
user.updateById();
return SUCCESS_TIP;
} else {
throw new BussinessException(BizExceptionEnum.OLD_PWD_NOT_RIGHT);
}
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class UserMgrController method reset.
/**
* 重置管理员的密码
*/
@RequestMapping("/reset")
@BussinessLog(value = "重置管理员密码", key = "userId", dict = Dict.UserDict)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip reset(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
User user = this.userMapper.selectById(userId);
user.setSalt(ShiroKit.getRandomSalt(5));
user.setPassword(ShiroKit.md5(Const.DEFAULT_PWD, user.getSalt()));
this.userMapper.updateById(user);
return SUCCESS_TIP;
}
Aggregations