From 7301ea98d8d3a05ee0eebe41ace91a2f2b4824ff Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Mon, 24 Feb 2020 14:00:30 +0800 Subject: [PATCH] FIX project list return id with integer --- README.md | 12 ++++++------ app/controllers/projects_controller.rb | 3 +-- app/views/projects/_project.json.jbuilder | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ee05c4262..7798769e2 100644 --- a/README.md +++ b/README.md @@ -994,7 +994,7 @@ http://localhost:3000/api/projects | jq |参数名|类型|说明| -|-|- |total_count |int |项目总条数 | -|id |string |项目标识 | +|id |string |项目id | |name |string|项目名称| |description |string|项目简介| |visits |int|流量数| @@ -1019,7 +1019,7 @@ http://localhost:3000/api/projects | jq "total_count": 3096, "projects": [ { - "id": "hnfl_demo1", + "id": 1, "name": "hnfl_demo1", "description": "my first project", "visits": 0, @@ -1042,7 +1042,7 @@ http://localhost:3000/api/projects | jq } }, { - "id": "hnfl_demo", + "id": 2, "name": "hnfl_demo", "description": "my first project", "visits": 0, @@ -1065,7 +1065,7 @@ http://localhost:3000/api/projects | jq } }, { - "id": "tongjj", + "id": 3, "name": "统计局", "description": "my first project", "visits": 0, @@ -1088,7 +1088,7 @@ http://localhost:3000/api/projects | jq } }, { - "id": null, + "id": 5, "name": "开源同名", "description": "my first project", "visits": 0, @@ -1111,7 +1111,7 @@ http://localhost:3000/api/projects | jq } }, { - "id": "mvp_demo", + "id": 7, "name": "开源支持", "description": "my first project", "visits": 0, diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 939a48fa0..d1e7191cb 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -2,8 +2,7 @@ class ProjectsController < ApplicationController include ApplicationHelper include OperateProjectAbilityAble before_action :require_login, except: %i[index branches group_type_list] - before_action :find_project_with_identifier, only: %i[branches] - before_action :find_project_with_id, only: %i[update show] + before_action :find_project_with_id, only: %i[show branches update] before_action :authorizate_user_can_edit_project!, only: %i[update] def index diff --git a/app/views/projects/_project.json.jbuilder b/app/views/projects/_project.json.jbuilder index 52e980342..550cafce7 100644 --- a/app/views/projects/_project.json.jbuilder +++ b/app/views/projects/_project.json.jbuilder @@ -1,4 +1,5 @@ -json.id project.identifier +json.id project.id +json.identifier project.identifier json.name project.name json.description project.description json.visits project.visits