首页 > 其他分享 >IndexPatternService几个重写的方法

IndexPatternService几个重写的方法

时间:2024-11-15 14:33:41浏览次数:1  
标签:方法 request indexPatternItem IndexPatternService indexPattern new 重写 response Exa

@Override
@Transactional(rollbackFor = Exception.class)
public AddIndexPatternResponse newIndexPattern(AddIndexPatternRequest request) {
IndexPatternItem indexPatternItem = request.getIndexPatternItem();
AddIndexPatternResponse response = new AddIndexPatternResponse();

if (StringUtils.isEmpty(indexPatternItem.getSystemId())
        || StringUtils.isEmpty(indexPatternItem.getIndexPatternName())
        || StringUtils.isEmpty(indexPatternItem.getApplicationName())) {
    throw new TitanException("所传参数为空!");
}

long id = SnowFlakeSequence.nextId();
IndexPattern indexPattern = new IndexPattern();
indexPattern.setId(id);
indexPattern.setSystemId(indexPatternItem.getSystemId());
indexPattern.setIndexPatternName(indexPatternItem.getIndexPatternName());
indexPattern.setApplicationName(indexPatternItem.getApplicationName());
indexPattern.setDesensitizationFlag(false);
indexPattern.setCreateTime(new Date());
indexPattern.setUpdateTime(new Date());
indexPatternMapper.insert(indexPattern);

if (!CollectionUtils.isEmpty(request.getDepartmentIndexPatternDTOList())) {
    permissionService.addPermissionForIndexPattern(id, request.getDepartmentIndexPatternDTOList());
}

if (!CollectionUtils.isEmpty(request.getUserIndexPatternDTOList())) {
    userPermissionService.addUserPermissionForIndexPattern(id, request.getUserIndexPatternDTOList());
}

RespUtils.setSuccess(response);
return response;

}
@Transactional(rollbackFor = Exception.class)
@Override
public DelIndexPatternResponse deleteIndexPatternByName(DelIndexPatternRequest request) {
String indexName = request.getIndexPatternName();
DelIndexPatternResponse response = new DelIndexPatternResponse();

    if (StringUtils.isEmpty(indexName)) {
        throw new TitanException("所传参数为空!");
    }

    Example indexPatternExample = new Example(IndexPattern.class);
    indexPatternExample.createCriteria().andEqualTo("indexPatternName", indexName);

    Example userPermissionExample = new Example(UserPermission.class);
    userPermissionExample.createCriteria().andEqualTo("indexPatternId", getIndexPatternByName(indexName).getId());
    userPermissionMapper.deleteByExample(userPermissionExample);

    Example departmentPermissionExample = new Example(DepartmentPermission.class);
    departmentPermissionExample.createCriteria().andEqualTo("indexPatternId", getIndexPatternByName(indexName).getId());
    permissionMapper.deleteByExample(departmentPermissionExample);

    indexPatternMapper.deleteByExample(indexPatternExample);
    RespUtils.setSuccess(response);
    return response;
}

@Transactional(rollbackFor = Exception.class)
@Override
public ChangeIndexPatternResponse updateIndexPatternByName(ChangeIndexPatternRequest request) {
IndexPatternItem indexPatternItem = request.getIndexPatternItem();
ChangeIndexPatternResponse response = new ChangeIndexPatternResponse();

    if (indexPatternItem == null) {
        throw new TitanException("所传参数为空!");
    }

    IndexPattern indexPatternNew = indexPatternMapper.selectByPrimaryKey(indexPatternItem.getId());
    if (indexPatternNew == null) {
        RespUtils.setError(ErrorCodeEnum.INDEX_PATTERN_NOT_EXIST, response);
        return response;
    }

    indexPatternNew.setApplicationName(indexPatternItem.getApplicationName());
    indexPatternNew.setIndexPatternName(indexPatternItem.getIndexPatternName());
    indexPatternNew.setSystemId(indexPatternItem.getSystemId());
    indexPatternNew.setUpdateTime(new Date());
    indexPatternMapper.updateByPrimaryKeySelective(indexPatternNew);

    if (request.getDepartmentIndexPatternDTOList() != null) {
        permissionService.deletePermissionByIndexPatternId(indexPatternItem.getId());
        permissionService.addPermissionForIndexPattern(indexPatternItem.getId(), request.getDepartmentIndexPatternDTOList());
    }

    if (request.getUserIndexPatternDTOList() != null) {
        userPermissionService.deleteUserPermissionByIndexPatternId(indexPatternItem.getId());
        userPermissionService.addUserPermissionForIndexPattern(indexPatternItem.getId(), request.getUserIndexPatternDTOList());
    }

    RespUtils.setSuccess(response);
    return response;
}

