Search in sources :

Example 36 with BussinessException

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);
        }
    }
}
Also used : Method(java.lang.reflect.Method) BussinessException(com.ikoori.vip.common.exception.BussinessException) BussinessException(com.ikoori.vip.common.exception.BussinessException) IConstantFactory(com.ikoori.vip.server.common.constant.factory.IConstantFactory)

Example 37 with BussinessException

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;
}
Also used : HashMap(java.util.HashMap) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Menu(com.ikoori.vip.common.persistence.model.Menu) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) BussinessLog(com.ikoori.vip.common.annotion.log.BussinessLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 38 with BussinessException

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";
}
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) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 39 with BussinessException

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);
    }
}
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) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 40 with BussinessException

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;
}
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) BussinessLog(com.ikoori.vip.common.annotion.log.BussinessLog) 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