# News

# Add News

Sử dụng API này để thêm bản ghi mới

# Endpoint

# Parameters

Name Type Description Required
companyId Number get in token payload ✔️
title String ✔️
slug String ✔️
desc String ✔️
tags String Array join() to String ✔️
categoryId Number ✔️
position String ✔️
images String ✔️
content String ✔️
titleSeo String ✔️
descSeo String ✔️
keywordSeo String ✔️
startDate String ✔️
endDate String ✔️
createdBy Number get in token payload ✔️
updatedBy Number get in token payload ✔️

# Response

{
  "status": true,
  "items": {
    "$rltAdd": [
        {
            ...<data>
        }
    ],
    "$rltUpdate": [],
    "$rltRemove": [],
    "$rltDelete": []
  }
}
curl -X POST http://localhost:3000/news/setList \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \
  --data '{
    "items": {
        "$add": [
            {
                "title": "title",
                "slug": "slug",
                "desc": "description",
                "tags": "tags",
                "categoryId": "categoryId",
                "position": "position",
                "images": "images",
                "content": "content",
                "titleSeo": "titleSeo",
                "descSeo": "descriptionSeo",
                "keywordSeo": "keywordSeo",
                "startDate": "startDate",
                "endDate": "endDate"
            }
        ]
    }
  }'

# Update News

Sử dụng API này để cập nhật nội dung

# Endpoint

# Parameters

Name Type Description Required
id Number ✔️
companyId Number get in token payload ✔️
title String ✔️
slug String ✔️
desc String ✔️
tags String Array join() to String ✔️
categoryId Number ✔️
position String ✔️
images String ✔️
content String ✔️
titleSeo String ✔️
descSeo String ✔️
keywordSeo String ✔️
startDate String ✔️
endDate String ✔️
updatedBy Number get in token payload ✔️

# Response

{
  "status": true,
  "items": {
    "$rltAdd": [],
    "$rltUpdate": [
      {
        ...<data>
      }
    ],
    "$rltRemove": [],
    "$rltDelete": []
  }
}
curl -X POST http://localhost:3000/news/setList \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \
  --data '{
    "items": {
        "$update": [
            {
                "id": 1,
                "title": "title",
                "slug": "slug",
                "desc": "description",
                "tags": "tags",
                "categoryId": "categoryId",
                "position": "position",
                "images": "images",
                "content": "content",
                "titleSeo": "titleSeo",
                "descSeo": "descriptionSeo",
                "keywordSeo": "keywordSeo",
                "startDate": "startDate",
                "endDate": "endDate"
            }
        ]
    }
  }'

# Delete News

Sử dụng API này để xóa bản ghi trên giao diện

# Endpoint

# Parameters

Name Type Description Required
id Number ✔️

# Response

{
  "status": true,
  "items": {
    "$rltAdd": [],
    "$rltUpdate": [],
    "$rltRemove": [],
    "$rltDelete": [
        {
          ...<data>
        }
    ]
  }
}
curl -X POST http://localhost:3000/news/setList \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \
  --data '{
    "items": {
        "$delete": [
            {
                "id": 1
            }
        ]
    }
  }'

# Remove News

Sử dụng API này để xóa bản ghi khỏi database

# Endpoint

# Parameters

Name Type Description Required
id Number ✔️

# Response

{
  "status": true,
  "items": {
    "$rltAdd": [],
    "$rltUpdate": [],
    "$rltRemove": [
        {
          ...<data>
        }
    ],
    "$rltDelete": []
  }
}
curl -X POST http://localhost:3000/news/setList \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \
  --data '{
    "items": {
        "$remove": [
            {
                "id": 1
            }
        ]
    }
  }'

# Get List News

Sử dụng API này để lấy danh sách News

# Endpoint

# Parameters

Name Type Description Required
companyId Number get in token payload ✔️
categoryId Number ✔️
title String
tags String Array join() to String

# Response

{
  "status": true,
  "message": "success",
  "totalRows": 2,
  "rows": [
    {
        "id": 1,
        "companyId": 1,
        "title": "title",
        "slug": "slug",
        "desc": "description",
        "tags": "tags",
        "categoryId": "categoryId",
        "position": "position",
        "images": "images",
        "content": "content",
        "titleSeo": "titleSeo",
        "descSeo": "descriptionSeo",
        "keywordSeo": "keywordSeo",
        "startDate": "startDate",
        "endDate": "endDate",
        "deleted": 0,
        "createdBy": 1,
        "updatedBy": 1,
        "createdAt": "createdAt",
        "updatedAt": "updatedAt"
    },
    {
        ...<data>
    }
  ]
}
curl -X POST http://localhost:3000/news/getListPaging \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \
  --data '{
    "title": "title",
    "categoryId": "categoryId",
    "tags": "tags"
  }'