---
# System prepended metadata

title: CMS

---

# CMS


## DAO
`feature/cms`

```csharp=
public enum ContentStatus {
    DRAFT,
    PUBLISHED,
    UNPUBLISHED
}

public class Content: Entity {

    public ContentStatus Status;
    public DateTime? PublishedAt;
    public List<Section> Sections;
}
```


```csharp=
public class Section: Entity {
    public int Sequence;
    
    public Locale Name;
    
    public SectionType SectionType;
    public SectionVariant Variant;
    
    public List<SectionBody> SectionBody;
        
    public SectionStatus SectionStatus;
}

public enum SectionStatus {
    ACTIVE,
    INACTIVE
}

public enum SectionType {
    HEADER_BANNER,
    HERO_BANNER,
    PRODUCT,
    STORE,
    MALL,
    SECTION_BANNER
}

public enum SectionVariant {
    NA,
    SINGLE,
    GROUP
}

public enum UrlType {
    ABSOLUTE,
    RELATIVE
}

public class SectionUrl {
    public string Url;
    public UrlType UrlType;
}

public class DateTimePeriod {
    public DateTime Start;
    public DateTime End;
}

public class SectionImage {
    public Image Website;
    public Image Mobile;
    public Locale Description;
}

public class SectionBody {
    public int Sequence;
    public Locale Name;
    public SectionUrl Url;
    public List<SectionImage> Images;
    public SectionCriteria? SectionCriteria;
}

public class SectionCreationCriteria {
    public DateTimePeriod? CreatedBetween;
    public int? CreatedDays;
}

public class NumberRangeCriteria {
    public decimal From;
    public decimal To;
}

public class SectionAdditionalCriteria {
    public NumberRangeCriteria? Distance;
    public int? MaxSalesWithinDays;
    public int? MaxViewsWithinDays;
    public NumberRangeCriteria? Price;
}

public class SectionCriteria {
    public SectionCreationCriteria Creation;
    public List<string> Categories;
    public List<AddressCountryCode> StoreAreas;
    public SectionAdditionalCriteria? AdditionalCriteria;
}

```


# API Schema

## For Frontpage

### GET /contents/published

```json=
{
    "sections": [
        {
            "id": "guid"
            "sequence": 1,
            "name": "Header Banner",
            "type": "HEADER_BANNER" // HEADER_BANNER,HERO_BANNER,PRODUCT,STORE,MALL,SECTION_BANNER
        },
        {
            "id": "guid"
            "sequence": 2,
            "name": "Hero Banner",
            "type": "HERO_BANNER"
        },
        {
            "id": "guid"
            "sequence": 3,
            "name": "สินค้าขายดีย์",
            "type": "PRODUCT"
        }
    ]
}
```
---

## For Admin Console

List Content Setting
### GET /console/contents
```json=
{
    "totalRecords": 3,
    "recordsPerPage": 20,
    "data": [
        {
            "id": "guid"
            "sequence": 1,
            "name": "Header Banner",
            "type": "HEADER_BANNER", // HEADER_BANNER,HERO_BANNER,PRODUCT,STORE,MALL,SECTION_BANNER
            "totalRecords": 0,
            "status": "INACTIVE"// ACTIVE,INACTIVE
        },
        {
            "id": "guid"
            "sequence": 2,
            "name": "Hero Banner",
            "type": "HERO_BANNER",
            "totalRecords": 0,
            "status": "INACTIVE"
        },
        {
            "id": "guid"
            "sequence": 3,
            "name": "สินค้าขายดีย์",
            "type": "PRODUCT",
            "totalRecords": 30,
            "status": "ACTIVE"
        }
    ],
    "createdAt": ISODateString,
    "publishedAt": ISODateString,
    "updatedBy": "Bruce Wayne"
}
```
Admin console get section detail

### GET /console/contents/sections/:guid

```json=
{
    "id": "guid",
    "sequence": 1,
    "name": {
        "en": "",
        "th": "",
        "zh": ""
    },
    "type": "PRODUCT", //HEADER_BANNER,HERO_BANNER,PRODUCT,STORE,MALL,SECTION_BANNER
    "variant": "SINGLE", // NA,SINGLE,GROUP
    "status": "ACTIVE", // ACTIVE,INACTIVE
    "body": [
        {
            "sequence": 1,
            "name": {
                "en": "",
                "th": "",
                "zh": ""
            },
            "images": [
                {
                    "url": {
                        "type":"ABSOLUTE", // absolute or relative
                        "url": "https://..."
                    },
                    "description": {
                        "en": "",
                        "th": "",
                        "zh": ""
                    },
                    "website" : { 
                        "baseUri": "https://...", 
                        "filePath": "/image.jpeg"
                    },
                    "mobile": {
                        "baseUri": "https://...", 
                        "filePath": "/image.jpeg"
                    },
                }
            ],
            "criteria": { // nullable
                "creation": {
                    "createdBetween": {
                        "start": "ISODateString",
                        "end": "ISODateString"
                    },
                    "createdDays": null, // number or null
                },
                "categories": ["110001", "110201", "1004", "1009"],
                "storeAreas": [
                    {
                        "country": "THA", // all over bangkok
                        "province": "TH-10",
                        "district": null,
                        "subdistrict": null,
                    },
                    {
                        "country": "THA", // some district of TH-11
                        "province": "TH-11",
                        "district": "TH-1101",
                        "subdistrict": null,
                    },
                ],
                "additionalCriteria": {
                    "maxSalesWithinDays": 30,
                    "maxViewsWithinDays": 7,
                    "distance": {
                        "from": 0,
                        "to": 500
                    },
                    "price": {
                        "from": 250.50,
                        "to": 1500.00
                    }
                }
            }
        }
    ]
}
```



Store
```json=
{
  "totalRecords": 1,
  "recordsPerPage": 1,
  "data": [
    {
        "name": {
            "th": string,
            "en": string,
            "zh": string
        },
        "images": [
            {
                "website": {
                    "baseUri": string,
                    "fielPath": string
                },
                "mobile": {
                    "baseUri": string,
                    "fielPath": string
                },
                "description": {
                    "th": string,
                    "en": string,
                    "zh": string
                },
                "url": {
                    "type": string, // ABSOLUTE | RELATIVE
                    "url": string
                }
            }
        ],
        "variant": string, // SINGLE | GROUP | NA
        "stores": [
            
        ]
     
}
      ]
}

```



```
[GET] <DOMAIN_MK_V2_API>/contents/published/sections/:id
```

Response 
```json=
{
    "totalRecords": 15,
    "recordsPerPage": 15,
    "data":[
        {
            "name": "",
            "variant": "NA",
            "images":[
                {
                    "website": {
                        "baseUri": "https://....",
                        "filePath": "/google/xxx.jpeg"
                    },
                    "mobile": {
                        "baseUri": "https://....",
                        "filePath": "/google/xxx.jpeg"
                    },
                    "description": "",
                    "url": {
                        "type": "RELATIVE", // ABSOLUTE | RELATIVE
                        "url": "xxx_xxx"
                    }
                }
            ]
        }
    ]
}
```


