From 9ab749f0f33ac1c7c9eb92a1ab2d96f87958e4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Sun, 1 Feb 2026 22:08:10 +0800 Subject: [PATCH] 1 --- api/model/pricing_plans.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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=普通)',