@Override
public FuzzyQueryIndexPatternResponse fuzzyQuery(FuzzyQueryIndexPatternRequest request) {
Map<String, Object> map = new HashMap<>();
map.put("indexPatternName", request.getIndexPatternName());
map.put("systemIdList", request.getSystemIdList());
map.put("applicationName", request.getApplicationName());

FuzzyQueryIndexPatternResponse response = new FuzzyQueryIndexPatternResponse();

if (request.getPageIndex() <= 0) {
    request.setPageIndex(1);
}

if (request.getLimit() <= 0) {
    request.setLimit(10);
}

int offset = (request.getPageIndex() - 1) * request.getLimit();
Page<IndexPattern> indexPatternPage = PageHelper.offsetPage(offset, request.getLimit(), true).doSelectPage(() -> indexPatternMapper.fuzzySearch(map));

Page<IndexPatternItem> indexPatternItemPage = new Page<>();
BeanUtils.copyProperties(indexPatternPage, indexPatternItemPage);

for (IndexPattern indexPattern : indexPatternPage.getResult()) {
    indexPatternItemPage.add(getIndexPatternItem(indexPattern));
}

response.setPageInfo(indexPatternItemPage.toPageInfo());
RespUtils.setSuccess(response);

return response;

}
@Override
public GetIndexPatternUserAndDepartmentResponse getIndexPatternUserAndDepartment(GetIndexPatternUserAndDepartmentRequest request) {
String indexPatternName = request.getIndexPatternName();
String indexName = request.getIndexPatternName();

if (StringUtils.isEmpty(indexName)) {
    throw new TitanException("所传参数为空!");
}

// 创建查询条件,获取索引模式
Example example = new Example(IndexPattern.class);
Example.Criteria criteria = example.createCriteria();
criteria.orEqualTo("indexPatternName", indexPatternName);

IndexPattern indexPattern = indexPatternMapper.selectOneByExample(example);


// 获取索引模式下的用户权限
Example userExample = new Example(UserPermission.class);
Example.Criteria userCriteria = userExample.createCriteria();
userCriteria.orEqualTo("indexPatternId", indexPattern.getId());

List<UserPermission> userPermissionList = userPermissionMapper.selectByExample(userExample);
List<String> userNameList = new ArrayList<>();
for (UserPermission userPermission : userPermissionList) {
    if (Boolean.TRUE.equals(userPermission.getPermanentFlag()) ||
        (Boolean.FALSE.equals(userPermission.getPermanentFlag()) &&
         userPermission.getEffectiveDate() != null &&
         userPermission.getEffectiveDate().getTime() > new Date().getTime())) {
        userNameList.add(userPermission.getUserName());
    }
}

// 获取索引模式下的部门权限
Example departmentExample = new Example(DepartmentPermission.class);
Example.Criteria departmentCriteria = departmentExample.createCriteria();
departmentCriteria.orEqualTo("indexPatternId", indexPattern.getId());

List<DepartmentPermission> departmentPermissionList = permissionMapper.selectByExample(departmentExample);
List<String> departmentIdList = new ArrayList<>();
for (DepartmentPermission departmentPermission : departmentPermissionList) {
    if (Boolean.TRUE.equals(departmentPermission.getPermanentFlag()) ||
        (Boolean.FALSE.equals(departmentPermission.getPermanentFlag()) &&
         departmentPermission.getEffectiveDate() != null &&
         departmentPermission.getEffectiveDate().getTime() > new Date().getTime())) {
        departmentIdList.add(departmentPermission.getDepartmentId());
    }
}

// 构建响应对象
GetIndexPatternUserAndDepartmentResponse response = new GetIndexPatternUserAndDepartmentResponse();
response.setUserNameList(userNameList);
response.setDepartmentIdList(departmentIdList);
RespUtils.setSuccess(response);

return response;

}
@Override
Public QueryIndicesBySystemAndApplicationResponse queryIndicesBySystemAndApplication(QueryIndicesBySystemAndApplicationRequest request){QueryIndicesBySystemAndApplicationResponse response=new QueryIndicesBySystemAndApplicationResponse();
String userName= request. getUserName();
if(StringUtils. isEmpty(userName)){
log. error("查询用户关联索引请求参数 为 空 ");
throw newTitanException(" 所 传 参 数 为 空!");}
UserConfig user=userService.queryByUserName(userName);
if( user== null){RespUtils. setError(ErrorCodeEnum.USER_NOT_EXIST,response); return response;}
QueryFinTechUser Request userRequest=new QueryFinTechUserRequest(); List< String> userNameList=newArrayList<>();userNameList.add(userName);userRequest.setUserNameList(userNameList);//全 查 询 用 户
UserInfoResponse userInfoResponse=finTechDataProviderService. queryFinTechUserInfo(userRequest);
String departmentId=userInfoResponse.getUserList().get(0).getOrgId(); Depart ment department=departmentService.getDepartmentById(departmentId);
//如果是全查 询 用 户 就 不 要 in 只 需 要 模 糊 查 询
Int isGlobal=0;
if(user.getGlobalQuery()||( department!= null&& department. getGlobalQuer y())){isGlobal=1;}
PageHelper.startPage(request.getPageIndex(),request.getPageLimit()); PageInfo pageInfo=new PageInfo<>(indexPatternMapper. selectIndexByApplicationAndSystemId( request.getIndexName(),request. getApplicationName(),request.getSystemIdList(),isGlobal,userName,departmentId)); List indexPatternItemList=newArrayList<>();pageInfo.getList(). forEach(userIndex->{IndexPatternItem item=new IndexPatternItem(); item. setSystemId(userIndex.getSystemId()); item.setApplicationName(userIndex. getApplicationName()); item.setIndexPattemName(userIndex. getIndexPatternName()); item. setId(userIndex.getId());indexPatternItemList.add(item);}); response. setIndicesList(indexPatternItemList); response.setTotal(pageInfo.getTotal()); response. setSuccess(); retur nresponse;}

