use of com.ikoori.vip.common.annotion.Permission 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.annotion.Permission 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;
}
use of com.ikoori.vip.common.annotion.Permission in project vip by guangdada.
the class DictController method deptUpdate.
/**
* 跳转到修改字典
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping("/dict_edit/{dictId}")
public String deptUpdate(@PathVariable Integer dictId, Model model) {
Dict dict = dictMapper.selectById(dictId);
model.addAttribute("dict", dict);
List<Dict> subDicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("pid", dictId));
model.addAttribute("subDicts", subDicts);
LogObjectHolder.me().set(dict);
return PREFIX + "dict_edit.html";
}
Aggregations