Skip to content

Commit

Permalink
feat: add new database design
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Jan 23, 2023
1 parent 3d1085d commit 127fcb9
Show file tree
Hide file tree
Showing 27 changed files with 22,339 additions and 12,020 deletions.
Binary file modified backend/.tmp/data.db
Binary file not shown.
79 changes: 58 additions & 21 deletions backend/src/api/article/content-types/article/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"info": {
"singularName": "article",
"pluralName": "articles",
"displayName": "Article",
"displayName": "article",
"description": ""
},
"options": {
Expand All @@ -13,37 +13,74 @@
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
"type": "string",
"required": true
},
"url": {
"type": "string"
"slug": {
"type": "uid",
"targetField": "title",
"required": true
},
"tag": {
"type": "string"
"viewed": {
"type": "biginteger",
"required": true,
"default": "0"
},
"viewed_times": {
"type": "biginteger"
"liked": {
"type": "biginteger",
"default": "0",
"required": true
},
"author_name": {
"type": "string"
"shared": {
"type": "biginteger",
"default": "0",
"required": true
},
"article_content": {
"type": "text"
"commented": {
"type": "biginteger",
"default": "0",
"required": true
},
"like": {
"type": "biginteger"
"content": {
"type": "richtext",
"required": true
},
"comment": {
"type": "biginteger"
"cover": {
"type": "string",
"required": true
},
"publish_time": {
"type": "datetime"
"summary": {
"type": "string",
"required": true
},
"author_id": {
"isAd": {
"type": "boolean",
"default": false,
"required": true
},
"typeId": {
"type": "relation",
"relation": "manyToOne",
"target": "api::type.type",
"inversedBy": "articles"
},
"authorId": {
"type": "relation",
"relation": "oneToOne",
"relation": "manyToOne",
"target": "api::author.author",
"mappedBy": "author_id"
"inversedBy": "articles"
},
"columId": {
"type": "relation",
"relation": "manyToOne",
"target": "api::colum.colum",
"inversedBy": "articles"
},
"tagId": {
"type": "relation",
"relation": "manyToOne",
"target": "api::tag.tag",
"inversedBy": "articles"
}
}
}
6 changes: 3 additions & 3 deletions backend/src/api/author/content-types/author/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"rank": {
"type": "integer"
},
"author_id": {
"articles": {
"type": "relation",
"relation": "oneToOne",
"relation": "oneToMany",
"target": "api::article.article",
"inversedBy": "author_id"
"mappedBy": "authorId"
}
}
}
26 changes: 26 additions & 0 deletions backend/src/api/colum/content-types/colum/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"kind": "collectionType",
"collectionName": "colums",
"info": {
"singularName": "colum",
"pluralName": "colums",
"displayName": "colum"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"column": {
"type": "string",
"required": true,
"unique": true
},
"articles": {
"type": "relation",
"relation": "oneToMany",
"target": "api::article.article",
"mappedBy": "columId"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

/**
* post controller
* colum controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::post.post');
module.exports = createCoreController('api::colum.colum');
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"/navs": {
"/colums": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NavListResponse"
"$ref": "#/components/schemas/ColumListResponse"
}
}
}
Expand Down Expand Up @@ -64,7 +64,7 @@
}
},
"tags": [
"Nav"
"Colum"
],
"parameters": [
{
Expand Down Expand Up @@ -169,7 +169,7 @@
}
}
],
"operationId": "get/navs"
"operationId": "get/colums"
},
"post": {
"responses": {
Expand All @@ -178,7 +178,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NavResponse"
"$ref": "#/components/schemas/ColumResponse"
}
}
}
Expand Down Expand Up @@ -235,31 +235,31 @@
}
},
"tags": [
"Nav"
"Colum"
],
"parameters": [],
"operationId": "post/navs",
"operationId": "post/colums",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NavRequest"
"$ref": "#/components/schemas/ColumRequest"
}
}
}
}
}
},
"/navs/{id}": {
"/colums/{id}": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NavResponse"
"$ref": "#/components/schemas/ColumResponse"
}
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@
}
},
"tags": [
"Nav"
"Colum"
],
"parameters": [
{
Expand All @@ -330,7 +330,7 @@
}
}
],
"operationId": "get/navs/{id}"
"operationId": "get/colums/{id}"
},
"put": {
"responses": {
Expand All @@ -339,7 +339,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NavResponse"
"$ref": "#/components/schemas/ColumResponse"
}
}
}
Expand Down Expand Up @@ -396,7 +396,7 @@
}
},
"tags": [
"Nav"
"Colum"
],
"parameters": [
{
Expand All @@ -410,13 +410,13 @@
}
}
],
"operationId": "put/navs/{id}",
"operationId": "put/colums/{id}",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NavRequest"
"$ref": "#/components/schemas/ColumRequest"
}
}
}
Expand Down Expand Up @@ -487,7 +487,7 @@
}
},
"tags": [
"Nav"
"Colum"
],
"parameters": [
{
Expand All @@ -501,7 +501,7 @@
}
}
],
"operationId": "delete/navs/{id}"
"operationId": "delete/colums/{id}"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

/**
* nav router
* colum router
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::nav.nav');
module.exports = createCoreRouter('api::colum.colum');
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

/**
* post service
* colum service
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::post.post');
module.exports = createCoreService('api::colum.colum');
55 changes: 55 additions & 0 deletions backend/src/api/global/content-types/global/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"kind": "singleType",
"collectionName": "globals",
"info": {
"singularName": "global",
"pluralName": "globals",
"displayName": "global",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"gadgets": {
"type": "component",
"repeatable": false,
"component": "layouts.gadgets",
"required": true
},
"favicon": {
"type": "text",
"unique": true,
"required": true
},
"siteName": {
"type": "string",
"required": true,
"unique": true
},
"navs": {
"type": "component",
"repeatable": true,
"component": "layouts.navs",
"required": true
},
"links": {
"type": "component",
"repeatable": true,
"component": "layouts.links",
"required": true
},
"ads": {
"type": "component",
"repeatable": true,
"component": "layouts.ads",
"required": true
},
"footers": {
"type": "component",
"repeatable": true,
"component": "layouts.footers"
}
}
}
9 changes: 9 additions & 0 deletions backend/src/api/global/controllers/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* global controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::global.global');
Loading

0 comments on commit 127fcb9

Please sign in to comment.