use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project orion-ops by lijiahangmax.
the class ApplicationEnvServiceImpl method syncAppEnv.
@Override
@Transactional(rollbackFor = Exception.class)
public void syncAppEnv(Long id, Long appId, Long profileId, List<Long> targetProfileIdList) {
ApplicationEnvService self = SpringHolder.getBean(ApplicationEnvService.class);
List<ApplicationEnvDO> envList;
// 查询数据
if (Const.N_N_L_1.equals(id)) {
// 全量同步
LambdaQueryWrapper<ApplicationEnvDO> wrapper = new LambdaQueryWrapper<ApplicationEnvDO>().eq(ApplicationEnvDO::getAppId, appId).eq(ApplicationEnvDO::getProfileId, profileId).eq(ApplicationEnvDO::getSystemEnv, Const.NOT_SYSTEM).orderByAsc(ApplicationEnvDO::getUpdateTime);
envList = applicationEnvDAO.selectList(wrapper);
} else {
// 查询数据
ApplicationEnvDO env = applicationEnvDAO.selectById(id);
Valid.notNull(env, MessageConst.UNKNOWN_DATA);
envList = Lists.singleton(env);
}
// 同步数据
for (Long targetProfileId : targetProfileIdList) {
// 同步环境变量
for (ApplicationEnvDO syncEnv : envList) {
ApplicationEnvRequest request = new ApplicationEnvRequest();
request.setAppId(syncEnv.getAppId());
request.setProfileId(targetProfileId);
request.setKey(syncEnv.getAttrKey());
request.setValue(syncEnv.getAttrValue());
request.setDescription(syncEnv.getDescription());
self.addAppEnv(request);
}
// 初始化系统变量
self.checkInitSystemEnv(appId, targetProfileId);
}
// 设置日志参数
EventParamsHolder.addParam(EventKeys.ID, id);
EventParamsHolder.addParam(EventKeys.APP_ID, appId);
EventParamsHolder.addParam(EventKeys.PROFILE_ID, profileId);
EventParamsHolder.addParam(EventKeys.ID_LIST, targetProfileIdList);
EventParamsHolder.addParam(EventKeys.ENV_COUNT, envList.size());
EventParamsHolder.addParam(EventKeys.PROFILE_COUNT, targetProfileIdList.size());
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.
the class SysApiController method sync.
/**
* 从redis同步api至数据库
*
* @return Boolean
*/
@PreAuth
@PostMapping("/sync")
@ApiOperation(value = "API同步")
@Log(value = "API同步")
public Result<?> sync() {
Set<Object> serviceIds = redisService.sGet(MateConstant.MATE_SERVICE_RESOURCE);
for (Object service : serviceIds) {
if (redisService.hHasKey(MateConstant.MATE_API_RESOURCE, service.toString())) {
Map<String, Object> apiMap = (Map<String, Object>) redisService.hget(MateConstant.MATE_API_RESOURCE, service.toString());
List<Map<String, String>> list = (List<Map<String, String>>) apiMap.get("list");
list.forEach(item -> {
SysApi sysApi = new SysApi();
sysApi.setAuth(item.get("auth"));
sysApi.setClassName(item.get("className"));
sysApi.setCode(item.get("code"));
sysApi.setContentType(item.get("contentType"));
sysApi.setMethod(item.get("method"));
sysApi.setMethodName(item.get("methodName"));
sysApi.setName(item.get("name"));
sysApi.setNotes(item.get("notes"));
sysApi.setPath(item.get("path"));
sysApi.setServiceId(item.get("serviceId"));
SysApi exist = sysApiService.getByCode(sysApi.getCode());
if (ObjectUtils.isEmpty(exist)) {
sysApiService.save(sysApi);
} else {
LambdaQueryWrapper<SysApi> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysApi::getCode, sysApi.getCode());
sysApiService.update(sysApi, queryWrapper);
}
});
}
redisService.hdel(MateConstant.MATE_API_RESOURCE, service.toString());
}
redisService.del(MateConstant.MATE_SERVICE_RESOURCE);
return Result.condition(true);
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.
the class SysRoleController method savePermission.
/**
* 角色权限设置
*
* @param roleId 角色Id
* @param ids 多个id使用逗号分隔
* @return Result
*/
@PreAuth
@Log(value = "角色权限设置", exception = "角色权限设置")
@PostMapping("/set-permission")
@ApiOperation(value = "角色权限设置", notes = "角色权限设置")
@ApiImplicitParams({ @ApiImplicitParam(name = "roleId", required = true, value = "角色ID", paramType = "form"), @ApiImplicitParam(name = "ids", required = true, value = "多个用,号隔开", paramType = "form") })
public Result<?> savePermission(@RequestParam String roleId, @RequestParam String ids) {
Collection longs = CollectionUtil.stringToCollection(ids);
long roleIdc = CollectionUtil.strToLong(roleId, 0L);
LambdaQueryWrapper<SysRolePermission> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SysRolePermission::getRoleId, roleIdc);
sysRolePermissionService.remove(lambdaQueryWrapper);
for (Iterator<Long> it = longs.iterator(); it.hasNext(); ) {
SysRolePermission sysRolePermission = new SysRolePermission();
long menuId = it.next();
sysRolePermission.setMenuId(menuId);
sysRolePermission.setRoleId(roleIdc);
sysRolePermissionService.saveOrUpdate(sysRolePermission);
}
redisService.del("getPermission-" + roleId);
return Result.success("操作成功");
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.
the class SysClientServiceImpl method export.
@Override
public List<SysClientPOI> export() {
LambdaQueryWrapper<SysClient> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysClient::getIsDeleted, 0);
List<SysClient> sysClients = this.baseMapper.selectList(queryWrapper);
return sysClients.stream().map(sysClient -> {
SysClientPOI sysClientPOI = new SysClientPOI();
BeanUtils.copyProperties(sysClient, sysClientPOI);
return sysClientPOI;
}).collect(Collectors.toList());
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.
the class SysDepartServiceImpl method export.
@Override
public List<SysDepartPOI> export() {
LambdaQueryWrapper<SysDepart> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysDepart::getIsDeleted, 0);
List<SysDepart> sysDeparts = this.baseMapper.selectList(queryWrapper);
return sysDeparts.stream().map(sysDepart -> {
SysDepartPOI sysDepartPOI = new SysDepartPOI();
BeanUtils.copyProperties(sysDepart, sysDepartPOI);
return sysDepartPOI;
}).collect(Collectors.toList());
}
Aggregations