'use strict';


const moment = require('moment');

module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const CourseV5Category = app.classModel.define('course_v5_category', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    type: INTEGER,
    parent_id: INTEGER,
    name: STRING,
    selected_icon: STRING,
    unselected_icon: STRING,
    report_icon: STRING,
    is_open: INTEGER,
    url: STRING,
    color: STRING,
    bind: INTEGER,
    status: INTEGER,
    is_deleted: INTEGER,
    sort: INTEGER,
    created_time: {
      type: DATE,
      allowNull: true,
      get() {
        const date = this.getDataValue('created_time');
        return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
      },
    },
    updated_time: {
      type: DATE,
      allowNull: true,
      get() {
        const date = this.getDataValue('updated_time');
        return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
      },
    },
  }, {
    timestamps: false,
    tableName: 'course_v5_category',
  });

  return CourseV5Category;

};
