| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- /**
- * Created by Macheng on 2021/04/26 .
- */
- import BaseModel from './baseModel'
- class DbConf extends BaseModel {
- id = 'default' // 数据库ID
- type = 0 // 数据库类型 1: Redis, 2: MySQL, 3: SQLite
- dbStatus = 0 // 运行状态 0: disconnect, 1: connect
- ip = '127.0.0.1' // IP
- port = 0 // Port
- user = '' // 用户名
- password = '' // 密码
- dbName = '' // 默认数据名称
- constructor(opts) {
- if (!opts) opts = {}
- super(opts)
- this.init(opts)
- }
- init(opts) {
- if (!opts) opts = {}
- super.init(opts)
- this.id = opts['id'] || this.id
- this.type = Number(opts['type']) || this.type
- this.dbStatus = Number(opts['dbStatus'])
- this.ip = opts['ip'] || this.ip
- this.port = Number(opts['port']) || this.port
- this.user = opts['user'] || this.user
- this.password = opts['password'] || this.password
- this.dbName = opts['dbName'] || this.dbName
- }
- toJson() {
- const obj1 = super.toJson()
- const obj2 = {
- id: this.id,
- type: this.type,
- dbStatus: this.dbStatus,
- ip: this.ip,
- port: this.port,
- user: this.user,
- password: this.password,
- dbName: this.dbName
- }
- return Object.assign({}, obj1, obj2)
- }
- }
- export default DbConf
|