abiao лет назад: 4
Родитель
Сommit
5612a6ed6a

+ 51 - 0
app/models/product_commend.rb

@@ -0,0 +1,51 @@
+class ProductCommend < ActiveRecord::Base
+    has_paper_trail
+    self.table_name = 'product_commends'
+    #has_product_id
+    validates :detail,presence:true
+    belongs_to :product, :foreign_key => :product_id
+    belongs_to :wx_user, :foreign_key => :wx_user_id
+
+    rails_admin do
+        navigation_label '商品管理'
+        weight -951
+
+        list do 
+            filters [:score]
+            field :id
+            field :detail
+            field :score
+            field :product
+            field :is_enable
+            field :wx_user_id
+            field :wx_user
+            field :is_top
+            field :recommend
+        end
+
+        show do
+            field :id
+            field :detail
+            field :score
+            field :product
+            field :is_enable
+            field :wx_user_id
+            field :wx_user
+            field :is_top
+            field :recommend
+        end
+
+        edit do 
+            field :detail
+            field :score
+            field :product
+            field :is_enable
+            field :wx_user_id
+            field :wx_user
+            field :is_top
+            field :recommend
+        end 
+
+    end
+
+end

+ 18 - 0
config/locales/models/product_commend.yml

@@ -0,0 +1,18 @@
+zh-CN:
+  activerecord:
+    models:
+      commend: 商品评论管理
+    attributes:
+      commend:
+        id: ID
+        wx_user_id: 微信id
+        product_id: 商品id
+        wx_user: 微信会员
+        product: 商品
+        detail: 评论内容
+        score: 评分
+        is_enable: 是否审核
+        is_top: 是否置顶
+        recommend: 推荐程度
+        create_time: 创建时间
+        update_time: 更新时间

+ 35 - 0
db/migrate/20210220114641_create_product_commends.rb

@@ -0,0 +1,35 @@
+# encoding:utf-8
+class CreateProductCommends < ActiveRecord::Migration
+  def up
+    #商品评论管理
+    create_table :product_commends do |t|
+      #微信ID
+      t.column :wx_user_id, :integer,:null=>false, :default => 0
+      #商品ID
+      t.column :product_id, :integer,:null=>false, :default => 0
+      #订单号
+      t.column :order_id, :string,:limit => 256
+      # 文字
+      t.column :detail, :string,:limit => 256
+      #评分
+      t.column :score, :integer,:null=>false, :default => 0
+      # 状态
+      t.column :is_enable, :boolean, :default=>false
+      # 是否置顶
+      t.column :is_top, :boolean, :default=>false
+      # 推荐程度
+      t.column :recommend, :boolean, :default=>false
+      # 备注
+      t.column :remark, :string,:limit => 256
+      t.timestamps
+    end
+    add_index :product_commends, :admin_user_id
+
+  end
+
+  def down
+  	drop_table :product_commends
+  end
+end
+
+