This commit is contained in:
张成
2026-02-01 22:08:10 +08:00
parent 63ae655b34
commit 9ab749f0f3

View File

@@ -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=普通)',