use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class MenuController method menuEdit.
/**
* 跳转到菜单详情列表页面
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/menu_edit/{menuId}")
public String menuEdit(@PathVariable Integer menuId, Model model) {
if (ToolUtil.isEmpty(menuId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
Menu menu = this.menuMapper.selectById(menuId);
// 获取父级菜单的id
Menu temp = new Menu();
temp.setCode(menu.getPcode());
Menu pMenu = this.menuMapper.selectOne(temp);
// 如果父级是顶级菜单
if (pMenu == null) {
menu.setPcode("0");
} else {
// 设置父级菜单的code为父级菜单的id
menu.setPcode(String.valueOf(pMenu.getId()));
}
Map<String, Object> menuMap = BeanKit.beanToMap(menu);
menuMap.put("pcodeName", ConstantFactory.me().getMenuNameByCode(temp.getCode()));
model.addAttribute("menu", menuMap);
LogObjectHolder.me().set(menu);
return PREFIX + "menu_edit.html";
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class MenuController method menuSetPcode.
/**
* 根据请求的父级菜单编号设置pcode和层级
*/
private void menuSetPcode(@Valid Menu menu) {
if (ToolUtil.isEmpty(menu.getPcode()) || menu.getPcode().equals("0")) {
menu.setPcode("0");
menu.setPcodes("[0],");
menu.setLevels(1);
} else {
int code = Integer.parseInt(menu.getPcode());
Menu pMenu = menuMapper.selectById(code);
Integer pLevels = pMenu.getLevels();
menu.setPcode(pMenu.getCode());
// 如果编号和父编号一致会导致无限递归
if (menu.getCode().equals(menu.getPcode())) {
throw new BussinessException(BizExceptionEnum.MENU_PCODE_COINCIDENCE);
}
menu.setLevels(pLevels + 1);
menu.setPcodes(pMenu.getPcodes() + "[" + pMenu.getCode() + "],");
}
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class RoleController method roleEdit.
/**
* 跳转到修改角色
*/
@Permission
@RequestMapping(value = "/role_edit/{roleId}")
public String roleEdit(@PathVariable Integer roleId, Model model) {
if (ToolUtil.isEmpty(roleId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
Role role = this.roleMapper.selectById(roleId);
model.addAttribute(role);
model.addAttribute("pName", ConstantFactory.me().getSingleRoleName(role.getPid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(role.getDeptid()));
LogObjectHolder.me().set(role);
return PREFIX + "/role_edit.html";
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class UserMgrController method roleAssign.
/**
* 跳转到角色分配页面
*/
@Permission
@RequestMapping("/role_assign/{userId}")
public String roleAssign(@PathVariable Integer userId, Model model) {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
User user = (User) Db.create(UserMapper.class).selectOneByCon("id", userId);
model.addAttribute("userId", userId);
model.addAttribute("userAccount", user.getAccount());
return PREFIX + "user_roleassign.html";
}
use of com.ikoori.vip.common.exception.BussinessException in project vip by guangdada.
the class UserMgrController method upload.
/**
* 上传图片(上传到项目的webapp/static/img)
*/
@RequestMapping(method = RequestMethod.POST, path = "/upload")
@ResponseBody
public JSONObject upload(@RequestPart("file") MultipartFile picture) {
JSONObject obj = new JSONObject();
String pictureName = UUID.randomUUID().toString() + ".jpg";
try {
String fileSavePath = gunsProperties.getFileUploadPath();
picture.transferTo(new File(fileSavePath + pictureName));
Picture pic = new Picture();
pic.setPictypeId(PicType.LOGO.getCode());
pic.setRealName(picture.getOriginalFilename());
pic.setUrl(fileSavePath + pictureName);
pic.setName(pictureName);
Integer picId = pictureMapper.insert(pic);
obj.put("pictureName", pictureName);
obj.put("pictureId", picId);
} catch (Exception e) {
throw new BussinessException(BizExceptionEnum.UPLOAD_ERROR);
}
return obj;
}
Aggregations