diff --git a/api/model/pricing_plans.js b/api/model/pricing_plans.js index deb6f37..4cb1652 100644 --- a/api/model/pricing_plans.js +++ b/api/model/pricing_plans.js @@ -50,9 +50,26 @@ module.exports = (db) => { }, features: { comment: '功能特性列表(JSON字符串数组)', - type: Sequelize.TEXT, + type: Sequelize.JSON(), allowNull: false, - defaultValue: '[]' + defaultValue: [], + get: function () { + const value = this.getDataValue('features'); + if (!value) return null; + if (typeof value === 'string') { + return JSON.parse(value); + } + return value; + }, + set: function (value) { + if (value === null || value === undefined) { + this.setDataValue('features', null); + } else if (typeof value === 'string') { + this.setDataValue('features', value); + } else { + this.setDataValue('features', JSON.stringify(value)); + } + }, }, featured: { comment: '是否为推荐套餐(1=推荐,0=普通)',