Search in sources :

Example 6 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class DeptServiceImpl method deleteDept.

@Override
public void deleteDept(Integer deptId) {
    Dept dept = deptMapper.selectById(deptId);
    Wrapper<Dept> wrapper = new EntityWrapper<>();
    wrapper = wrapper.like("pids", "%[" + dept.getId() + "]%");
    List<Dept> subDepts = deptMapper.selectList(wrapper);
    for (Dept temp : subDepts) {
        temp.deleteById();
    }
    dept.deleteById();
}
Also used : Dept(com.ikoori.vip.common.persistence.model.Dept) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper)

Example 7 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class MenuServiceImpl method delMenuContainSubMenus.

@Override
public void delMenuContainSubMenus(Integer menuId) {
    Menu menu = menuMapper.selectById(menuId);
    // 删除当前菜单
    delMenu(menuId);
    // 删除所有子菜单
    Wrapper<Menu> wrapper = new EntityWrapper<>();
    wrapper = wrapper.like("pcodes", "%[" + menu.getCode() + "]%");
    List<Menu> menus = menuMapper.selectList(wrapper);
    for (Menu temp : menus) {
        delMenu(temp.getId());
    }
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Menu(com.ikoori.vip.common.persistence.model.Menu)

Example 8 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class DictServiceImpl method addDict.

@Override
public void addDict(String dictName, String dictValues) {
    // 判断有没有该字典
    List<Dict> dicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("name", dictName).and().eq("pid", 0));
    if (dicts != null && dicts.size() > 0) {
        throw new BussinessException(BizExceptionEnum.DICT_EXISTED);
    }
    // 解析dictValues
    List<Map<String, String>> items = parseKeyValue(dictValues);
    // 添加字典
    Dict dict = new Dict();
    dict.setName(dictName);
    dict.setNum(0);
    dict.setPid(0);
    this.dictMapper.insert(dict);
    // 添加字典条目
    for (Map<String, String> item : items) {
        String num = item.get(MUTI_STR_KEY);
        String name = item.get(MUTI_STR_VALUE);
        Dict itemDict = new Dict();
        itemDict.setPid(dict.getId());
        itemDict.setName(name);
        try {
            itemDict.setNum(Integer.valueOf(num));
        } catch (NumberFormatException e) {
            throw new BussinessException(BizExceptionEnum.DICT_MUST_BE_NUMBER);
        }
        this.dictMapper.insert(itemDict);
    }
}
Also used : Dict(com.ikoori.vip.common.persistence.model.Dict) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Map(java.util.Map) BussinessException(com.ikoori.vip.common.exception.BussinessException)

Example 9 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class CardServiceImpl method saveCard.

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveCard(Card card, String rights) {
    if (card.getGrantType().intValue() == CardGrantType.RULE.getCode() && !checkCardLevel(card.getId(), card.getCardLevel(), card.getMerchantId())) {
        throw new BussinessException(BizExceptionEnum.INVALID_cardLevel);
    }
    if (!checkCardName(card.getId(), card.getName(), card.getMerchantId())) {
        throw new BussinessException(BizExceptionEnum.INVALID_cardName);
    }
    if (card.getGrantType().intValue() == CardGrantType.SUB_WX.getCode()) {
        if (!checkSubWxCount(card.getId(), card.getMerchantId())) {
            throw new BussinessException(BizExceptionEnum.INVALID_grantType);
        }
    }
    card.setCreateUserId(Long.valueOf(ShiroKit.getUser().getId()));
    if (card.getCoverType().intValue() == 1) {
        card.setColorCode("");
    } else {
        card.setCoverPic("");
    }
    card.setCardNumberPrefix("KR");
    if (card.getId() != null) {
        Card cardDb = cardMapper.selectById(card.getId());
        String[] ignoreProperties = { "id", "createUserId", "merchantId", "colorId", "isNeedActivate", "isSyncWeixin", "isAvailable", "syncWeixinState", "weixinCardId", "cardNumberPrefix", "isAllowShare", "termToCardId", "activationCondition", "grantCondition", "displayOrder", "createTime", "updateTime", "status" };
        BeanUtils.copyProperties(card, cardDb, ignoreProperties);
        cardDb.setUpdateTime(new Date());
        Integer c = cardMapper.updateAllColumnById(cardDb);
        if (c > 0) {
            // 先删除修改前的权益值,再添加新的权益值
            cardRightMapper.delete(new EntityWrapper<CardRight>().eq("card_id", card.getId()));
            if (StringUtils.isNotBlank(rights)) {
                getRigthFromJson(rights, card.getId());
            }
        }
    } else {
        cardMapper.insert(card);
        if (StringUtils.isNotBlank(rights)) {
            getRigthFromJson(rights, card.getId());
        }
    }
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) BussinessException(com.ikoori.vip.common.exception.BussinessException) Date(java.util.Date) Card(com.ikoori.vip.common.persistence.model.Card) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class MemberServiceImpl method updateUnionid.

public void updateUnionid() {
    String url = WeChatAPI.batchget + "?access_token=" + WeChatAPI.getAccesstoken();
    boolean c = true;
    List<Member> members = null;
    do {
        Wrapper<Member> w = new EntityWrapper<>();
        w.isNull("unionid");
        w.last(" limit 100");
        members = memberMapper.selectList(w);
        if (members != null && members.size() > 0) {
            JSONObject data = new JSONObject();
            JSONArray o = new JSONArray();
            for (Member m : members) {
                JSONObject sobj = new JSONObject();
                sobj.put("openid", m.getOpenId());
                sobj.put("lang", "zh_CN");
                o.add(sobj);
            }
            data.put("user_list", o);
            updateUnionid(url, data.toJSONString());
            System.out.println(data.toJSONString());
        }
        c = members == null || members.size() < 100 ? false : true;
        members = null;
    } while (c);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) JSONArray(com.alibaba.fastjson.JSONArray) Member(com.ikoori.vip.common.persistence.model.Member)

Aggregations

EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)23 News (com.ch999.haha.admin.entity.News)5 Date (java.util.Date)5 Adoption (com.ch999.haha.admin.entity.Adoption)4 AdoptionRequest (com.ch999.haha.admin.entity.AdoptionRequest)4 JSONObject (com.alibaba.fastjson.JSONObject)3 BussinessException (com.ikoori.vip.common.exception.BussinessException)3 Dict (com.ikoori.vip.common.persistence.model.Dict)3 Transactional (org.springframework.transaction.annotation.Transactional)3 JSONArray (com.alibaba.fastjson.JSONArray)2 UserFans (com.ch999.haha.admin.entity.UserFans)2 Permission (com.ikoori.vip.common.annotion.Permission)2 Member (com.ikoori.vip.common.persistence.model.Member)2 Menu (com.ikoori.vip.common.persistence.model.Menu)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CommentZanBO (com.ch999.haha.admin.document.redis.CommentZanBO)1 UserInfoBO (com.ch999.haha.admin.document.redis.UserInfoBO)1 AdoptionFeedBack (com.ch999.haha.admin.entity.AdoptionFeedBack)1 Phone (com.ch999.haha.admin.entity.Phone)1 UserInfo (com.ch999.haha.admin.entity.UserInfo)1