新增:issue负责人变更为一对多
This commit is contained in:
parent
587facfb3d
commit
241bbc06ca
|
@ -0,0 +1,10 @@
|
|||
class Api::V1::Issues::AssignersController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
# 负责人列表
|
||||
def index
|
||||
@assigners = User.joins(assigned_issues: :project).where(projects: {id: @project&.id})
|
||||
@assigners = kaminary_select_paginate(@assigners)
|
||||
end
|
||||
end
|
|
@ -68,6 +68,9 @@ class Issue < ApplicationRecord
|
|||
has_many :issue_tags, through: :issue_tags_relates
|
||||
has_many :issue_times, dependent: :destroy
|
||||
has_many :issue_depends, dependent: :destroy
|
||||
has_many :issue_assigners
|
||||
has_many :assigners, through: :issue_assigners
|
||||
|
||||
scope :issue_includes, ->{includes(:user)}
|
||||
scope :issue_many_includes, ->{includes(journals: :user)}
|
||||
scope :issue_issue, ->{where(issue_classify: [nil,"issue"])}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: issue_assigners
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# issue_id :integer
|
||||
# assigner_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_issue_assigners_on_assigner_id (assigner_id)
|
||||
# index_issue_assigners_on_issue_id (issue_id)
|
||||
#
|
||||
|
||||
class IssueAssigner < ApplicationRecord
|
||||
belongs_to :issue
|
||||
belongs_to :assigner, class_name: "User"
|
||||
end
|
|
@ -175,6 +175,8 @@ class User < Owner
|
|||
has_many :system_notifications, through: :system_notification_histories
|
||||
has_one :trace_user, dependent: :destroy
|
||||
has_many :feedbacks, dependent: :destroy
|
||||
has_many :issue_assigners, foreign_key: :assigner_id
|
||||
has_many :assigned_issues, through: :issue_assigners, source: :issue
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
||||
scope :like, lambda { |keywords|
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
json.total_count @assigners.total_count
|
||||
json.assigners @assigners.each do |assigner|
|
||||
json.partial! 'api/v1/users/simple_user', locals: { user: assigner}
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
class CreateIssueAssigners < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :issue_assigners do |t|
|
||||
t.references :issue
|
||||
t.references :assigner, references: :user
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue