add project pm

This commit is contained in:
呱呱呱 2023-11-02 15:04:43 +08:00
parent dd30341f6e
commit 840bbff88a
9 changed files with 43 additions and 10 deletions

View File

@ -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.

View File

@ -0,0 +1,3 @@
// Place all the styles related to the api/pm/projects controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,11 @@
class Api::Pm::ProjectsController < Api::Pm::BaseController
def convert
@project = Project.joins(:owner).find params[:project_id]
data = {
owner: @project.owner.try(:login),
identifier: @project.identifier
}
render_ok(data: data)
end
end

View File

@ -232,15 +232,6 @@ class ProjectsController < ApplicationController
def show
end
def mp_show
@project = Project.joins(:owner).find params[:project_id]
data={
owner:@project.owner.try(:login),
identifier:@project.identifier
}
render_ok(data:data)
end
def destroy
if current_user.admin? || @project.manager?(current_user)
ActiveRecord::Base.transaction do

View File

@ -0,0 +1,2 @@
module Api::Pm::ProjectsHelper
end

View File

@ -127,7 +127,6 @@ Rails.application.routes.draw do
# blockchain related routes
get 'users/blockchain/balance', to: 'users#blockchain_balance'
get 'projects/mp_show', to: 'projects#mp_show'
post 'users/blockchain/balance_project', to: 'users#blockchain_balance_one_project'
post 'users/blockchain/transfer', to: 'users#blockchain_transfer'
post 'users/blockchain/exchange', to: 'users#blockchain_exchange'

View File

@ -16,6 +16,11 @@ defaults format: :json do
end
end
end
resources :projects do
collection do
get :convert
end
end
end
namespace :v1 do

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Api::Pm::ProjectsController, type: :controller do
end

View File

@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Api::Pm::ProjectsHelper. For example:
#
# describe Api::Pm::ProjectsHelper 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::Pm::ProjectsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end