midway-fatcms 0.0.1-beta.3 → 0.0.1-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -134,13 +134,13 @@ exports.default = (appInfo) => {
134
134
  // 使用浏览器插件配置header信息:插件名:ModHeader - Modify HTTP headers
135
135
  // 默认值:配置key:fatcmsdebug, 配置value: headerSecret的值
136
136
  fatcmsDebug: {
137
- headerKey: 'euhvfvv5sDt19dNoerVFamhNYlLJ8ZDDYcRZhMJWNRxALxtrxLPqJSks9sRZEpKY',
138
- headerSecret: 'IlddQO1fO8X7KSwnF3KazNaNHK05Y0kYaD+1z3yGlfZpz0+aAF5hDzf7KQk2dyx0',
137
+ headerKey: 'fatcmsDebug',
138
+ headerSecret: '111',
139
139
  },
140
140
  // 是否开启SA账号。只有账号密码没有用,必须通过ModHeader插件设置如下字段
141
141
  fatcmsSAEnable: {
142
- headerKey: 'WyuX2jf8hehgXAjV5Bf22hvbK/KTEiHCM8eiQeI0FETm/UFXkcLnn3GSTUfwVrrE',
143
- headerSecret: 'lzt19Ef6HxSqg2rp6Q1M3YT+uMrTecmAm3cX1mwFZGqoXknwWdj5fTJil1Vr9AeHDIUFuOOxrU1kSSVa6h/Ppw==',
142
+ headerKey: 'fatcmsSAEnable',
143
+ headerSecret: '222',
144
144
  },
145
145
  // 是否启用内置的定时任务
146
146
  fatcmsScheduleService: true,
@@ -11,6 +11,9 @@ interface HttpGetRes {
11
11
  */
12
12
  export declare class StaticController extends BaseApiController {
13
13
  protected ctx: Context;
14
+ constructor();
15
+ private getLocalPaths;
16
+ private initNotFoundList;
14
17
  private responseLocalFile;
15
18
  proxyStaticFile(ossName: string, relativePath: string): Promise<string>;
16
19
  saveNotFoundList(): Promise<void>;
@@ -20,17 +20,17 @@ const fs2 = require("fs");
20
20
  const path = require("path");
21
21
  const https = require("https");
22
22
  const functions_1 = require("../../libs/utils/functions");
23
- const localDir = path.join(__dirname, '../../../public/static'); // 本地文件存储目录
24
- const notFoundListFile = path.join(localDir, '__404__list.json'); // 404列表文件
25
23
  function getPathConfig(ossName) {
26
24
  const remoteBaseUrlMap = {
27
25
  "cdnjsx": 'https://cdnjsx.oss-cn-shanghai.aliyuncs.com',
28
26
  "i.alicdn.com": "https://i.alicdn.com",
29
27
  "img.alicdn.com": "https://img.alicdn.com",
28
+ "at.alicdn.com": "https://at.alicdn.com",
30
29
  };
31
- const remoteBaseUrl = remoteBaseUrlMap[ossName];
30
+ let remoteBaseUrl = remoteBaseUrlMap[ossName];
32
31
  if (!remoteBaseUrl) {
33
- throw new Error(`ossName: ${ossName} 未配置`);
32
+ console.error(`getPathConfig ossName: ${ossName} 未配置`);
33
+ remoteBaseUrl = `https://${ossName}`;
34
34
  }
35
35
  return {
36
36
  remoteBaseUrl,
@@ -38,26 +38,43 @@ function getPathConfig(ossName) {
38
38
  }
39
39
  // 404列表缓存
40
40
  let notFoundList = new Set();
41
- // 初始化:加载404列表
42
- async function init() {
43
- try {
44
- // 确保本地存储目录存在
45
- await fs.mkdir(localDir, { recursive: true });
46
- const data = await fs.readFile(notFoundListFile, 'utf8');
47
- notFoundList = new Set(JSON.parse(data));
48
- console.log(`已加载${notFoundList.size}个404记录`);
49
- }
50
- catch (error) {
51
- if (error.code !== 'ENOENT') {
52
- console.error('读取404列表失败:', error);
53
- }
54
- }
55
- }
56
- init();
41
+ let notFoundListIsInit = false;
57
42
  /**
58
43
  * 静态文件代理功能
59
44
  */
60
45
  let StaticController = class StaticController extends BaseApiController_1.BaseApiController {
46
+ constructor() {
47
+ super();
48
+ this.initNotFoundList();
49
+ }
50
+ getLocalPaths() {
51
+ const appDir = this.app.getAppDir();
52
+ const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
53
+ const notFoundListFile = path.join(localDir, '__404__list.json'); // 404列表文件
54
+ return {
55
+ localDir,
56
+ notFoundListFile
57
+ };
58
+ }
59
+ async initNotFoundList() {
60
+ if (notFoundListIsInit) {
61
+ return;
62
+ }
63
+ notFoundListIsInit = true;
64
+ const { localDir, notFoundListFile } = this.getLocalPaths();
65
+ try {
66
+ // 确保本地存储目录存在
67
+ await fs.mkdir(localDir, { recursive: true });
68
+ const data = await fs.readFile(notFoundListFile, 'utf8');
69
+ notFoundList = new Set(JSON.parse(data));
70
+ console.log(`已加载${notFoundList.size}个404记录`);
71
+ }
72
+ catch (error) {
73
+ if (error.code !== 'ENOENT') {
74
+ console.error('读取404列表失败:', error);
75
+ }
76
+ }
77
+ }
61
78
  async responseLocalFile(localFilePath, localHeaderPath, relativePath) {
62
79
  const headers = {
63
80
  "Cache-Control": 'public, max-age=31536000',
@@ -107,6 +124,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
107
124
  return false;
108
125
  }
109
126
  async proxyStaticFile(ossName, relativePath) {
127
+ const { localDir } = this.getLocalPaths();
110
128
  const PATH_CONFIG = getPathConfig(ossName);
111
129
  // 构建本地路径和远程路径
112
130
  const localFilePath = path.join(localDir, ossName, "files", relativePath);
@@ -161,6 +179,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
161
179
  }
162
180
  // 保存404列表
163
181
  async saveNotFoundList() {
182
+ const { notFoundListFile } = this.getLocalPaths();
164
183
  try {
165
184
  // 确保存储404列表的目录存在
166
185
  const dir = path.dirname(notFoundListFile);
@@ -260,6 +279,7 @@ __decorate([
260
279
  __metadata("design:returntype", Promise)
261
280
  ], StaticController.prototype, "proxyStaticFile", null);
262
281
  StaticController = __decorate([
263
- (0, core_1.Controller)('/ns/static')
282
+ (0, core_1.Controller)('/ns/static'),
283
+ __metadata("design:paramtypes", [])
264
284
  ], StaticController);
265
285
  exports.StaticController = StaticController;
@@ -10,5 +10,5 @@ export declare class UserAccountManageApi extends BaseApiController {
10
10
  /**
11
11
  * 重置密码
12
12
  */
13
- chgUserPassword(): Promise<import("../../libs/utils/common-dto").CommonResult>;
13
+ chgUserPassword(): Promise<import("../..").CommonResult>;
14
14
  }
package/dist/index.d.ts CHANGED
@@ -30,10 +30,6 @@ export * from './controller/manage/SysConfigMangeApi';
30
30
  export * from './controller/manage/SystemInfoManageApi';
31
31
  export * from './controller/manage/UserAccountManageApi';
32
32
  export * from './controller/manage/WorkbenchMangeApi';
33
- export * from './controller/medstatistic/MedAdminController';
34
- export * from './controller/medstatistic/MedClientController';
35
- export * from './controller/medstatistic/MedMessageService';
36
- export * from './controller/medstatistic/MedScoreService';
37
33
  export * from './controller/myinfo/AuthController';
38
34
  export * from './controller/myinfo/MyInfoController';
39
35
  export * from './controller/render/AppRenderController';
@@ -69,3 +65,29 @@ export * from './service/curd/CurdMixService';
69
65
  export * from './service/curd/CurdProService';
70
66
  export * from './service/proxyapi/ProxyApiLoadService';
71
67
  export * from './service/proxyapi/ProxyApiService';
68
+ export * from './models/userSession';
69
+ export * from './models/bizmodels';
70
+ export * from './models/SystemEntities';
71
+ export * from './models/SystemPerm';
72
+ export * from './models/contextLogger';
73
+ export * from './models/devops';
74
+ export * from './models/SystemTables';
75
+ export * from './libs/utils/common-dto';
76
+ export * from './libs/utils/crypto-utils';
77
+ export * from './libs/utils/fatcms-request';
78
+ export * from './libs/utils/functions';
79
+ export * from './libs/utils/ordernum-utils';
80
+ export * from './libs/utils/parseConfig';
81
+ export * from './libs/crud-pro/CrudPro';
82
+ export * from './libs/crud-pro/defaultConfigs';
83
+ export * from './libs/crud-pro/exceptions';
84
+ export * from './libs/crud-pro/interfaces';
85
+ export * from './libs/crud-pro/models/ExecuteContext';
86
+ export * from './libs/crud-pro/models/FuncContext';
87
+ export * from './libs/crud-pro/models/RequestModel';
88
+ export * from './libs/crud-pro/models/SqlCfgModel';
89
+ export * from './libs/crud-pro/models/Transaction';
90
+ export * from './libs/crud-pro/models/keys';
91
+ export * from './libs/crud-pro/models/ExecuteContextFunc';
92
+ export * from './libs/crud-pro/models/RequestCfgModel';
93
+ export * from './libs/crud-pro/models/SqlSegArg';
package/dist/index.js CHANGED
@@ -48,10 +48,6 @@ __exportStar(require("./controller/manage/SysConfigMangeApi"), exports);
48
48
  __exportStar(require("./controller/manage/SystemInfoManageApi"), exports);
49
49
  __exportStar(require("./controller/manage/UserAccountManageApi"), exports);
50
50
  __exportStar(require("./controller/manage/WorkbenchMangeApi"), exports);
51
- __exportStar(require("./controller/medstatistic/MedAdminController"), exports);
52
- __exportStar(require("./controller/medstatistic/MedClientController"), exports);
53
- __exportStar(require("./controller/medstatistic/MedMessageService"), exports);
54
- __exportStar(require("./controller/medstatistic/MedScoreService"), exports);
55
51
  __exportStar(require("./controller/myinfo/AuthController"), exports);
56
52
  __exportStar(require("./controller/myinfo/MyInfoController"), exports);
57
53
  __exportStar(require("./controller/render/AppRenderController"), exports);
@@ -87,3 +83,29 @@ __exportStar(require("./service/curd/CurdMixService"), exports);
87
83
  __exportStar(require("./service/curd/CurdProService"), exports);
88
84
  __exportStar(require("./service/proxyapi/ProxyApiLoadService"), exports);
89
85
  __exportStar(require("./service/proxyapi/ProxyApiService"), exports);
86
+ __exportStar(require("./models/userSession"), exports);
87
+ __exportStar(require("./models/bizmodels"), exports);
88
+ __exportStar(require("./models/SystemEntities"), exports);
89
+ __exportStar(require("./models/SystemPerm"), exports);
90
+ __exportStar(require("./models/contextLogger"), exports);
91
+ __exportStar(require("./models/devops"), exports);
92
+ __exportStar(require("./models/SystemTables"), exports);
93
+ __exportStar(require("./libs/utils/common-dto"), exports);
94
+ __exportStar(require("./libs/utils/crypto-utils"), exports);
95
+ __exportStar(require("./libs/utils/fatcms-request"), exports);
96
+ __exportStar(require("./libs/utils/functions"), exports);
97
+ __exportStar(require("./libs/utils/ordernum-utils"), exports);
98
+ __exportStar(require("./libs/utils/parseConfig"), exports);
99
+ __exportStar(require("./libs/crud-pro/CrudPro"), exports);
100
+ __exportStar(require("./libs/crud-pro/defaultConfigs"), exports);
101
+ __exportStar(require("./libs/crud-pro/exceptions"), exports);
102
+ __exportStar(require("./libs/crud-pro/interfaces"), exports);
103
+ __exportStar(require("./libs/crud-pro/models/ExecuteContext"), exports);
104
+ __exportStar(require("./libs/crud-pro/models/FuncContext"), exports);
105
+ __exportStar(require("./libs/crud-pro/models/RequestModel"), exports);
106
+ __exportStar(require("./libs/crud-pro/models/SqlCfgModel"), exports);
107
+ __exportStar(require("./libs/crud-pro/models/Transaction"), exports);
108
+ __exportStar(require("./libs/crud-pro/models/keys"), exports);
109
+ __exportStar(require("./libs/crud-pro/models/ExecuteContextFunc"), exports);
110
+ __exportStar(require("./libs/crud-pro/models/RequestCfgModel"), exports);
111
+ __exportStar(require("./libs/crud-pro/models/SqlSegArg"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midway-fatcms",
3
- "version": "0.0.1-beta.3",
3
+ "version": "0.0.1-beta.5",
4
4
  "description": "This is a midway component sample",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -1,6 +1,7 @@
1
1
  import { All, Controller, Inject, Param } from '@midwayjs/core';
2
2
  import { Context } from '@midwayjs/koa';
3
3
  import { BaseApiController } from '../base/BaseApiController';
4
+ import * as _ from 'lodash';
4
5
  import * as fs from 'fs/promises';
5
6
  import * as fs2 from 'fs';
6
7
  import * as path from 'path';
@@ -15,19 +16,18 @@ interface HttpGetRes {
15
16
  }
16
17
 
17
18
 
18
- const localDir = path.join(__dirname, '../../../public/static'); // 本地文件存储目录
19
- const notFoundListFile = path.join(localDir, '__404__list.json') // 404列表文件
20
-
21
19
 
22
20
  function getPathConfig(ossName: string) {
23
21
  const remoteBaseUrlMap = {
24
22
  "cdnjsx": 'https://cdnjsx.oss-cn-shanghai.aliyuncs.com',
25
- "i.alicdn.com":"https://i.alicdn.com",
26
- "img.alicdn.com":"https://img.alicdn.com",
23
+ "i.alicdn.com": "https://i.alicdn.com",
24
+ "img.alicdn.com": "https://img.alicdn.com",
25
+ "at.alicdn.com": "https://at.alicdn.com",
27
26
  };
28
- const remoteBaseUrl = remoteBaseUrlMap[ossName];
27
+ let remoteBaseUrl = remoteBaseUrlMap[ossName];
29
28
  if (!remoteBaseUrl) {
30
- throw new Error(`ossName: ${ossName} 未配置`);
29
+ console.error(`getPathConfig ossName: ${ossName} 未配置`);
30
+ remoteBaseUrl = `https://${ossName}`
31
31
  }
32
32
  return {
33
33
  remoteBaseUrl,
@@ -35,28 +35,13 @@ function getPathConfig(ossName: string) {
35
35
  }
36
36
 
37
37
 
38
- // 404列表缓存
39
- let notFoundList = new Set();
40
-
41
38
 
42
- // 初始化:加载404列表
43
- async function init() {
44
- try {
45
- // 确保本地存储目录存在
46
- await fs.mkdir(localDir, { recursive: true });
47
- const data = await fs.readFile(notFoundListFile, 'utf8');
48
39
 
49
- notFoundList = new Set(JSON.parse(data));
50
- console.log(`已加载${notFoundList.size}个404记录`);
51
- } catch (error) {
52
- if (error.code !== 'ENOENT') {
53
- console.error('读取404列表失败:', error);
54
- }
55
- }
56
- }
40
+ // 404列表缓存
41
+ let notFoundList = new Set();
42
+ let notFoundListIsInit = false;
57
43
 
58
44
 
59
- init();
60
45
 
61
46
  /**
62
47
  * 静态文件代理功能
@@ -66,6 +51,44 @@ export class StaticController extends BaseApiController {
66
51
  @Inject()
67
52
  protected ctx: Context;
68
53
 
54
+ constructor() {
55
+ super();
56
+ this.initNotFoundList();
57
+ }
58
+
59
+
60
+ private getLocalPaths(): any {
61
+ const appDir = this.app.getAppDir();
62
+ const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
63
+ const notFoundListFile = path.join(localDir, '__404__list.json') // 404列表文件
64
+ return {
65
+ localDir,
66
+ notFoundListFile
67
+ }
68
+ }
69
+
70
+
71
+ private async initNotFoundList() {
72
+ if (notFoundListIsInit) {
73
+ return;
74
+ }
75
+ notFoundListIsInit = true;
76
+
77
+ const { localDir, notFoundListFile } = this.getLocalPaths();
78
+ try {
79
+ // 确保本地存储目录存在
80
+ await fs.mkdir(localDir, { recursive: true });
81
+ const data = await fs.readFile(notFoundListFile, 'utf8');
82
+
83
+ notFoundList = new Set(JSON.parse(data));
84
+ console.log(`已加载${notFoundList.size}个404记录`);
85
+ } catch (error) {
86
+ if (error.code !== 'ENOENT') {
87
+ console.error('读取404列表失败:', error);
88
+ }
89
+ }
90
+ }
91
+
69
92
  private async responseLocalFile(localFilePath: string, localHeaderPath: string, relativePath: string): Promise<boolean> {
70
93
 
71
94
  const headers = {
@@ -128,6 +151,7 @@ export class StaticController extends BaseApiController {
128
151
  @All('/:ossName/:relativePath+')
129
152
  async proxyStaticFile(@Param('ossName') ossName: string, @Param('relativePath') relativePath: string) {
130
153
 
154
+ const { localDir } = this.getLocalPaths();
131
155
  const PATH_CONFIG = getPathConfig(ossName);
132
156
 
133
157
 
@@ -195,6 +219,7 @@ export class StaticController extends BaseApiController {
195
219
 
196
220
  // 保存404列表
197
221
  async saveNotFoundList() {
222
+ const { notFoundListFile } = this.getLocalPaths();
198
223
  try {
199
224
  // 确保存储404列表的目录存在
200
225
  const dir = path.dirname(notFoundListFile);
package/src/index.ts CHANGED
@@ -30,10 +30,6 @@ export * from './controller/manage/SysConfigMangeApi';
30
30
  export * from './controller/manage/SystemInfoManageApi';
31
31
  export * from './controller/manage/UserAccountManageApi';
32
32
  export * from './controller/manage/WorkbenchMangeApi';
33
- export * from './controller/medstatistic/MedAdminController';
34
- export * from './controller/medstatistic/MedClientController';
35
- export * from './controller/medstatistic/MedMessageService';
36
- export * from './controller/medstatistic/MedScoreService';
37
33
  export * from './controller/myinfo/AuthController';
38
34
  export * from './controller/myinfo/MyInfoController';
39
35
  export * from './controller/render/AppRenderController';
@@ -69,3 +65,35 @@ export * from './service/curd/CurdMixService';
69
65
  export * from './service/curd/CurdProService';
70
66
  export * from './service/proxyapi/ProxyApiLoadService';
71
67
  export * from './service/proxyapi/ProxyApiService';
68
+ export * from './models/userSession';
69
+ export * from './models/bizmodels';
70
+ export * from './models/SystemEntities';
71
+ export * from './models/SystemPerm';
72
+ export * from './models/contextLogger';
73
+ export * from './models/devops';
74
+ export * from './models/SystemTables';
75
+
76
+
77
+ export * from './libs/utils/common-dto';
78
+ export * from './libs/utils/crypto-utils';
79
+ export * from './libs/utils/fatcms-request';
80
+ export * from './libs/utils/functions';
81
+ export * from './libs/utils/ordernum-utils';
82
+ export * from './libs/utils/parseConfig';
83
+
84
+ export * from './libs/crud-pro/CrudPro';
85
+ export * from './libs/crud-pro/defaultConfigs';
86
+ export * from './libs/crud-pro/exceptions';
87
+ export * from './libs/crud-pro/interfaces';
88
+
89
+ export * from './libs/crud-pro/models/ExecuteContext';
90
+ export * from './libs/crud-pro/models/FuncContext';
91
+ export * from './libs/crud-pro/models/RequestModel';
92
+ export * from './libs/crud-pro/models/SqlCfgModel';
93
+ export * from './libs/crud-pro/models/Transaction';
94
+ export * from './libs/crud-pro/models/keys';
95
+ export * from './libs/crud-pro/models/ExecuteContextFunc';
96
+ export * from './libs/crud-pro/models/RequestCfgModel';
97
+ export * from './libs/crud-pro/models/SqlSegArg';
98
+
99
+
@@ -1,35 +0,0 @@
1
- import { Context } from '@midwayjs/koa';
2
- import { BaseApiController } from '../base/BaseApiController';
3
- import { AuthService } from '../../service/AuthService';
4
- import { CommonResult } from '../../libs/utils/common-dto';
5
- import { WorkbenchService } from "../../service/WorkbenchService";
6
- import { SysConfigService } from "../../service/SysConfigService";
7
- import { MedScoreService } from "./MedScoreService";
8
- import { MedMessageService } from "./MedMessageService";
9
- interface IUserRechargeRule {
10
- score: number;
11
- authentication_score: number;
12
- recharge_package: any[];
13
- vip_package: any[];
14
- }
15
- /**
16
- * medstatistic 管理端
17
- */
18
- export declare class MedAdminController extends BaseApiController {
19
- protected ctx: Context;
20
- protected authService: AuthService;
21
- protected workbenchService: WorkbenchService;
22
- protected sysConfigService: SysConfigService;
23
- protected medScoreService: MedScoreService;
24
- protected medMessageService: MedMessageService;
25
- /**
26
- * 审批后自动充值30个积分
27
- */
28
- recharge_by_authentication_success(): Promise<CommonResult>;
29
- /**
30
- * 将DB中的数据同步到Redis,因为PHP的程序需要。
31
- */
32
- sync_med_user_recharge_rule_to_redis(): Promise<CommonResult>;
33
- get_med_user_recharge_rule(): Promise<IUserRechargeRule>;
34
- }
35
- export {};
@@ -1,205 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MedAdminController = void 0;
13
- const core_1 = require("@midwayjs/core");
14
- const _ = require("lodash");
15
- const BaseApiController_1 = require("../base/BaseApiController");
16
- const AuthService_1 = require("../../service/AuthService");
17
- const common_dto_1 = require("../../libs/utils/common-dto");
18
- const WorkbenchService_1 = require("../../service/WorkbenchService");
19
- const permission_middleware_1 = require("../../middleware/permission.middleware");
20
- const SysConfigService_1 = require("../../service/SysConfigService");
21
- const functions_1 = require("../../libs/utils/functions");
22
- const exceptions_1 = require("../../libs/crud-pro/exceptions");
23
- const keys_1 = require("../../libs/crud-pro/models/keys");
24
- const ordernum_utils_1 = require("../../libs/utils/ordernum-utils");
25
- const MedScoreService_1 = require("./MedScoreService");
26
- const DateTimeUtils_1 = require("../../libs/crud-pro/utils/DateTimeUtils");
27
- const MedMessageService_1 = require("./MedMessageService");
28
- const constants_1 = require("./constants");
29
- const MED_STATISTIC_DB = "medstatistic";
30
- /**
31
- * medstatistic 管理端
32
- */
33
- let MedAdminController = class MedAdminController extends BaseApiController_1.BaseApiController {
34
- /**
35
- * 审批后自动充值30个积分
36
- */
37
- async recharge_by_authentication_success() {
38
- const body = this.ctx.request.body; // {user_id}
39
- const user_id = parseInt(body.user_id); // med的C端用户user_id
40
- if (!user_id) {
41
- throw new exceptions_1.CommonException("user_id不存在");
42
- }
43
- const authRes = await this.curdMixService.executeCrudByCfg({
44
- condition: {
45
- user_id: user_id,
46
- },
47
- }, {
48
- sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
49
- sqlTable: "fa_user_authentication",
50
- sqlDatabase: MED_STATISTIC_DB,
51
- });
52
- const authResOne = authRes.getOneObj();
53
- if (!authResOne || `${authResOne.status}` !== '1') {
54
- throw new exceptions_1.CommonException("未提交认证资料或认证审批未通过");
55
- }
56
- const RECHARGE_TYPE_FOR_AUTH = '3';
57
- // 查询之前有没有通过积分认证获得积分
58
- const fa_user_rechargeRes = await this.curdMixService.executeCrudByCfg({
59
- condition: {
60
- user_id: user_id,
61
- type: RECHARGE_TYPE_FOR_AUTH
62
- },
63
- }, {
64
- sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
65
- sqlTable: "fa_user_recharge",
66
- sqlDatabase: MED_STATISTIC_DB,
67
- });
68
- const fa_user_rechargeResOne = fa_user_rechargeRes.getOneObj();
69
- if (fa_user_rechargeResOne) {
70
- return common_dto_1.CommonResult.errorRes("用户已经获得认证积分");
71
- }
72
- const rechargeRule = await this.get_med_user_recharge_rule();
73
- // 插入充值记录
74
- await this.curdMixService.executeCrudByCfg({
75
- data: {
76
- user_id: user_id,
77
- type: RECHARGE_TYPE_FOR_AUTH,
78
- paid: 1,
79
- order_no: (0, ordernum_utils_1.generateOrderNumber)('CZ'),
80
- money: 0,
81
- score: rechargeRule.authentication_score,
82
- pay_time: DateTimeUtils_1.DateTimeUtils.getCurrentTimeStampSecond(),
83
- createtime: DateTimeUtils_1.DateTimeUtils.getCurrentTimeStampSecond(),
84
- },
85
- }, {
86
- sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
87
- sqlTable: "fa_user_recharge",
88
- sqlDatabase: MED_STATISTIC_DB,
89
- });
90
- // 查询用户信息
91
- const userRes = await this.curdMixService.executeCrudByCfg({
92
- condition: {
93
- id: user_id,
94
- },
95
- }, {
96
- sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
97
- sqlTable: "fa_user",
98
- sqlDatabase: MED_STATISTIC_DB,
99
- });
100
- const userOne = userRes.getOneObj();
101
- if (!userOne) {
102
- return common_dto_1.CommonResult.errorRes("用户信息没有查询到");
103
- }
104
- // 更新用户日志。
105
- await this.medScoreService.updateScore(user_id, MedScoreService_1.UpdateScorePM.increase, rechargeRule.authentication_score, "用户认证通过获得积分");
106
- // 更新认证状态
107
- await this.curdMixService.executeCrudByCfg({
108
- condition: {
109
- id: user_id,
110
- },
111
- data: {
112
- is_authentication: 1
113
- }
114
- }, {
115
- sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
116
- sqlTable: "fa_user",
117
- sqlDatabase: MED_STATISTIC_DB,
118
- });
119
- // 发送消息
120
- // title:string, content: string, received_by: string | number, msgObj: ISendUserReceivedMsg
121
- const title = "您的身份认证请求,已经审批通过";
122
- await this.medMessageService.insertMessage(title, title, user_id, {
123
- target_object_id: authResOne.id,
124
- target_object_type: constants_1.TARGET_OBJECT_TYPE_USER_AUTHENTICATION,
125
- msg_type: constants_1.MsgType.user_auth_pass
126
- });
127
- return common_dto_1.CommonResult.successMsg('用户认证审批通过获得积分' + rechargeRule.authentication_score);
128
- }
129
- /**
130
- * 将DB中的数据同步到Redis,因为PHP的程序需要。
131
- */
132
- async sync_med_user_recharge_rule_to_redis() {
133
- const ruleObj = await this.get_med_user_recharge_rule();
134
- await this.redisService.set("score", ruleObj.score);
135
- await this.redisService.set("authentication_score", ruleObj.authentication_score);
136
- await this.redisService.set("recharge_package", JSON.stringify(ruleObj.recharge_package.map((obj0) => {
137
- const obj = {};
138
- obj.score = "" + obj0.score;
139
- obj.price = "" + obj0.price;
140
- return obj;
141
- })));
142
- await this.redisService.set("vip_package", JSON.stringify(ruleObj.vip_package.map((obj0) => {
143
- const obj = {};
144
- obj.score = "" + obj0.score;
145
- obj.day = "" + obj0.day;
146
- return obj;
147
- })));
148
- return common_dto_1.CommonResult.successRes("SUCCESS");
149
- }
150
- async get_med_user_recharge_rule() {
151
- const rowObj = await this.sysConfigService.getSysConfigOne("med_user_recharge_rule");
152
- const configContentObj = (0, functions_1.parseJsonObject)(rowObj.config_content);
153
- const configContentData = configContentObj.data || {};
154
- const recharge_package = configContentData.recharge_package || [];
155
- const vip_package = configContentData.vip_package || [];
156
- const authentication_score = Number(_.get(configContentData, 'score_setting.authentication_score')) || 30;
157
- const score = Number(_.get(configContentData, 'score_setting.score')) || 1;
158
- return {
159
- score,
160
- authentication_score,
161
- recharge_package,
162
- vip_package
163
- };
164
- }
165
- };
166
- __decorate([
167
- (0, core_1.Inject)(),
168
- __metadata("design:type", Object)
169
- ], MedAdminController.prototype, "ctx", void 0);
170
- __decorate([
171
- (0, core_1.Inject)(),
172
- __metadata("design:type", AuthService_1.AuthService)
173
- ], MedAdminController.prototype, "authService", void 0);
174
- __decorate([
175
- (0, core_1.Inject)(),
176
- __metadata("design:type", WorkbenchService_1.WorkbenchService)
177
- ], MedAdminController.prototype, "workbenchService", void 0);
178
- __decorate([
179
- (0, core_1.Inject)(),
180
- __metadata("design:type", SysConfigService_1.SysConfigService)
181
- ], MedAdminController.prototype, "sysConfigService", void 0);
182
- __decorate([
183
- (0, core_1.Inject)(),
184
- __metadata("design:type", MedScoreService_1.MedScoreService)
185
- ], MedAdminController.prototype, "medScoreService", void 0);
186
- __decorate([
187
- (0, core_1.Inject)(),
188
- __metadata("design:type", MedMessageService_1.MedMessageService)
189
- ], MedAdminController.prototype, "medMessageService", void 0);
190
- __decorate([
191
- (0, core_1.Post)('/recharge_by_authentication_success', { middleware: [(0, permission_middleware_1.checkPermission)("BizOperationUserAdmin")] }),
192
- __metadata("design:type", Function),
193
- __metadata("design:paramtypes", []),
194
- __metadata("design:returntype", Promise)
195
- ], MedAdminController.prototype, "recharge_by_authentication_success", null);
196
- __decorate([
197
- (0, core_1.Post)('/sync_med_user_recharge_rule_to_redis', { middleware: [(0, permission_middleware_1.checkPermission)("BizOperationUserAdmin")] }),
198
- __metadata("design:type", Function),
199
- __metadata("design:paramtypes", []),
200
- __metadata("design:returntype", Promise)
201
- ], MedAdminController.prototype, "sync_med_user_recharge_rule_to_redis", null);
202
- MedAdminController = __decorate([
203
- (0, core_1.Controller)('/ns/api/medadmin')
204
- ], MedAdminController);
205
- exports.MedAdminController = MedAdminController;