Search in sources :

Example 91 with Permission

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;
}
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 92 with Permission

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;
}
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)

Example 93 with Permission

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";
}
Also used : Dict(com.ikoori.vip.common.persistence.model.Dict) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Permission (com.ikoori.vip.common.annotion.Permission)93 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)92 Merchant (com.ikoori.vip.common.persistence.model.Merchant)55 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)47 HashMap (java.util.HashMap)31 Map (java.util.Map)23 BussinessException (com.ikoori.vip.common.exception.BussinessException)18 Store (com.ikoori.vip.common.persistence.model.Store)12 Coupon (com.ikoori.vip.common.persistence.model.Coupon)11 Card (com.ikoori.vip.common.persistence.model.Card)9 MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)6 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)6 User (com.ikoori.vip.common.persistence.model.User)6 ShiroUser (com.ikoori.vip.server.core.shiro.ShiroUser)4 LinkedHashMap (java.util.LinkedHashMap)4 BussinessLog (com.ikoori.vip.common.annotion.log.BussinessLog)3 OperationLog (com.ikoori.vip.common.persistence.model.OperationLog)3 WxConfig (com.ikoori.vip.common.persistence.model.WxConfig)3 LogWarpper (com.ikoori.vip.server.modular.system.warpper.LogWarpper)3 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)2