[ADD]项目创建者审核申请
This commit is contained in:
parent
8f1e0f39ea
commit
a072162324
100
api_document.md
100
api_document.md
|
@ -4058,6 +4058,70 @@ http://localhost:3000/api/users/Jason/projects.json | jq
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
|
#### 特殊许可证项目申请列表
|
||||||
|
```
|
||||||
|
GET /api/apply_signatures
|
||||||
|
```
|
||||||
|
*示例*
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
-d "project_id=36" \
|
||||||
|
-d "page=1" \
|
||||||
|
-d "limit=5" \
|
||||||
|
-d "search=16895620" \
|
||||||
|
-d "status=waiting" \
|
||||||
|
http://localhost:3000/api/apply_signatures | jq
|
||||||
|
```
|
||||||
|
*请求参数说明:*
|
||||||
|
|
||||||
|
|参数名|必选|类型|说明|
|
||||||
|
|-|-|-|-|
|
||||||
|
|project_id |是|int |项目id |
|
||||||
|
|page |否|string |页数,第几页 |
|
||||||
|
|limit |否|string |每页多少条数据,默认15条 |
|
||||||
|
|search |否|string |用户名、登录名匹配搜索 |
|
||||||
|
|status |否|string |状态匹配搜索,'unpassed': 审核未通过,'waiting': 等待审核 'passed':审核通过 |
|
||||||
|
|
||||||
|
|
||||||
|
*返回参数说明:*
|
||||||
|
|
||||||
|
|参数名|类型|说明|
|
||||||
|
|-|-|-|
|
||||||
|
|total_count |int |返回记录总条数 |
|
||||||
|
|apply_signatures |array|特殊许可证项目申请信息|
|
||||||
|
|-- id |int|特殊许可证项目申请id|
|
||||||
|
|-- status |int|特殊许可证项目申请状态,'unpassed': 审核未通过,'waiting': 等待审核 'passed':审核通过|
|
||||||
|
|user |object|用户|
|
||||||
|
|-- id |int|用户id|
|
||||||
|
|-- name |string|用户名称|
|
||||||
|
|-- login |string|用户登录名/标识|
|
||||||
|
|-- image_url |string|用户头像|
|
||||||
|
|-- email |string|用户邮箱|
|
||||||
|
|-- is_owner |boolean|是否是项目的拥有者,true:是, false:不是|
|
||||||
|
|
||||||
|
|
||||||
|
返回值
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"total_count": 1,
|
||||||
|
"apply_signatures": [
|
||||||
|
{
|
||||||
|
"id": 18,
|
||||||
|
"status": "waiting",
|
||||||
|
"user": {
|
||||||
|
"id": 3,
|
||||||
|
"name": "16895620",
|
||||||
|
"login": "16895620",
|
||||||
|
"image_url": "avatars/User/boy.jpg",
|
||||||
|
"email": "2456233122@qq.com",
|
||||||
|
"is_owner": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
---
|
||||||
#### 特殊许可证项目用户创建申请
|
#### 特殊许可证项目用户创建申请
|
||||||
```
|
```
|
||||||
POST /api/apply_signatures
|
POST /api/apply_signatures
|
||||||
|
@ -4095,4 +4159,40 @@ http://localhost:3000/api/apply_signatures.json | jq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
---
|
||||||
|
#### 特殊许可证项目申请修改
|
||||||
|
```
|
||||||
|
PATCH /api/apply_signatures/:id
|
||||||
|
```
|
||||||
|
|
||||||
|
*示例*
|
||||||
|
```bash
|
||||||
|
curl -X POST \
|
||||||
|
-d "id=18" \
|
||||||
|
-d "status=passed" \
|
||||||
|
http://localhost:3000/api/apply_signatures/18 | jq
|
||||||
|
```
|
||||||
|
|
||||||
|
*请求参数说明:*
|
||||||
|
|
||||||
|
|参数名|必选|类型|说明|
|
||||||
|
|-|-|-|-|
|
||||||
|
|id |是|int |特殊许可证项目申请id |
|
||||||
|
|status |是|string |特殊许可证项目申请状态 ,'unpassed': 审核未通过,'waiting': 等待审核 'passed':审核通过|
|
||||||
|
|
||||||
|
*返回参数说明:*
|
||||||
|
|
||||||
|
|参数名|类型|说明|
|
||||||
|
|-|-|-|
|
||||||
|
|status |int |0:添加成功, -1: 更改失败, 1: 表示已经是该状态了 |
|
||||||
|
|message |string|返回信息说明|
|
||||||
|
|
||||||
|
|
||||||
|
返回值
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": 0,
|
||||||
|
"message": "success"
|
||||||
|
}
|
||||||
|
```
|
||||||
---
|
---
|
|
@ -1,5 +1,14 @@
|
||||||
class ApplySignaturesController < ApplicationController
|
class ApplySignaturesController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
before_action :find_project, only: [:index, :create, :update]
|
||||||
|
before_action :require_owner, only: [:update]
|
||||||
|
before_action :find_apply_signature, only: [:update]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@apply_signatures = @project.apply_signatures.with_status(status).includes(user: :user_extension)
|
||||||
|
@apply_signatures = @apply_signatures.joins(:user).where("LOWER(concat(users.lastname, users.firstname, users.login, users.mail)) LIKE ?", "%#{search.split(" ").join('|')}%")
|
||||||
|
@apply_signatures = kaminari_paginate(@apply_signatures)
|
||||||
|
end
|
||||||
|
|
||||||
def template_file
|
def template_file
|
||||||
license = License.find_by_name("PHengLEI")
|
license = License.find_by_name("PHengLEI")
|
||||||
|
@ -25,4 +34,45 @@ class ApplySignaturesController < ApplicationController
|
||||||
render_json
|
render_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@apply_signature.update_attributes!(apply_signature_params)
|
||||||
|
if @apply_signature.status == "passed"
|
||||||
|
Projects::AddMemberInteractor.call(@apply_signature.project.owner, @apply_signature.project, @apply_signature.user, "read", true)
|
||||||
|
else
|
||||||
|
Projects::DeleteMemberInteractor.call(@apply_signature.project.owner, @apply_signature.project, @apply_signature.user)
|
||||||
|
end
|
||||||
|
render_ok
|
||||||
|
rescue Exception => e
|
||||||
|
uid_logger_error(e.message)
|
||||||
|
tip_exception(e.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@project = Project.find_by_id(params[:project_id])
|
||||||
|
normal_status(-1, "项目不存在") unless @project.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_apply_signature
|
||||||
|
@apply_signature = ApplySignature.find_by_id(params[:id])
|
||||||
|
normal_status(-1, "特殊许可申请不存在") unless @apply_signature.present?
|
||||||
|
normal_status(1, "已经是该状态了") if @apply_signature.status == params[:status]
|
||||||
|
end
|
||||||
|
|
||||||
|
def apply_signature_params
|
||||||
|
params.permit(:status)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search
|
||||||
|
params.fetch(:search, "").to_s.downcase
|
||||||
|
end
|
||||||
|
|
||||||
|
def status
|
||||||
|
params.fetch(:status, "waiting")
|
||||||
|
end
|
||||||
|
|
||||||
|
def require_owner
|
||||||
|
normal_status(403, "") unless @project.owner?(current_user)
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -22,6 +22,7 @@ class ApplySignature < ApplicationRecord
|
||||||
has_many :attachments, as: :container, dependent: :destroy
|
has_many :attachments, as: :container, dependent: :destroy
|
||||||
|
|
||||||
scope :with_user_id, -> (user_id) {where(user_id: user_id)}
|
scope :with_user_id, -> (user_id) {where(user_id: user_id)}
|
||||||
|
scope :with_status, -> (status) {where(status: status) if status.present?}
|
||||||
|
|
||||||
validates :project_id, uniqueness: {scope: :user_id}
|
validates :project_id, uniqueness: {scope: :user_id}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
json.total_count @apply_signatures.total_count
|
||||||
|
json.apply_signatures @apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
|
||||||
|
if signature.user.present?
|
||||||
|
json.user do
|
||||||
|
json.partial! 'members/member', user: signature.user
|
||||||
|
json.is_owner @project.owner?(signature.user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -59,7 +59,7 @@ Rails.application.routes.draw do
|
||||||
delete :destroy_files
|
delete :destroy_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :apply_signatures, only: [:create] do
|
resources :apply_signatures, only: [:index, :create, :update] do
|
||||||
collection do
|
collection do
|
||||||
get :template_file
|
get :template_file
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue