/src/backend/codecc/core/codeccjob/biz-codeccjob/src/main/java/com/tencent/bk/codecc/codeccjob/dao/mongorepository/DefectRepository.java

https://github.com/Tencent/bk-ci · Java · 101 lines · 20 code · 9 blank · 72 comment · 0 complexity · c6d6eea70ba9ea24102723e96a6705d4 MD5 · raw file

  1. /*
  2. * Tencent is pleased to support the open source community by making BK-CODECC 蓝鲸代码检查平台 available.
  3. *
  4. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
  5. *
  6. * BK-CODECC 蓝鲸代码检查平台 is licensed under the MIT license.
  7. *
  8. * A copy of the MIT License is included in this file.
  9. *
  10. *
  11. * Terms of the MIT License:
  12. * ---------------------------------------------------
  13. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
  14. * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
  15. * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  21. * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  22. * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. package com.tencent.bk.codecc.codeccjob.dao.mongorepository;
  27. import com.tencent.bk.codecc.defect.model.DefectEntity;
  28. import org.springframework.data.mongodb.repository.MongoRepository;
  29. import org.springframework.data.mongodb.repository.Query;
  30. import org.springframework.stereotype.Repository;
  31. import java.util.List;
  32. import java.util.Set;
  33. /**
  34. * 告警查询持久代码
  35. *
  36. * @version V1.0
  37. * @date 2019/10/20
  38. */
  39. @Repository
  40. public interface DefectRepository extends MongoRepository<DefectEntity, String>
  41. {
  42. /**
  43. * 通过实体id查询告警信息
  44. *
  45. * @param entityId
  46. * @return
  47. */
  48. DefectEntity findByEntityId(String entityId);
  49. /**
  50. * 通过任务id,工具名查询告警信息
  51. *
  52. * @param taskId
  53. * @param toolName
  54. * @return
  55. */
  56. List<DefectEntity> findByTaskIdAndToolName(long taskId, String toolName);
  57. /**
  58. * 通过任务id,工具名和状态查询告警信息
  59. *
  60. * @param taskId
  61. * @param toolName
  62. * @param status
  63. * @return
  64. */
  65. List<DefectEntity> findByTaskIdAndToolNameAndStatus(long taskId, String toolName, int status);
  66. /**
  67. * 根据taskId,工具名查询所有的告警ID
  68. *
  69. * @param taskId
  70. * @param toolName
  71. * @return
  72. */
  73. @Query(fields = "{'id':1}", value = "{'task_id': ?0, 'tool_name': ?1}")
  74. List<DefectEntity> findIdsByTaskIdAndToolName(long taskId, String toolName);
  75. /**
  76. * 通过任务id,工具名查询告警信息
  77. *
  78. * @param taskId
  79. * @param toolName
  80. * @return
  81. */
  82. @Query(fields = "{'id':1, 'status':1}", value = "{'task_id': ?0, 'tool_name': ?1, 'id': {'$in': ?2}}")
  83. List<DefectEntity> findStatusByTaskIdAndToolNameAndIdIn(long taskId, String toolName, Set<Long> idSet);
  84. /**
  85. * 根据entityIdSet查询告警信息
  86. *
  87. * @param entityIdSet
  88. * @return
  89. */
  90. @Query(fields = "{'id':1, 'status':1}", value = "{'_id': {'$in': ?0}}")
  91. List<DefectEntity> findStatusByEntityIdIn(Set<String> entityIdSet);
  92. }