guhongwei 4 سال پیش
والد
کامیت
e240cf7aeb

+ 0 - 36
app/controller/.testmess.js

@@ -1,36 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: ["!title", "publish_time", "origin", "content"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["!title", "publish_time", "origin", "content"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        title: "title",
-        publish_time: "publish_time",
-        origin: "origin",
-        content: "content",
-      },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};

+ 0 - 62
app/controller/.thousand.js

@@ -1,62 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: [
-      "!title",
-      "pic",
-      "content",
-      "abstract",
-      "type",
-      "parent_id",
-      "parent",
-      "publish_time",
-      "url",
-      "info_type",
-      "is_use",
-      "news_type",
-      "origin",
-    ],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: [
-      "!title",
-      "pic",
-      "content",
-      "abstract",
-      "type",
-      "parent_id",
-      "parent",
-      "publish_time",
-      "url",
-      "info_type",
-      "is_use",
-      "news_type",
-      "origin",
-    ],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        name: "name",
-        site: "site",
-      },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};

+ 0 - 44
app/controller/company.js

@@ -1,44 +0,0 @@
-'use strict';
-
-const _ = require('lodash');
-const meta = require('./.company.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// const http = require('http');
-// const schedule = require('node-schedule');
-// 5分钟
-// const rule2 = new schedule.RecurrenceRule();
-// const times2 = [ 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56 ];
-// rule2.minute = times2;
-// schedule.scheduleJob(rule2, function() {
-//   httpGet();
-// });
-// 5秒钟
-// const rule1 = new schedule.RecurrenceRule();
-// const times1 = [ 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56 ];
-// rule1.second = times1;
-// schedule.scheduleJob(rule1, function() {
-//   httpGet();
-// });
-// 企业信息表
-class CompanyController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.company;
-  }
-}
-
-// function httpGet() {
-//   const uri = 'http://smart.jilinjobs.cn/www/index';
-//   http
-//     .get(uri, function(res) {
-//       console.log('访问个人微博状态码: ' + res.statusCode);
-//     })
-//     .on('error', function(e) {
-//       console.log('个人微博 error: ' + e.message);
-//     });
-// }
-
-
-module.exports = CrudController(CompanyController, meta);

+ 0 - 16
app/controller/testmess.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const _ = require('lodash');
-const meta = require('./.testmess.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 测试信息
-class TestmessController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.testmess;
-  }
-}
-
-module.exports = CrudController(TestmessController, meta);

+ 0 - 16
app/controller/thousand.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const _ = require('lodash');
-const meta = require('./.thousand.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-//
-class ThousandController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.thousand;
-  }
-}
-
-module.exports = CrudController(ThousandController, meta);

+ 0 - 19
app/model/testmess.js

@@ -1,19 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 测试信息
-const TestmessSchema = {
-  title: { type: String, required: false, maxLength: 200 }, // 标题
-  publish_time: { type: String, required: false, maxLength: 200 }, // 发布时间
-  origin: { type: String, required: false, maxLength: 200 }, // 来源
-  content: { type: String, required: false, maxLength: 200 }, // 内容
-};
-
-const schema = new Schema(TestmessSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Testmess', schema, 'testmess');
-};

+ 0 - 31
app/model/thousand.js

@@ -1,31 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-
-
-// 信息表
-const ThousandSchema = {
-  title: { type: String, required: false, maxLength: 128 }, // 标题
-  pic: { type: String, required: false, maxLength: 256 }, // 标题图片URL
-  content: { type: String, required: false, maxLength: 102400, select: false }, // 内容详情
-  abstract: { type: String, required: false, maxLength: 500 }, // 内容简介
-  type: { type: String, required: false, maxLength: 5 }, // 所属类型
-  parent_id: { type: String, required: false, maxLength: 64 }, // 所属id
-  parent: { type: String, required: false, maxLength: 100 }, // 所属名称
-  publish_time: String, // 发布时间
-  url: { type: String, required: false, maxLength: 256 }, // 外部链接
-  info_type: { type: String, required: false, maxLength: 256, default: '0' }, // 信息类型 0、普通 1、外链
-  is_use: { type: String, required: false, maxLength: 5 }, // 是否使用,0=>使用中;1=>已禁止
-  news_type: { type: String, default: 1, maxLength: 5 }, // 0抓取,1正常输入
-  origin: { type: String, required: false, maxLength: 200 }, // 发布来源
-};
-
-
-const schema = new Schema(ThousandSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Thousand', schema, 'market_thousand');
-};

+ 0 - 9
app/router.js

@@ -5,17 +5,8 @@
  */
 module.exports = app => {
   const { router, controller } = app;
-  // router.get('/', controller.home.index);
   // 企业信息表设置
   router.resources('company', '/api/servicetest/company', controller.company); // index、create、show、destroy
   router.post('company', '/api/servicetest/company/update/:id', controller.company.update);
 
-  // 企业信息表设置
-  router.resources('testmess', '/api/servicetest/testmess', controller.testmess); // index、create、show、destroy
-  router.post('testmess', '/api/servicetest/testmess/update/:id', controller.testmess.update);
-  // 1000万数据
-  // 信息表设置路由
-  router.resources('thousand', '/api/servicetest/thousand', controller.thousand); // index、create、show、destroy
-  router.post('thousand', '/api/servicetest/thousand/update/:id', controller.thousand.update);
-
 };

+ 0 - 22
app/schedule/schedule.js

@@ -1,22 +0,0 @@
-'use strict';
-const _ = require('lodash');
-const Subscription = require('egg').Subscription;
-class TaskPortal extends Subscription {
-  // 通过 schedule 属性来设置定时任务的执行间隔等配置
-  static get schedule() {
-    // return {
-    //   interval: '5m',
-    //   type: 'all',
-    // };
-  }
-  // // subscribe 是真正定时任务执行时被运行的函数
-  async subscribe() {
-    // const res = await this.ctx.curl('http://127.0.0.1:8081/api/servicetest/thousand', {
-    //   dataType: 'json',
-    // });
-    // console.log(res.data);
-    await this.ctx.service.thousand.create();
-  }
-}
-
-module.exports = TaskPortal;

+ 0 - 16
app/service/testmess.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const assert = require('assert');
-const _ = require('lodash');
-const { ObjectId } = require('mongoose').Types;
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { TestmessError, ErrorCode } = require('naf-core').Error;
-
-class TestmessService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'testmess');
-    this.model = this.ctx.model.Testmess;
-  }
-}
-
-module.exports = TestmessService;

+ 0 - 25
app/service/thousand.js

@@ -1,25 +0,0 @@
-'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;
-const test = require('../../test.js');
-class ThousandService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'thousand');
-    this.model = this.ctx.model.Thousand;
-  }
-  async create() {
-    for (const val of test) {
-      const res = await this.model.create(val);
-      console.log(res);
-    }
-    // const res = await this.model.create({ ...test });
-    // console.log(res);
-    // return res;
-  }
-}
-
-module.exports = ThousandService;