Spaces:
Sleeping
Sleeping
| /** | |
| * Copyright (c) 2018, OBCon Inc. | |
| * All rights reserved. | |
| */ | |
| /** | |
| * @file | |
| * @copyright OBCon Inc. Korea 2018 | |
| * @author gye hyun james kim [pnuskgh@gmail.com] | |
| */ | |
| //--- http://docs.sequelizejs.com/ | |
| let Sequelize = require('sequelize'); | |
| let Model = utils.getClass('include', 'model.js'); | |
| class ServicesModel extends Model { | |
| constructor() { | |
| super(); | |
| this._title = '서비스'; | |
| this._database = db.db_scada; | |
| this._tableName = 'service'; | |
| } | |
| get fields() { | |
| return Object.assign({ | |
| host: { | |
| type: Sequelize.STRING(62), | |
| allowNull: false, | |
| defaultValue: 'scada.obcon.biz', | |
| validate: { | |
| }, | |
| title: '호스트', | |
| strType: 'string' | |
| }, | |
| port: { | |
| type: Sequelize.INTEGER(8), | |
| allowNull: false, | |
| defaultValue: 80, | |
| validate: { | |
| }, | |
| title: '포트', | |
| strType: 'integer' | |
| }, | |
| version: { | |
| type: Sequelize.STRING(8), | |
| allowNull: false, | |
| defaultValue: '0.00.000', | |
| validate: { | |
| }, | |
| title: '버전', | |
| strType: 'string' | |
| }, | |
| userName: { | |
| type: Sequelize.STRING(32), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '담당자 이름', | |
| strType: 'string' | |
| }, | |
| userTitle: { | |
| type: Sequelize.STRING(32), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '직책', | |
| strType: 'string' | |
| }, | |
| userEmail: { | |
| type: Sequelize.STRING(64), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '이메일', | |
| strType: 'string' | |
| }, | |
| userPhone: { | |
| type: Sequelize.STRING(32), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '전화', | |
| strType: 'string' | |
| }, | |
| category: { | |
| type: Sequelize.STRING(32), | |
| allowNull: false, | |
| defaultValue: 'OBCon', | |
| validate: { | |
| }, | |
| title: '서비스', | |
| strType: 'select', | |
| enum: [ | |
| ['OBCon', 'OBCon'], | |
| ['OBCon Android', 'OBCon Android'], | |
| ['Raspberry Pi IoT', 'Raspberry Pi IoT'], | |
| ['OBCon Stock', 'OBCon Stock'], | |
| ['OBCon CRM', 'OBCon CRM'], | |
| ['MediaWiki', 'MediaWiki'], ['WordPress', 'WordPress'] | |
| ] | |
| }, | |
| subCategory: { | |
| type: Sequelize.STRING(16), | |
| allowNull: false, | |
| defaultValue: 'Other', | |
| validate: { | |
| }, | |
| title: '서비스 분류', | |
| strType: 'select', | |
| enum: [ | |
| ['SCADA', 'SCADA'], ['CMS', 'CMS'], ['Stock', 'Stock'], ['IoT', 'IoT'], ['Open API', 'Open API'], | |
| ['Other', '--없음--'] | |
| ] | |
| }, | |
| type: { | |
| type: Sequelize.STRING(16), | |
| allowNull: false, | |
| defaultValue: 'Serviced', | |
| validate: { | |
| }, | |
| title: '타입', | |
| strType: 'select', | |
| enum: [ ['', '--없음--'], ['Serviced', 'Serviced'], ['Standalone', 'Standalone'] ] | |
| }, | |
| status: { | |
| type: Sequelize.STRING(8), | |
| allowNull: false, | |
| defaultValue: 'Active', | |
| validate: { | |
| }, | |
| title: '상태', | |
| strType: 'select', | |
| enum: [ ['Active', 'Active'], ['Inactive', 'Inactive'] ] //--- [value, title]의 배열 | |
| }, | |
| dateStart: { | |
| type: Sequelize.STRING(10), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '서비스 개시일', | |
| strType: 'string' | |
| }, | |
| dateEnd: { | |
| type: Sequelize.STRING(10), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '서비스 종료일', | |
| strType: 'string' | |
| }, | |
| authenticateId: { | |
| type: Sequelize.STRING(64), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '아이디', | |
| strType: 'string' | |
| }, | |
| hash: { | |
| type: Sequelize.STRING(64), | |
| allowNull: true, | |
| validate: { | |
| }, | |
| title: '비밀번호', | |
| strType: 'string' | |
| } | |
| }, super.fields); | |
| } | |
| //--- 데이터 초기화 | |
| init() { | |
| // this.table.drop(); | |
| this.table | |
| .sync() //--- Table이 없는 경우 생성 | |
| .then(function() { //--- Default data 생성 | |
| let query = { where: { deleted: false } }; | |
| this.table.findAll(query) | |
| .then(function(data) { | |
| if (data.length == 0) { | |
| this.table.create({ | |
| name: 'OBCon SCADA', | |
| host: 'scada.obcon.biz', | |
| port: 80, | |
| userName: '김계현', | |
| userTitle: '이사', | |
| userEmail: 'ghkim@obcon.biz', | |
| userPhone: '010-4667-1106', | |
| type: 'Serviced', | |
| status: 'Active', | |
| description: '', | |
| assignedUserId: 1, | |
| createdBy: 1, | |
| updatedBy: 1, | |
| deleted: false | |
| }).catch(utils.obj.loggerError); | |
| } | |
| }.bind(this)); | |
| }.bind(this)); | |
| } | |
| } | |
| module.exports = ServicesModel; | |