ソースを参照

修改域名相关,生产配置

lrf 1 年間 前
コミット
a8bb1383f2
3 ファイル変更50 行追加32 行削除
  1. 19 0
      .vscode/launch.json
  2. 29 30
      app/service/util.js
  3. 2 2
      config/config.prod.js

+ 19 - 0
.vscode/launch.json

@@ -0,0 +1,19 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "name": "核心服务",
+      "type": "node",
+      "request": "launch",
+      "cwd": "${workspaceRoot}",
+      "runtimeExecutable": "npm",
+      "windows": { "runtimeExecutable": "npm.cmd" },
+      "runtimeArgs": ["run", "debug"],
+      "console": "integratedTerminal",
+      "protocol": "auto",
+      "restart": true,
+      "port": 9229,
+      "autoAttachChildProcesses": true
+    }
+  ]
+}

+ 29 - 30
app/service/util.js

@@ -1,6 +1,5 @@
 'use strict';
 
-
 const _ = require('lodash');
 const fs = require('fs');
 const Excel = require('exceljs');
@@ -10,6 +9,8 @@ const moment = require('moment');
 const nodemailer = require('nodemailer');
 const docx = require('docx');
 const archiver = require('archiver');
+const { ObjectId } = require('mongoose').Types;
+
 class UtilService extends CrudService {
   constructor(ctx) {
     super(ctx);
@@ -38,6 +39,7 @@ class UtilService extends CrudService {
         pass: auth_code, // 授权码
       },
     });
