Browse Source

更改:issue与我相关可自定义用户

pull/347/head
yystopf 2 years ago
parent
commit
a1ba0b596a
2 changed files with 7 additions and 6 deletions
  1. +1
    -1
      app/controllers/api/pm/issues_controller.rb
  2. +6
    -5
      app/services/api/v1/issues/list_service.rb

+ 1
- 1
app/controllers/api/pm/issues_controller.rb View File

@@ -162,7 +162,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
:update_begin_date, :update_end_date,
:sort_by, :sort_direction, :root_id,
:issue_tag_ids, :pm_project_id, :pm_sprint_id, :pm_issue_type, :pm_project_ids,
:status_ids, :ids, :exclude_ids, :pm_issue_types
:status_ids, :ids, :exclude_ids, :pm_issue_types, :participantor_id
)
end



+ 6
- 5
app/services/api/v1/issues/list_service.rb View File

@@ -5,7 +5,7 @@ class Api::V1::Issues::ListService < ApplicationService
attr_reader :begin_date, :end_date, :update_begin_date, :update_end_date
attr_reader :milestone_id, :assigner_id, :status_id, :priority_id, :sort_by, :sort_direction, :current_user
attr_reader :pm_project_id, :pm_project_ids, :pm_sprint_id, :root_id, :pm_issue_type, :status_ids, :ids, :exclude_ids, :pm_issue_types
attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count, :complete_issues_count
attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count, :complete_issues_count, :participantor

validates :category, inclusion: { in: %w[all opened closed], message: '请输入正确的Category'}
validates :participant_category, inclusion: { in: %w[all aboutme authoredme assignedme atme], message: '请输入正确的ParticipantCategory'}
@@ -40,6 +40,7 @@ class Api::V1::Issues::ListService < ApplicationService
@status_ids = params[:status_ids].present? ? params[:status_ids].split(',') : []
@pm_issue_types = params[:pm_issue_types].present? ? params[:pm_issue_types].split(',') : []
@sort_direction = (params[:sort_direction].present? ? params[:sort_direction] : 'desc').downcase
@participantor = params[:participantor_id].present? ? User.find_by_id(params[:participantor_id]) : current_user
@current_user = current_user
end

@@ -66,13 +67,13 @@ class Api::V1::Issues::ListService < ApplicationService

case participant_category
when 'aboutme' # 关于我的
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: %w[authored assigned atme], participant_id: current_user&.id})
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: %w[authored assigned atme], participant_id: participantor&.id})
when 'authoredme' # 我创建的
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'authored', participant_id: current_user&.id})
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'authored', participant_id: participantor&.id})
when 'assignedme' # 我负责的
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'assigned', participant_id: current_user&.id})
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'assigned', participant_id: participantor&.id})
when 'atme' # @我的
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'atme', participant_id: current_user&.id})
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'atme', participant_id: participantor&.id})
end
# author_id
issues = issues.where(author_id: author_id) if author_id.present?


Loading…
Cancel
Save