1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * 工料机库业务逻辑
- *
- * @author CaiAoLin
- * @date 2017/8/16
- * @version
- */
- import BaseModel from "../../common/base/base_model";
- import mongoose from 'mongoose';
- const STDGLJLibMapSchema = mongoose.model('std_glj_lib_map');
- class STDGLJLibMapModel extends BaseModel {
- /**
- * 构造函数
- *
- * @return {void}
- */
- constructor() {
- let parent = super();
- parent.model = STDGLJLibMapSchema;
- parent.init();
- }
- /**
- * 获取对应的工料机库
- *
- * @param {String} compilationId
- * @return {Promise}
- */
- async getGLJLibList(compilationId) {
- let result = [];
- let gliLib = await this.findDataByCondition({deleted: false, compilationId: compilationId.toString()}, null, false);
- if (gliLib.length <= 0) {
- return result;
- }
- // 整理数据
- let gljList = [];
- for(let tmp of gliLib) {
- let tmpRation = {id: tmp.ID, name: tmp.dispName};
- if (gljList.length <= 0) {
- gljList = [tmpRation];
- } else {
- gljList.push(tmpRation);
- }
- }
- result = gljList;
- return result;
- }
- }
- export default STDGLJLibMapModel;
|