use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.
the class SysUserServiceImpl method export.
@Override
public List<SysUserPOI> export() {
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUser::getIsDeleted, "0");
List<SysUser> sysUsers = this.baseMapper.selectList(queryWrapper);
return sysUsers.stream().map(sysUser -> {
SysUserPOI sysUserPoi = new SysUserPOI();
BeanUtils.copyProperties(sysUser, sysUserPoi);
sysUserPoi.setDepartName(sysDepartService.getById(sysUser.getDepartId()).getName());
sysUserPoi.setRoleName(sysRoleService.getById(sysUser.getRoleId()).getRoleName());
sysUserPoi.setStatusName(dictService.getValue("status", sysUser.getStatus()).getData());
return sysUserPoi;
}).collect(Collectors.toList());
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class KmDocController method convertAll.
@AutoLog(value = "km_doc-批量转换")
@ApiOperation(value = "km_doc-批量转换", notes = "km_doc-批量转换")
@PostMapping(value = "/convertAll")
public Result<?> convertAll(HttpServletRequest req) {
LambdaQueryWrapper<KmDoc> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(KmDoc::getFileType, "pdf");
List<KmDoc> kmDocList = kmDocService.list(wrapper);
if (kmDocList.size() > 0) {
for (KmDoc kmDoc : kmDocList) {
if (kmDoc != null) {
kmDocService.convertDocSync(kmDoc);
}
}
}
return Result.OK();
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class SysUserDepartServiceImpl method queryDepartIdsOfUser.
/**
* 根据用户id查询部门信息
*/
@Override
public List<DepartIdModel> queryDepartIdsOfUser(String userId) {
LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
LambdaQueryWrapper<SysDepart> queryDep = new LambdaQueryWrapper<SysDepart>();
try {
queryUDep.eq(SysUserDepart::getUserId, userId);
List<String> depIdList = new ArrayList<>();
List<DepartIdModel> depIdModelList = new ArrayList<>();
List<SysUserDepart> userDepList = this.list(queryUDep);
if (userDepList != null && userDepList.size() > 0) {
for (SysUserDepart userDepart : userDepList) {
depIdList.add(userDepart.getDepId());
}
queryDep.in(SysDepart::getId, depIdList);
List<SysDepart> depList = sysDepartService.list(queryDep);
if (depList != null || depList.size() > 0) {
for (SysDepart depart : depList) {
depIdModelList.add(new DepartIdModel().convertByUserDepart(depart));
}
}
return depIdModelList;
}
} catch (Exception e) {
e.fillInStackTrace();
}
return null;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
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, ThirdAppConfig.DINGTALK.toLowerCase());
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 kms by mahonelau.
the class ThirdAppDingtalkServiceImpl method syncLocalUserToThirdApp.
@Override
public SyncInfoVo syncLocalUserToThirdApp(String ids) {
SyncInfoVo syncInfo = new SyncInfoVo();
String accessToken = this.getAccessToken();
if (accessToken == null) {
syncInfo.addFailInfo("accessToken获取失败!");
return syncInfo;
}
List<SysUser> sysUsers;
if (StringUtils.isNotBlank(ids)) {
String[] idList = ids.split(",");
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SysUser::getId, (Object[]) idList);
// 获取本地指定用户
sysUsers = sysUserService.list(queryWrapper);
} else {
// 获取本地所有用户
sysUsers = sysUserService.list();
}
// 查询钉钉所有的部门,用于同步用户和部门的关系
List<Department> allDepartment = JdtDepartmentAPI.listAll(accessToken);
for (SysUser sysUser : sysUsers) {
// 外部模拟登陆临时账号,不同步
if ("_reserve_user_external".equals(sysUser.getUsername())) {
continue;
}
// 钉钉用户信息,不为null代表已同步过
Response<User> dtUserInfo;
/*
* 判断是否同步过的逻辑:
* 1. 查询 sys_third_account(第三方账号表)是否有数据,如果有代表已同步
* 2. 本地表里没有,就先用手机号判断,不通过再用username判断。
*/
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneBySysUserId(sysUser.getId(), ThirdAppConfig.DINGTALK.toLowerCase());
if (sysThirdAccount != null && oConvertUtils.isNotEmpty(sysThirdAccount.getThirdUserId())) {
// sys_third_account 表匹配成功,通过第三方userId查询出第三方userInfo
dtUserInfo = JdtUserAPI.getUserById(sysThirdAccount.getThirdUserId(), accessToken);
} else {
// 手机号匹配
Response<String> thirdUserId = JdtUserAPI.getUseridByMobile(sysUser.getPhone(), accessToken);
// 手机号匹配成功
if (thirdUserId.isSuccess() && oConvertUtils.isNotEmpty(thirdUserId.getResult())) {
// 通过查询到的userId查询用户详情
dtUserInfo = JdtUserAPI.getUserById(thirdUserId.getResult(), accessToken);
} else {
// 手机号匹配失败,尝试使用username匹配
dtUserInfo = JdtUserAPI.getUserById(sysUser.getUsername(), accessToken);
}
}
String dtUserId;
// api 接口是否执行成功
boolean apiSuccess;
// 已同步就更新,否则就创建
if (dtUserInfo != null && dtUserInfo.isSuccess() && dtUserInfo.getResult() != null) {
User dtUser = dtUserInfo.getResult();
dtUserId = dtUser.getUserid();
User updateQwUser = this.sysUserToDtUser(sysUser, dtUser, allDepartment);
Response<JSONObject> updateRes = JdtUserAPI.update(updateQwUser, accessToken);
// 收集成功/失败信息
apiSuccess = this.syncUserCollectErrInfo(updateRes, sysUser, syncInfo);
} else {
User newQwUser = this.sysUserToDtUser(sysUser, allDepartment);
Response<String> createRes = JdtUserAPI.create(newQwUser, accessToken);
dtUserId = createRes.getResult();
// 收集成功/失败信息
apiSuccess = this.syncUserCollectErrInfo(createRes, sysUser, syncInfo);
}
// api 接口执行成功,并且 sys_third_account 表匹配失败,就向 sys_third_account 里插入一条数据
if (apiSuccess && (sysThirdAccount == null || oConvertUtils.isEmpty(sysThirdAccount.getThirdUserId()))) {
if (sysThirdAccount == null) {
sysThirdAccount = new SysThirdAccount();
sysThirdAccount.setSysUserId(sysUser.getId());
sysThirdAccount.setStatus(1);
sysThirdAccount.setDelFlag(0);
sysThirdAccount.setThirdType(ThirdAppConfig.DINGTALK.toLowerCase());
}
// 设置第三方app用户ID
sysThirdAccount.setThirdUserId(dtUserId);
sysThirdAccountService.saveOrUpdate(sysThirdAccount);
}
}
return syncInfo;
}
Aggregations