bs-page-config-converter

提供给C端和数据库出来的数据结构差异比较大,提供该包进行转换

Usage no npm install needed!

<script type="module">
  import bsPageConfigConverter from 'https://cdn.skypack.dev/bs-page-config-converter';
</script>

README

丙晟首页配置对象转换工具

提供给C端和数据库出来的数据结构差异比较大,提供该包进行转换

使用

引入

const {
  DTOConverter,
  BizConverter
} = require("bs-page-config-converter")

let dtoConverter = new DTOConverter()
let bizConverter = new BizConverter()

let dtoRet = dtoConverter.obj2List(bizObj) // 后台数据结构转换成C端数据结构
let bizRet = bizConverter.obj2List(dtoObj) // C端数据结构转换成后台数据结构

DTOConverter

将后台数据结构转换成C端数据结构

  let dtoConverter = new DTOConverter(options)
  ...

options

属性 默认值 描述
defaultFields ["templateId","templateParentId","templateName"] 模板公共配置字段
multipleConfig ["mainActivity","functionBall","marketingActivity","tab"] 带有多条配置信息的字段

BizConverter

将后台数据结构转换成C端数据结构

  let bizConverter = new BizConverter(options)
  ...

options

属性 默认值 描述
defaultFields ["templateId","templateParentId","templateName"] 模板公共配置字段
itemCommonConfig ["display"] 组件公共配置字段

两边数据示例

后台数据库数据格式

{
    "templateId":"",
    "templateParentId":"",
    "templateName":"",
    "componentList":[
        {
            "componentType":"theme",
            "itemList":[
                {	
                    "propertyList":[
                        {
                            "propertyTitle":"authorizePlaza",
                            "propertyValue":"0:集团统一配置/1:授权广场"
                        },
                        {
                            "propertyTitle":"themeColor",
                            "propertyValue":""
                        },
                        {
                            "propertyTitle":"topColor",
                            "propertyValue":""
                        },
                        {
                            "propertyTitle":"topTextColor",
                            "propertyValue":""
                        }
                    ]
                }
            ]
        },
        {
            "componentType":"banner",
            "display":"",
            "itemList":[
                {	
                    "propertyList":[
                        {
                            "propertyTitle":"isRandom",
                            "propertyValue":""
                        }
                    ]
                }
            ]
        },
        {
            "componentType":"mainActivity",
            "display":"",
            "itemList":[
                {	
                    "propertyList":[
                        {
                            "propertyTitle":"isRandom",
                            "propertyValue":""
                        }
                    ]
                }
            ]
        }
    ]
}

C端读取的数据格式

{
    "templateId":"",
    "templateParentId":"",
    "templateName":"",
    "theme":{
      "themeColor":"",
      "topColor":"",
      "topTextColor":""
    },
    "banner":{
        "display":"",
        "isRandom":""
    },
    "mainActivity":{
        "list":[{
            "display":"",
            "title":"",
            "img":"",
            "url":"",
            "popColor":"",
            "popImg":""
        }]
    },
    "functionBall": {
        "display":"",
        "list":[{
            "display":"",
            "authorizePlaza":"",
            "title":"",
            "img":"",
            "url":""
        }]
    },
    "plazaActivity":{
        "display":"",
        "authorizePlaza":"",
        "url":""
    },
    "shopActivity":{
        "display":""
    },
    "marketingActivity":{
        "display":"",
        "list":[{
            "display":"",
            "authorizePlaza":"",
            "title":"",
            "des":"",
            "img":"",
            "url":""
        }]
    },
    "couponList":{
        "display":""
    },
    "tab":{
        "list":[{
            "display":"",
            "authorizePlaza":"",
            "title":"",
            "img":"",
            "imgSelected":"",
            "url":""
        }]
    }
}