123456789101112131415161718192021222324252627282930 |
- 'use strict';
- const assert = require('assert');
- const _ = require('lodash');
- const {ObjectId} = require('mongoose').Types;
- const {CrudService} = require('naf-framework-mongoose/lib/service');
- const {BusinessError, ErrorCode} = require('naf-core').Error;
- class TDigitalServiceService extends CrudService {
- constructor(ctx) {
- super(ctx, 't_digital_service');
- this.model = this.ctx.model.TDigitalService;
- }
- // 重写创建方法
- async create(data) {
- const {type, title, phone} = data;
- assert(type && title && phone, '缺少部分信息项');
- assert(/^\d{11}$/i.test(phone), 'phone无效');
- /*const temp = await this.model.findOne({type, title});
- if (temp) {
- throw new BusinessError(ErrorCode.DATA_EXISTED);
- }*/
- const res = await this.model.create(data);
- return res;
- }
- }
- module.exports = TDigitalServiceService;
|