| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | 
							- 'use strict';
 
- /**
 
-  *
 
-  *
 
-  * @author Mai
 
-  * @date
 
-  * @version
 
-  */
 
- module.exports = app => {
 
-     class ExternalData extends app.BaseService {
 
-         /**
 
-          * 构造函数
 
-          * @param ctx
 
-          */
 
-         constructor(ctx) {
 
-             super(ctx);
 
-             this.tableName = 'external_data';
 
-         }
 
-         async getExValue(tid, sid, ex_type, ex_field) {
 
-             const result = await this.getDataByCondition({
 
-                 tid: tid, sid: sid,
 
-                 ex_type: ex_type, ex_field: ex_field
 
-             });
 
-             return result && result.ex_value !== null ? JSON.parse(result.ex_value) : null;
 
-         }
 
-         async saveExValue(tid, sid, ex_type, ex_field, ex_value) {
 
-             const filter = {
 
-                 tid: tid, sid: sid,
 
-                 ex_type: ex_type, ex_field: ex_field
 
-             };
 
-             const count = await this.count(filter);
 
-             if (count >= 0) {
 
-                 await this.db.update(this.tableName, { ex_value: JSON.stringify(ex_value) }, filter);
 
-             } else {
 
-                 filter.ex_value = JSON.stringify(ex_value);
 
-                 await this.db.insert(this.tableName, filter);
 
-             }
 
-         }
 
-     }
 
-     return ExternalData;
 
- };
 
 
  |