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