Spaces:
Sleeping
Sleeping
| /** | |
| * Copyright (c) 2018~2019, OBCon Inc. | |
| * All rights reserved. | |
| */ | |
| /** | |
| * @file | |
| * @copyright OBCon Inc. Korea 2018~2019 | |
| * @author gye hyun james kim [pnuskgh@gmail.com] | |
| */ | |
| //--- http://docs.sequelizejs.com/ | |
| let Sequelize = require('sequelize'); | |
| let Model = utils.getClass('include', 'model.js'); | |
| //--- Setting Class는 정적인 설정을 관리하고 | |
| //--- Setting 모듈은 동적인 설정을 관리 한다. | |
| /* | |
| SELECT id, site, moduleName, moduleId, category, name | |
| FROM settings | |
| ORDER BY site ASC, category ASC, name ASC, moduleName ASC, moduleId ASC; | |
| */ | |
| class SettingsModel extends Model { | |
| constructor() { | |
| super(); | |
| this._title = '설정'; | |
| this._database = db.db_scada; | |
| this._tableName = 'setting'; | |
| } | |
| get fields() { | |
| let fields = Object.assign({ | |
| site: { //--- 0. service별 설정, 기타. 사이트별 설정 | |
| type: Sequelize.INTEGER(11), | |
| allowNull: true, | |
| defaultValue: 0, | |
| validate: { | |
| }, | |
| title: '사이트', | |
| strType: 'integer' | |
| }, | |
| moduleName: { //--- 모듈 이름 (단수 형태) | |
| type: Sequelize.STRING(32), | |
| allowNull: true, | |
| defaultValue: '', | |
| validate: { | |
| }, | |
| title: '모듈 이름', | |
| strType: 'string' | |
| }, | |
| moduleId: { //--- 0. 모듈의 전역 설정, 기타. 모듈별 설정 | |
| type: Sequelize.INTEGER(11), | |
| allowNull: true, | |
| defaultValue: 0, | |
| validate: { | |
| }, | |
| title: '모듈', | |
| strType: 'integer' | |
| }, | |
| category: { //--- 분류 | |
| type: Sequelize.STRING(72), | |
| allowNull: true, | |
| defaultValue: '', | |
| validate: { | |
| }, | |
| title: '분류', | |
| strType: 'string' | |
| }, | |
| // title: { //--- name 필드를 대신 사용함 | |
| // type: Sequelize.STRING(72), | |
| // allowNull: true, | |
| // defaultValue: '', | |
| // validate: { | |
| // }, | |
| // title: '설정 이름', | |
| // strType: 'string' | |
| // }, | |
| custom: { //--- JSON 형태로 설정값을 저장 한다. | |
| type: Sequelize.STRING(10240), | |
| allowNull: true, | |
| defaultValue: '{}', | |
| validate: { | |
| }, | |
| title: '설정값', | |
| strType: 'string' | |
| } | |
| }, super.fields); | |
| return fields; | |
| } | |
| newRecord(site, moduleName, moduleId, category, name) { | |
| let rtObj = { | |
| id: '', | |
| site: site, | |
| moduleName: moduleName, | |
| moduleId: moduleId, | |
| category: category, | |
| name: name, | |
| custom: '{}' | |
| // description: '', | |
| // assignedUserId: 1, | |
| // createdBy: 1, | |
| // updatedBy: 1, | |
| // deleted: false | |
| }; | |
| return rtObj; | |
| } | |
| } | |
| module.exports = SettingsModel; | |