根据pm管理需求新增issue接口
This commit is contained in:
parent
6a057dedd0
commit
f6ffaa82a6
|
@ -0,0 +1,2 @@
|
||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Place all the styles related to the api/v1/pm_issues controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,23 @@
|
||||||
|
class Api::V1::PmIssuesController < ApplicationController
|
||||||
|
before_action :require_login, except: [:index, :show]
|
||||||
|
|
||||||
|
def create
|
||||||
|
project = Project.new( id: 0, user_id: current_user.id, name:"pm_mm", identifier:"pm_mm" )
|
||||||
|
@object_result = Api::V1::Issues::CreateService.call(project, issue_params, current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def issue_params
|
||||||
|
params.permit(
|
||||||
|
:status_id, :priority_id, :milestone_id,
|
||||||
|
:branch_name, :start_date, :due_date,
|
||||||
|
:subject, :description, :blockchain_token_num,
|
||||||
|
:pm_project_id, :pm_sprint_id,
|
||||||
|
:issue_tag_ids => [],
|
||||||
|
:assigner_ids => [],
|
||||||
|
:attachment_ids => [],
|
||||||
|
:receivers_login => []
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
module Api::V1::PmIssuesHelper
|
||||||
|
end
|
|
@ -29,6 +29,8 @@ class Api::V1::Issues::CreateService < ApplicationService
|
||||||
@assigner_ids = params[:assigner_ids]
|
@assigner_ids = params[:assigner_ids]
|
||||||
@attachment_ids = params[:attachment_ids]
|
@attachment_ids = params[:attachment_ids]
|
||||||
@receivers_login = params[:receivers_login]
|
@receivers_login = params[:receivers_login]
|
||||||
|
@pm_project_id = params[:pm_project_id]
|
||||||
|
@pm_sprint_id = params[:pm_sprint_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
|
@ -57,7 +59,8 @@ class Api::V1::Issues::CreateService < ApplicationService
|
||||||
@created_issue.assigners = @assigners unless assigner_ids.blank?
|
@created_issue.assigners = @assigners unless assigner_ids.blank?
|
||||||
@created_issue.attachments = @attachments unless attachment_ids.blank?
|
@created_issue.attachments = @attachments unless attachment_ids.blank?
|
||||||
@created_issue.issue_tags = @issue_tags unless issue_tag_ids.blank?
|
@created_issue.issue_tags = @issue_tags unless issue_tag_ids.blank?
|
||||||
|
@created_issue.pm_project_id = @pm_project_id
|
||||||
|
@created_issue.pm_sprint_id = @pm_sprint_id
|
||||||
@created_issue.issue_tags_value = @issue_tags.order("id asc").pluck(:id).join(",") unless issue_tag_ids.blank?
|
@created_issue.issue_tags_value = @issue_tags.order("id asc").pluck(:id).join(",") unless issue_tag_ids.blank?
|
||||||
@created_issue.save!
|
@created_issue.save!
|
||||||
|
|
||||||
|
@ -135,6 +138,7 @@ class Api::V1::Issues::CreateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_issue_project_trends
|
def build_issue_project_trends
|
||||||
|
return if @project.id == 0
|
||||||
@created_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: "create"})
|
@created_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: "create"})
|
||||||
@created_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE}) if status_id.to_i == 5
|
@created_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE}) if status_id.to_i == 5
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
json.partial! "api/v1/issues/detail", locals: {issue: @object_result}
|
|
@ -44,6 +44,7 @@ defaults format: :json do
|
||||||
collection do
|
collection do
|
||||||
patch :batch_update
|
patch :batch_update
|
||||||
delete :batch_destroy
|
delete :batch_destroy
|
||||||
|
post :pm_create
|
||||||
end
|
end
|
||||||
|
|
||||||
member do
|
member do
|
||||||
|
@ -54,12 +55,15 @@ defaults format: :json do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :pm_issues
|
||||||
|
|
||||||
scope module: :issues do
|
scope module: :issues do
|
||||||
resources :issue_tags, except: [:new, :edit] do
|
resources :issue_tags, except: [:new, :edit] do
|
||||||
collection do
|
collection do
|
||||||
get :pm_index
|
get :pm_index
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
resources :milestones, except: [:new, :edit]
|
resources :milestones, except: [:new, :edit]
|
||||||
resources :issue_statues, only: [:index], controller: '/api/v1/issues/statues' do
|
resources :issue_statues, only: [:index], controller: '/api/v1/issues/statues' do
|
||||||
collection do
|
collection do
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Api::V1::PmIssuesController, type: :controller do
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the Api::V1::PmIssuesHelper. For example:
|
||||||
|
#
|
||||||
|
# describe Api::V1::PmIssuesHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
RSpec.describe Api::V1::PmIssuesHelper, type: :helper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue