Search in sources :

Example 1 with BussinessException

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";
}
Also used : Menu(com.ikoori.vip.common.persistence.model.Menu) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with BussinessException

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() + "],");
    }
}
Also used : Menu(com.ikoori.vip.common.persistence.model.Menu) BussinessException(com.ikoori.vip.common.exception.BussinessException)

Example 3 with BussinessException

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";
}
Also used : Role(com.ikoori.vip.common.persistence.model.Role) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with BussinessException

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";
}
Also used : ShiroUser(com.ikoori.vip.server.core.shiro.ShiroUser) User(com.ikoori.vip.common.persistence.model.User) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with BussinessException

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;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Picture(com.ikoori.vip.common.persistence.model.Picture) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) NoPermissionException(javax.naming.NoPermissionException) BussinessException(com.ikoori.vip.common.exception.BussinessException) BussinessException(com.ikoori.vip.common.exception.BussinessException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

BussinessException (com.ikoori.vip.common.exception.BussinessException)41 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)25 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 Permission (com.ikoori.vip.common.annotion.Permission)17 Transactional (org.springframework.transaction.annotation.Transactional)9 User (com.ikoori.vip.common.persistence.model.User)8 Merchant (com.ikoori.vip.common.persistence.model.Merchant)7 Date (java.util.Date)7 Coupon (com.ikoori.vip.common.persistence.model.Coupon)6 ShiroUser (com.ikoori.vip.server.core.shiro.ShiroUser)6 BussinessLog (com.ikoori.vip.common.annotion.log.BussinessLog)5 File (java.io.File)4 HashMap (java.util.HashMap)4 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)3 OrderItemPayDo (com.ikoori.vip.common.dto.OrderItemPayDo)3 Card (com.ikoori.vip.common.persistence.model.Card)3 Member (com.ikoori.vip.common.persistence.model.Member)3 Menu (com.ikoori.vip.common.persistence.model.Menu)3 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)3 ApiOperation (io.swagger.annotations.ApiOperation)3