Search in sources :

Example 66 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.

the class SysCategoryServiceImpl method getTreeChildIds.

/**
 * 递归 根据父id获取子节点id
 * @param pidVal
 * @param sb
 * @return
 */
private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
    LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(SysCategory::getPid, pidVal);
    List<SysCategory> dataList = baseMapper.selectList(queryWrapper);
    if (dataList != null && dataList.size() > 0) {
        for (SysCategory category : dataList) {
            if (!sb.toString().contains(category.getId())) {
                sb.append(",").append(category.getId());
            }
            this.getTreeChildIds(category.getId(), sb);
        }
    }
    return sb;
}
Also used : SysCategory(org.jeecg.modules.system.entity.SysCategory) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 67 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.

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 68 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.

the class SysThirdAccountServiceImpl method saveThirdUser.

public String saveThirdUser(SysUser sysUser) {
    // 保存用户
    String userid = UUIDGenerator.generate();
    sysUser.setId(userid);
    sysUserMapper.insert(sysUser);
    // 获取第三方角色
    SysRole sysRole = sysRoleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleCode, "third_role"));
    // 保存用户角色
    SysUserRole userRole = new SysUserRole();
    userRole.setRoleId(sysRole.getId());
    userRole.setUserId(userid);
    sysUserRoleMapper.insert(userRole);
    return userid;
}
Also used : SysRole(org.jeecg.modules.system.entity.SysRole) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysUserRole(org.jeecg.modules.system.entity.SysUserRole)

Example 69 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.

the class SysThirdAccountServiceImpl method createUser.

@Override
public SysUser createUser(String phone, String thirdUserUuid) {
    // 先查询第三方,获取登录方式
    LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
    query.eq(SysThirdAccount::getThirdUserUuid, thirdUserUuid);
    SysThirdAccount account = sysThirdAccountMapper.selectOne(query);
    // 通过用户名查询数据库是否已存在
    SysUser userByName = sysUserMapper.getUserByName(thirdUserUuid);
    if (null != userByName) {
        // 如果账号存在的话,则自动加上一个时间戳
        String format = DateUtils.yyyymmddhhmmss.get().format(new Date());
        thirdUserUuid = thirdUserUuid + format;
    }
    // 添加用户
    SysUser user = new SysUser();
    user.setActivitiSync(CommonConstant.ACT_SYNC_0);
    user.setDelFlag(CommonConstant.DEL_FLAG_0);
    user.setStatus(1);
    user.setUsername(thirdUserUuid);
    user.setPhone(phone);
    // 设置初始密码
    String salt = oConvertUtils.randomGen(8);
    user.setSalt(salt);
    String passwordEncode = PasswordUtil.encrypt(user.getUsername(), "123456", salt);
    user.setPassword(passwordEncode);
    user.setRealname(account.getRealname());
    user.setAvatar(account.getAvatar());
    String s = this.saveThirdUser(user);
    // 更新用户第三方账户表的userId
    SysThirdAccount sysThirdAccount = new SysThirdAccount();
    sysThirdAccount.setSysUserId(s);
    sysThirdAccountMapper.update(sysThirdAccount, query);
    return user;
}
Also used : SysThirdAccount(org.jeecg.modules.system.entity.SysThirdAccount) SysUser(org.jeecg.modules.system.entity.SysUser) Date(java.util.Date) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 70 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.

the class KmDocServiceImpl method retrieveDocDbInfo.

private List<KmSearchResultVO> retrieveDocDbInfo(List<KmDocEsVO> kmDocEsVOList) {
    if (kmDocEsVOList == null || kmDocEsVOList.isEmpty())
        return Collections.EMPTY_LIST;
    // get info from DB
    List<String> docIdList = new ArrayList<>();
    kmDocEsVOList.forEach(e -> {
        docIdList.add(e.getDocId());
    });
    List<KmSearchResultVO> kmSearchResultVOList = new ArrayList<>();
    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    if (sysUser == null) {
        return kmSearchResultVOList;
    } else {
        String userId = sysUser.getId();
        LambdaQueryWrapper<KmDocFavourite> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(KmDocFavourite::getDocId, docIdList);
        queryWrapper.eq(KmDocFavourite::getUserId, userId);
        List<KmDocFavourite> kmDocFavouriteList = kmDocFavouriteService.list(queryWrapper);
        List<String> favouritDocList = new ArrayList<>();
        if (kmDocFavouriteList != null && kmDocFavouriteList.size() > 0) {
            kmDocFavouriteList.forEach(e -> favouritDocList.add(e.getDocId()));
        }
        List<KmDoc> kmDocList = super.listByIds(docIdList);
        Map<String, KmDoc> kmDocMap = new HashMap<>();
        kmDocList.forEach(e -> kmDocMap.put(e.getId(), e));
        kmDocEsVOList.forEach((e) -> {
            KmSearchResultVO kmSearchResultVO = new KmSearchResultVO();
            kmSearchResultVO.setCategory(e.getCategory());
            kmSearchResultVO.setId(e.getDocId());
            // kmSearchResultVO.setPubTime(e.getPubTime());
            kmSearchResultVO.setSource(e.getSource());
            kmSearchResultVO.setTitle(e.getTitle());
            kmSearchResultVO.setFileNo(e.getFileNo());
            if (e.getVersions() != null)
                kmSearchResultVO.setVersions(StringUtils.concatListToString(Arrays.asList(e.getVersions())));
            if (e.getKeywords() != null)
                kmSearchResultVO.setKeywords(StringUtils.concatListToString(Arrays.asList(e.getKeywords())));
            if (e.getTopicCodes() != null)
                kmSearchResultVO.setTopicCodes(StringUtils.concatListToString(Arrays.asList(e.getTopicCodes())));
            if (e.getBusinessTypes() != null)
                kmSearchResultVO.setBusinessType(StringUtils.concatListToString(Arrays.asList(e.getBusinessTypes())));
            // 拼装db信息
            if (kmDocMap.containsKey(kmSearchResultVO.getId())) {
                KmDoc one = kmDocMap.get(kmSearchResultVO.getId());
                kmSearchResultVO.setDownloads(one.getDownloads());
                kmSearchResultVO.setViews(one.getViews());
                kmSearchResultVO.setFileId(one.getFileId());
                kmSearchResultVO.setPreviewFileId(one.getPreviewFileId());
                kmSearchResultVO.setFileType(one.getFileType());
                kmSearchResultVO.setSize(one.getFileSize());
                kmSearchResultVO.setPubTimeTxt(one.getPubTimeTxt());
                kmSearchResultVO.setDownloadFlag(one.getDownloadFlag());
                kmSearchResultVO.setEffectTime(one.getEffectTime());
                kmSearchResultVO.setRemark(one.getRemark());
                kmSearchResultVO.setOrgCode(one.getOrgCode());
            }
            // 拼装收藏夹标记
            if (favouritDocList.contains(e.getDocId()))
                kmSearchResultVO.setFavourite(1);
            else
                kmSearchResultVO.setFavourite(0);
            kmSearchResultVOList.add(kmSearchResultVO);
        });
        return kmSearchResultVOList;
    }
}
Also used : LoginUser(org.jeecg.common.system.vo.LoginUser) 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