diff --git a/app/controllers/api/v1/issues_controller.rb b/app/controllers/api/v1/issues_controller.rb index 6f615e498..689d8e520 100644 --- a/app/controllers/api/v1/issues_controller.rb +++ b/app/controllers/api/v1/issues_controller.rb @@ -99,7 +99,7 @@ class Api::V1::IssuesController < Api::V1::BaseController params.permit( :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, - :subject, :description, + :subject, :description, :blockchain_token_num, :issue_tag_ids => [], :assigner_ids => [], :attachment_ids => [], diff --git a/app/services/api/v1/issues/create_service.rb b/app/services/api/v1/issues/create_service.rb index 30f4a11ef..ae9d45c95 100644 --- a/app/services/api/v1/issues/create_service.rb +++ b/app/services/api/v1/issues/create_service.rb @@ -4,13 +4,14 @@ class Api::V1::Issues::CreateService < ApplicationService include Api::V1::Issues::Concerns::Loadable attr_reader :project, :current_user - attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description + attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login attr_accessor :created_issue validates :subject, presence: true validates :status_id, :priority_id, presence: true validates :project, :current_user, presence: true + validates :blockchain_token_num, numericality: {greater_than: 0} def initialize(project, params, current_user = nil) @project = project @@ -23,6 +24,7 @@ class Api::V1::Issues::CreateService < ApplicationService @due_date = params[:due_date] @subject = params[:subject] @description = params[:description] + @blockchain_token_num = params[:blockchain_token_num] @issue_tag_ids = params[:issue_tag_ids] @assigner_ids = params[:assigner_ids] @attachment_ids = params[:attachment_ids] @@ -94,6 +96,7 @@ class Api::V1::Issues::CreateService < ApplicationService issue_attributes.merge!({start_date: start_date}) if start_date.present? issue_attributes.merge!({due_date: due_date}) if due_date.present? issue_attributes.merge!({branch_name: branch_name}) if branch_name.present? + issue_attributes.merge!({blockchain_token_num: blockchain_token_num}) if blockchain_token_num.present? issue_attributes end diff --git a/app/services/api/v1/issues/list_service.rb b/app/services/api/v1/issues/list_service.rb index fa27f4ee4..7019dc8e4 100644 --- a/app/services/api/v1/issues/list_service.rb +++ b/app/services/api/v1/issues/list_service.rb @@ -7,7 +7,7 @@ class Api::V1::Issues::ListService < ApplicationService validates :category, inclusion: {in: %w(all opened closed), message: "请输入正确的Category"} validates :participant_category, inclusion: {in: %w(all aboutme authoredme assignedme atme), message: "请输入正确的ParticipantCategory"} - validates :sort_by, inclusion: {in: ['issues.created_on', 'issues.updated_on', 'issue_priorities.position'], message: '请输入正确的SortBy'}, allow_blank: true + validates :sort_by, inclusion: {in: ['issues.created_on', 'issues.updated_on', 'issues.blockchain_token_num', 'issue_priorities.position'], message: '请输入正确的SortBy'}, allow_blank: true validates :sort_direction, inclusion: {in: %w(asc desc), message: '请输入正确的SortDirection'}, allow_blank: true validates :current_user, presence: true @@ -68,7 +68,7 @@ class Api::V1::Issues::ListService < ApplicationService issues = issues.where(status_id: status_id) if status_id.present? # keyword - issues = issues.ransack(subject_or_description_cont: keyword).result if keyword.present? + issues = issues.ransack(id_eq: params[:keyword]).result.or(issues.ransack(subject_or_description_cont: keyword).result) if keyword.present? @total_issues_count = issues.distinct.size @closed_issues_count = issues.closed.distinct.size diff --git a/app/services/api/v1/issues/update_service.rb b/app/services/api/v1/issues/update_service.rb index 9aa9d6bb1..4d3495022 100644 --- a/app/services/api/v1/issues/update_service.rb +++ b/app/services/api/v1/issues/update_service.rb @@ -4,11 +4,12 @@ class Api::V1::Issues::UpdateService < ApplicationService include Api::V1::Issues::Concerns::Loadable attr_reader :project, :issue, :current_user - attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description + attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login attr_accessor :add_assigner_ids, :previous_issue_changes, :updated_issue, :atme_receivers validates :project, :issue, :current_user, presence: true + validates :blockchain_token_num, numericality: {greater_than: 0} def initialize(project, issue, params, current_user = nil) @project = project @@ -22,6 +23,7 @@ class Api::V1::Issues::UpdateService < ApplicationService @due_date = params[:due_date] @subject = params[:subject] @description = params[:description] + @blockchain_token_num = params[:blockchain_token_num] @issue_tag_ids = params[:issue_tag_ids] @assigner_ids = params[:assigner_ids] @attachment_ids = params[:attachment_ids] @@ -94,6 +96,7 @@ class Api::V1::Issues::UpdateService < ApplicationService @updated_issue.due_date = due_date unless due_date.nil? @updated_issue.subject = subject if subject.present? @updated_issue.description = description unless description.nil? + @updated_issue.blockchain_token_num = blockchain_token_num unless blockchain_token_num.nil? end def build_assigner_participants diff --git a/app/views/api/v1/issues/_detail.json.jbuilder b/app/views/api/v1/issues/_detail.json.jbuilder index 193357ce1..d1b6352c7 100644 --- a/app/views/api/v1/issues/_detail.json.jbuilder +++ b/app/views/api/v1/issues/_detail.json.jbuilder @@ -1,4 +1,4 @@ -json.(issue, :id, :subject, :project_issues_index, :description, :branch_name, :start_date, :due_date) +json.(issue, :id, :subject, :project_issues_index, :description, :branch_name, :start_date, :due_date, :blockchain_token_num) json.created_at issue.created_on.strftime("%Y-%m-%d %H:%M") json.updated_at issue.updated_on.strftime("%Y-%m-%d %H:%M") json.tags issue.show_issue_tags.each do |tag| diff --git a/app/views/api/v1/issues/_simple_detail.json.jbuilder b/app/views/api/v1/issues/_simple_detail.json.jbuilder index 7e0d6b11f..27424deff 100644 --- a/app/views/api/v1/issues/_simple_detail.json.jbuilder +++ b/app/views/api/v1/issues/_simple_detail.json.jbuilder @@ -1,4 +1,4 @@ -json.(issue, :id, :subject, :project_issues_index) +json.(issue, :id, :subject, :project_issues_index, :blockchain_token_num) json.created_at issue.created_on.strftime("%Y-%m-%d %H:%M") json.updated_at issue.updated_on.strftime("%Y-%m-%d %H:%M") json.tags issue.show_issue_tags.each do |tag|