use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.
the class ThirdAppDingtalkServiceImpl method sendActionCardMessage.
/**
* 发送卡片消息(SysAnnouncement定制)
*
* @param announcement
* @param verifyConfig 是否验证配置(未启用的APP会拒绝发送)
* @return
*/
public Response<String> sendActionCardMessage(SysAnnouncement announcement, boolean verifyConfig) {
if (verifyConfig && !thirdAppConfig.isDingtalkEnabled()) {
return null;
}
String accessToken = this.getAccessToken();
if (accessToken == null) {
return null;
}
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
String markdown = "### " + announcement.getTitile() + "\n" + oConvertUtils.getString(announcement.getMsgAbstract(), "空");
ActionCardMessage actionCard = new ActionCardMessage(markdown);
actionCard.setTitle(announcement.getTitile());
actionCard.setSingle_title("详情");
actionCard.setSingle_url(RestUtil.getBaseUrl() + "/sys/annountCement/show/" + announcement.getId());
Message<ActionCardMessage> actionCardMessage = new Message<>(agentId, actionCard);
if (CommonConstant.MSG_TYPE_ALL.equals(announcement.getMsgType())) {
actionCardMessage.setTo_all_user(true);
return JdtMessageAPI.sendActionCardMessage(actionCardMessage, accessToken);
} else {
// 将userId转为username
String[] userIds = null;
String userId = announcement.getUserIds();
if (oConvertUtils.isNotEmpty(userId)) {
userIds = userId.substring(0, (userId.length() - 1)).split(",");
} else {
LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysAnnouncementSend::getAnntId, announcement.getId());
SysAnnouncementSend sysAnnouncementSend = sysAnnouncementSendMapper.selectOne(queryWrapper);
userIds = new String[] { sysAnnouncementSend.getUserId() };
}
if (userIds != null) {
String[] usernameList = sysUserService.userIdToUsername(Arrays.asList(userIds)).toArray(new String[] {});
// 通过第三方账号表查询出第三方userId
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(usernameList, THIRD_TYPE);
List<String> dtUserIds = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
actionCardMessage.setUserid_list(dtUserIds);
return JdtMessageAPI.sendActionCardMessage(actionCardMessage, accessToken);
}
}
return null;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartPermissionServiceImpl method getPermRuleListByDeptIdAndPermId.
@Override
public List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId, String permissionId) {
SysDepartPermission departPermission = this.getOne(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
if (departPermission != null && oConvertUtils.isNotEmpty(departPermission.getDataRuleIds())) {
LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
query.in(SysPermissionDataRule::getId, Arrays.asList(departPermission.getDataRuleIds().split(",")));
query.orderByDesc(SysPermissionDataRule::getCreateTime);
List<SysPermissionDataRule> permRuleList = this.ruleMapper.selectList(query);
return permRuleList;
} else {
return null;
}
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartPermissionServiceImpl method saveDepartPermission.
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDepartPermission(String departId, String permissionIds, String lastPermissionIds) {
List<String> add = getDiff(lastPermissionIds, permissionIds);
if (add != null && add.size() > 0) {
List<SysDepartPermission> list = new ArrayList<SysDepartPermission>();
for (String p : add) {
if (oConvertUtils.isNotEmpty(p)) {
SysDepartPermission rolepms = new SysDepartPermission(departId, p);
list.add(rolepms);
}
}
this.saveBatch(list);
}
List<String> delete = getDiff(permissionIds, lastPermissionIds);
if (delete != null && delete.size() > 0) {
for (String permissionId : delete) {
this.remove(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
// 删除部门权限时,删除部门角色中已授权的权限
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList(new LambdaQueryWrapper<SysDepartRole>().eq(SysDepartRole::getDepartId, departId));
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList());
if (roleIds != null && roleIds.size() > 0) {
departRolePermissionMapper.delete(new LambdaQueryWrapper<SysDepartRolePermission>().eq(SysDepartRolePermission::getPermissionId, permissionId));
}
}
}
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartServiceImpl method queryTreeListByPid.
/**
* 根据parentId查询部门树
* @param parentId
* @param ids 前端回显传递
* @return
*/
@Override
public List<SysDepartTreeModel> queryTreeListByPid(String parentId, String ids) {
Consumer<LambdaQueryWrapper<SysDepart>> square = i -> {
if (oConvertUtils.isNotEmpty(ids)) {
i.in(SysDepart::getId, ids.split(","));
} else {
if (oConvertUtils.isEmpty(parentId)) {
i.and(q -> q.isNull(true, SysDepart::getParentId).or().eq(true, SysDepart::getParentId, ""));
} else {
i.eq(true, SysDepart::getParentId, parentId);
}
}
};
LambdaQueryWrapper<SysDepart> lqw = new LambdaQueryWrapper();
lqw.eq(true, SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
lqw.func(square);
lqw.orderByDesc(SysDepart::getDepartOrder);
List<SysDepart> list = list(lqw);
List<SysDepartTreeModel> records = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
SysDepart depart = list.get(i);
SysDepartTreeModel treeModel = new SysDepartTreeModel(depart);
// TODO 异步树加载key拼接__+时间戳,以便于每次展开节点会刷新数据
// treeModel.setKey(treeModel.getKey()+"__"+System.currentTimeMillis());
treeModel.setKey(treeModel.getKey());
Integer count = this.baseMapper.queryCountByPid(depart.getId());
if (count > 0) {
treeModel.setIsLeaf(false);
} else {
treeModel.setIsLeaf(true);
}
records.add(treeModel);
}
return records;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartServiceImpl method queryTreeList.
/**
* queryTreeList 根据部门id查询,前端回显调用
*/
@Override
public List<SysDepartTreeModel> queryTreeList(String ids) {
List<SysDepartTreeModel> listResult = new ArrayList<>();
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
if (oConvertUtils.isNotEmpty(ids)) {
query.in(true, SysDepart::getId, ids.split(","));
}
query.orderByAsc(SysDepart::getDepartOrder);
List<SysDepart> list = this.list(query);
for (SysDepart depart : list) {
listResult.add(new SysDepartTreeModel(depart));
}
return listResult;
}
Aggregations