Search in sources :

Example 31 with LambdaQueryWrapper

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;
}
Also used : ActionCardMessage(com.jeecg.dingtalk.api.message.vo.ActionCardMessage) Message(com.jeecg.dingtalk.api.message.vo.Message) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage) ActionCardMessage(com.jeecg.dingtalk.api.message.vo.ActionCardMessage) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 32 with LambdaQueryWrapper

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;
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 33 with LambdaQueryWrapper

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));
            }
        }
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysDepartRole(org.jeecg.modules.system.entity.SysDepartRole) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 34 with LambdaQueryWrapper

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) Cacheable(org.springframework.cache.annotation.Cacheable) org.jeecg.modules.system.entity(org.jeecg.modules.system.entity) Autowired(org.springframework.beans.factory.annotation.Autowired) FindsDepartsChildrenUtil(org.jeecg.modules.system.util.FindsDepartsChildrenUtil) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) StringUtil(io.netty.util.internal.StringUtil) DepartIdModel(org.jeecg.modules.system.model.DepartIdModel) JSONArray(com.alibaba.fastjson.JSONArray) Service(org.springframework.stereotype.Service) org.jeecg.common.util.oConvertUtils(org.jeecg.common.util.oConvertUtils) ISysDepartService(org.jeecg.modules.system.service.ISysDepartService) YouBianCodeUtil(org.jeecg.common.util.YouBianCodeUtil) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) org.jeecg.modules.system.mapper(org.jeecg.modules.system.mapper) CacheConstant(org.jeecg.common.constant.CacheConstant) FillRuleUtil(org.jeecg.common.util.FillRuleUtil) Consumer(java.util.function.Consumer) FillRuleConstant(org.jeecg.common.constant.FillRuleConstant) JSONObject(com.alibaba.fastjson.JSONObject) CommonConstant(org.jeecg.common.constant.CommonConstant) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel) Transactional(org.springframework.transaction.annotation.Transactional) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 35 with LambdaQueryWrapper

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;
}
Also used : SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)381 Transactional (org.springframework.transaction.annotation.Transactional)60 JSONObject (com.alibaba.fastjson.JSONObject)52 Result (org.jeecg.common.api.vo.Result)50 ArrayList (java.util.ArrayList)42 List (java.util.List)30 Map (java.util.Map)29 Collectors (java.util.stream.Collectors)26 Service (org.springframework.stereotype.Service)24 LoginUser (org.jeecg.common.system.vo.LoginUser)22 SysPermission (org.jeecg.modules.system.entity.SysPermission)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)21 IPage (com.baomidou.mybatisplus.core.metadata.IPage)20 HashMap (java.util.HashMap)20 SysUser (org.jeecg.modules.system.entity.SysUser)20 ApiOperation (io.swagger.annotations.ApiOperation)19 ServiceException (cn.lili.common.exception.ServiceException)18 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)18 Autowired (org.springframework.beans.factory.annotation.Autowired)18