标签:方法,request,indexPatternItem,IndexPatternService,indexPattern,new,重写,response,Exa
From: https://www.cnblogs.com/lmzzr24/p/18547914

相关文章

  • 使用css 画三角形的三种方法
    使用纯css绘制三角形方法一使用边框实现先实现一个div四个粗边框不同颜色保留左右和下边框设置左右边框为颜色为transparent<body><divclass="div1"></div><divclass="div2"></div><divclass="div3"></div>&l......
  • 国标GB28181-2016平台LiteGBS国标GB28181视频平台球机安装好后发现云台不受控制的解决
    随着视频技术的不断进步,视频监控、直播、执法记录仪等多种视频资源的应用场景愈发广泛且多样化。LiteGBS国标GB28181视频平台不仅在数量上快速增长,更在质量、格式及编码标准等方面展现出极高的多样性。因此,为了实现对这些资源的有效整合和统一管理输出,信息化项目中对于视频综合接......
  • 安川Yaskawa机器人DX100示教器维修的方法
        安川Yaskawa机器人DX100示教器维修的优劣势分析安川Yaskawa机器人示教编程,工业机器人维修,即操作人员经过安川机器人示教器,ABB机器人保养,手动操控机器人的关节运动,以使机器人运动到预订的方位,一起将该方位进行记载,并传递到机器人操控器中,今后的机器人可根据指令自......
  • HTTP协议详解:发展、请求方法与安全
    前言第一次写文章比较生疏,思路也很局限,除了课件之外添加内容有限,但也以此督促学习,争取日更。学习视频来自B站up主“泷羽sec”有兴趣的师傅可以关注一下,如涉及侵权马上删除文章,笔记只是方便各位师傅的学习和探讨,文章所提到的网站以及内容,只做学习交流,其他均与本人以及泷羽sec......
  • thinkphp 6.0.* 升级到thinkphp 6.0.15最新版的方法
    ​虽然thinkphp官方目前更新到了8.x版本,但是旧项目是使用thinkphp6.0.*,如果直接升级到thinkphp6.1.*或者8.*,项目会运行错误,那么应该怎么升级到thinkphp6.0.*的最新版呢?方法是:打开项目根目录下的composer.json文件,找到下面的代码"require":{"php":">=7.2.5",......
  • java.util.Collection集合方法:Collections.BinarySearch 方法
    BinarySearch(List,Object)  使用二進位搜尋演算法搜尋指定的物件清單。BinarySearch(List,Object,IComparator)  使用二進位搜尋演算法搜尋指定的物件清單。参数:List要所有的list列表Object要搜索的索引键案例:packagecom.test.controller;importcom.te......
  • JavaScript常用对象方法二:数组(array)
    1.concat()用于连接两个或多个数组。该方法不会改变现有的数组,而是返回一个新的数组。个人感觉es6出来的扩展运算符比这个方法要简洁一些扩展运算符的方法:constarr1=[1,2];constarr2=[3,4];constarr3=[...arr1,...arr2];console.log(arr3);//[1,2,......
  • getDepartmentById方法
    publicDepartmentgetDepartmentById(StringdepartmentId){if(StringUtils.isEmpty(departmentId)){returnnull;}Exampleexample=newExample(Department.class);Example.Criteriacriteria=example.createCriteria();criteria.andEqualTo("departmentId"......
  • 帝国CMS过滤内容里面HTML字符简单的方法代码
    自定义函数在 /e/class/userfun.php 文件中添加以下代码:functionDELHTML($string){$string=preg_replace("'<script[^>]*?>.*?</script>'si","",$string);//去掉javascript$string=preg_replace("'<[\......
  • 宝塔面板安装网站后打不开的解决方法及排查步骤
    1.检查网络连接确认服务器网络是否正常:从服务器上尝试ping外部网站,确保网络畅通。例如:ping域名 或 ping你的网址2.检查宝塔面板状态登录服务器,检查面板是否正常运行:使用命令 bt 进入宝塔面板管理界面。如果面板未运行,尝试启动面板:btstart3.检查网站......