issue index for pm

This commit is contained in:
呱呱呱 2023-10-31 09:11:54 +08:00
parent 92cefd34b2
commit 51648e52b3
2 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@ class Api::V1::PmIssuesController < ApplicationController
before_action :require_login, except: [:index, :show]
def index
project = Project.find_by_id(params[:project_id]) || Project.new( id: 0, user_id: 0, name:"pm_mm", identifier:"pm_mm" )
object_result = Api::V1::Issues::ListService.call(@project, query_params, current_user)
@total_issues_count = @object_result[:total_issues_count]
@opened_issues_count = @object_result[:opened_issues_count]
@ -14,7 +15,7 @@ class Api::V1::PmIssuesController < ApplicationController
end
def create
project = Project.find_by_id(params[:project_id]) || Project.new( id: 0, user_id: current_user.id, name:"pm_mm", identifier:"pm_mm" )
project = Project.find_by_id(params[:project_id]) || Project.new( id: 0, user_id: 0, name:"pm_mm", identifier:"pm_mm" )
@object_result = Api::V1::Issues::CreateService.call(project, issue_params, current_user)
end

View File

@ -4,6 +4,7 @@ class Api::V1::Issues::ListService < ApplicationService
attr_reader :project, :only_name, :category, :participant_category, :keyword, :author_id, :issue_tag_ids
attr_reader :begin_date, :end_date
attr_reader :milestone_id, :assigner_id, :status_id, :sort_by, :sort_direction, :current_user
attr_reader :pm_project_id, :pm_sprint_id
attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count
validates :category, inclusion: {in: %w(all opened closed), message: "请输入正确的Category"}
@ -26,6 +27,8 @@ class Api::V1::Issues::ListService < ApplicationService
@begin_date = params[:begin_date]
@end_date = params[:end_date]
@sort_by = params[:sort_by].present? ? params[:sort_by] : 'issues.updated_on'
@pm_project_id = params[:pm_project_id]
@pm_sprint_id = params[:pm_sprint_id]
@sort_direction = (params[:sort_direction].present? ? params[:sort_direction] : 'desc').downcase
@current_user = current_user
end
@ -65,6 +68,12 @@ class Api::V1::Issues::ListService < ApplicationService
# milestone_id
issues = issues.where(fixed_version_id: milestone_id) if milestone_id.present?
# pm_project_id
issues = issues.where(pm_project_id: pm_project_id) if pm_project_id.present?
# pm_sprint_id
issues = issues.where(pm_sprint_id: pm_sprint_id) if pm_sprint_id.present?
# assigner_id
issues = issues.joins(:assigners).where(users: {id: assigner_id}) if assigner_id.present?