+    if (process.env.NODE_ENV === 'development') email = '402788946@qq.com';
     const mailOptions = {
       from: user_email, // 发送者,与上面的user一致
       to: email, // 接收者,可以同时发送多个,以逗号隔开
@@ -83,15 +85,25 @@ class UtilService extends CrudService {
     return res;
   }
   async utilMethod(query, body) {
-    // // 重置班级
-    // 找到要删除的学生
-    const res = await this.ctx.model.Student.find({ school_name: '吉林职业技术学院', planid: '60769b703cead37068645fb2', termid: { $ne: '60779c0b2ec7ac704ce301ab' } });
-    // const test = res.map(f => {
-    //   return { name: f.name, openid: f.openid, id: f._id };
-    // });
-    const ids = res.map(i => i._id);
-    await this.ctx.model.User.deleteMany({ uid: ids });
-    await this.ctx.model.Student.deleteMany({ school_name: '吉林职业技术学院', planid: '60769b703cead37068645fb2', termid: { $ne: '60779c0b2ec7ac704ce301ab' } });
+    // for (const trainPlan of allTranPlan) {
+    //   const { termnum = [] } = trainPlan;
+    //   const termids = termnum.map(f => ObjectId(f._id).toString());
+    //   // 查出该期所有的申请
+    //   const termApplys = await applyModel.find({ termid: termids }).lean();
+    //   const needDeletes = termApplys.filter(f => !(allSubject.find(s => s._id === f.subid) && allTeacher.find(t => t._id === f.teacherid)));
+    //   const deleteIds = needDeletes.map(i => i._id);
+    //   console.log(deleteIds.length);
+    //   // await applyModel.deleteMany({ _id: deleteIds });
+    // }
+    // // // 重置班级
+    // // 找到要删除的学生
+    // const res = await this.ctx.model.Student.find({ school_name: '吉林职业技术学院', planid: '60769b703cead37068645fb2', termid: { $ne: '60779c0b2ec7ac704ce301ab' } });
+    // // const test = res.map(f => {
+    // //   return { name: f.name, openid: f.openid, id: f._id };
+    // // });
+    // const ids = res.map(i => i._id);
+    // await this.ctx.model.User.deleteMany({ uid: ids });
+    // await this.ctx.model.Student.deleteMany({ school_name: '吉林职业技术学院', planid: '60769b703cead37068645fb2', termid: { $ne: '60779c0b2ec7ac704ce301ab' } });
     // const ids = res.map(i => i.openid);
     // // console.log(ids);
     //
@@ -106,15 +118,12 @@ class UtilService extends CrudService {
     // else throw new BusinessError(ErrorCode.BADPARAM, '需要重置范围');
     // await this.ctx.model.Student.updateMany(filters, { classid: undefined });
     // // 重置班级结束
-
   }
   async getQueryOptions({ skip, limit, sort, desc } = {}) {
     if (sort && _.isString(sort)) {
       sort = { [sort]: desc ? -1 : 1 };
     } else if (sort && _.isArray(sort)) {
-      sort = sort
-        .map(f => ({ [f]: desc ? -1 : 1 }))
-        .reduce((p, c) => ({ ...p, ...c }), {});
+      sort = sort.map(f => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
     }
     return { skip, limit, sort };
   }
@@ -214,11 +223,11 @@ class UtilService extends CrudService {
     // 取出预设存储地址
     const rootPath = `${app.config.cdn.repos_root_path}`;
     const rooturl = `${app.config.cdn.repos_root_url_excel}`;
-    let path = `${rootPath}${rooturl}`;
+    const path = `${rootPath}${rooturl}`;
     if (!path) {
       throw new BusinessError(ErrorCode.BUSINESS, '服务端没有设置存储路径');
     }
-    if (process.env.NODE_ENV === 'development') path = 'E:\\exportFile\\';
+    // if (process.env.NODE_ENV === 'development') path = 'E:\\exportFile\\';
     if (!fs.existsSync(path)) {
       // 如果不存在文件夹,就创建
       fs.mkdirSync(path);
@@ -228,7 +237,7 @@ class UtilService extends CrudService {
     fs.createWriteStream(filepath);
     const workbook = new Excel.Workbook();
     const sheet = workbook.addWorksheet('sheet');
-    if (meta)sheet.columns = meta;
+    if (meta) sheet.columns = meta;
     sheet.addRows(dataList);
     if (_.isArray(opera)) {
       for (const o of opera) {
@@ -279,7 +288,7 @@ class UtilService extends CrudService {
       sheet = workbook.addWorksheet('sheet');
     } else {
       let domain = 'http://127.0.0.1';
-      if (process.env.NODE_ENV === 'development')domain = `${domain}:8000`;
+      if (process.env.NODE_ENV === 'development') domain = `${domain}:8000`;
       const file = await this.ctx.curl(`${domain}${downloadPath}`);
       if (!(file && file.data)) {
         throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找导出的excel');
@@ -309,14 +318,7 @@ class UtilService extends CrudService {
    * @param {String} fn 文件名
    */
   async toDocx(data, fn = '培训心得') {
-    const {
-      Document,
-      Packer,
-      Paragraph,
-      TextRun,
-      HeadingLevel,
-      AlignmentType,
-    } = docx;
+    const { Document, Packer, Paragraph, TextRun, HeadingLevel, AlignmentType } = docx;
     const doc = new Document();
     const children = [];
     // 整理数据
@@ -387,10 +389,7 @@ class UtilService extends CrudService {
    */
   async toZip(fileList, fn = '导出结果') {
     if (!_.isArray(fileList)) {
-      throw new BusinessError(
-        ErrorCode.DATA_INVALID,
-        '需要压缩的文件数据格式错误'
-      );
+      throw new BusinessError(ErrorCode.DATA_INVALID, '需要压缩的文件数据格式错误');
     }
     fn = `${fn}.zip`;
     // zip文件夹创建

+ 2 - 2
config/config.prod.js

@@ -17,13 +17,13 @@ module.exports = () => {
 
   config.wxapi = {
     appid: 'wxd2e28415cb866c0b', // 微信公众号APPID
-    baseUrl: 'http://www.jilinjobswx.cn', // 微信网关地址
+    baseUrl: 'http://jytz.jilinjobs.cn', // 微信网关地址
     mchid: '1505364491', // 商户ID
     mchkey: '1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik9', // 商户key
     wxurl: 'http://jytz.jilinjobs.cn/api/wxpayback',
     payurl: 'https://api.mch.weixin.qq.com/pay/unifiedorder',
     sendDirMq:
-      'http://www.jilinjobswx.cn/api.weixin.qq.com/cgi-bin/message/template/send?appid=',
+      'http://jytz.jilinjobs.cn/api.weixin.qq.com/cgi-bin/message/template/send?appid=',
   };
   // 签到小程序
   config.wxapp = {