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