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.
- package/dist/config/config.default.js +4 -4
- package/dist/controller/gateway/StaticController.d.ts +3 -0
- package/dist/controller/gateway/StaticController.js +41 -21
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/index.d.ts +26 -4
- package/dist/index.js +26 -4
- package/package.json +1 -1
- package/src/controller/gateway/StaticController.ts +50 -25
- package/src/index.ts +32 -4
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
|
@@ -1,28 +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 { MedMessageService } from "./MedMessageService";
|
|
7
|
-
import { CurdProService } from "../../service/curd/CurdProService";
|
|
8
|
-
/**
|
|
9
|
-
* medstatistic 用户端
|
|
10
|
-
*/
|
|
11
|
-
export declare class MedClientController extends BaseApiController {
|
|
12
|
-
protected ctx: Context;
|
|
13
|
-
protected authService: AuthService;
|
|
14
|
-
protected workbenchService: WorkbenchService;
|
|
15
|
-
protected curdProService: CurdProService;
|
|
16
|
-
protected medMessageService: MedMessageService;
|
|
17
|
-
/**
|
|
18
|
-
* 充值
|
|
19
|
-
*/
|
|
20
|
-
recharge(): Promise<CommonResult>;
|
|
21
|
-
/**
|
|
22
|
-
* 获取用户收到的消息。只需要登录即可
|
|
23
|
-
*/
|
|
24
|
-
send_user_received_message(): Promise<CommonResult>;
|
|
25
|
-
private get_fa_contact;
|
|
26
|
-
private getBBSTopic;
|
|
27
|
-
private getBBSReply;
|
|
28
|
-
}
|
|
@@ -1,188 +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.MedClientController = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const BaseApiController_1 = require("../base/BaseApiController");
|
|
15
|
-
const AuthService_1 = require("../../service/AuthService");
|
|
16
|
-
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
17
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
18
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
|
-
const MedMessageService_1 = require("./MedMessageService");
|
|
20
|
-
const CurdProService_1 = require("../../service/curd/CurdProService");
|
|
21
|
-
const constants_1 = require("./constants");
|
|
22
|
-
const permission_middleware_1 = require("../../middleware/permission.middleware");
|
|
23
|
-
const MED_STATISTIC_DB = "medstatistic";
|
|
24
|
-
/**
|
|
25
|
-
* medstatistic 用户端
|
|
26
|
-
*/
|
|
27
|
-
let MedClientController = class MedClientController extends BaseApiController_1.BaseApiController {
|
|
28
|
-
/**
|
|
29
|
-
* 充值
|
|
30
|
-
*/
|
|
31
|
-
async recharge() {
|
|
32
|
-
// const body = this.ctx.request.body as any; // {user_id}
|
|
33
|
-
// const pay_type = body.pay_type; // 类型:1=微信,2=支付宝,3=授权
|
|
34
|
-
// const recharge_type = body.recharge_type; // 充值方式:1=套餐,2=自定义积分
|
|
35
|
-
// const package_price = body.package_price; // 套餐充值 package_price 元人民币
|
|
36
|
-
// const custom_score = body.custom_score; // 自定义充值 custom_score 元人民币
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* 获取用户收到的消息。只需要登录即可
|
|
43
|
-
*/
|
|
44
|
-
async send_user_received_message() {
|
|
45
|
-
const msgObj = this.ctx.request.body; // {user_id}
|
|
46
|
-
const { msg_type, target_object_id, target_object_type } = msgObj || {};
|
|
47
|
-
// title:string, content: string, received_by: string | number, msgObj: ISendUserReceivedMsg
|
|
48
|
-
if (target_object_type === constants_1.TARGET_OBJECT_TYPE_BBS_TOPIC) {
|
|
49
|
-
const topicObj = await this.getBBSTopic(target_object_id);
|
|
50
|
-
// 点赞了一篇帖子,发送消息 给作者
|
|
51
|
-
if (msg_type === constants_1.MsgType.bbs_post_be_like) {
|
|
52
|
-
const title = "您的帖子收到了点赞";
|
|
53
|
-
const content = `《${topicObj.title}》`;
|
|
54
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
55
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
56
|
-
}
|
|
57
|
-
// 回复了一篇帖子,发送消息 给作者
|
|
58
|
-
if (msg_type === constants_1.MsgType.bbs_post_be_reply) {
|
|
59
|
-
const title = "您的帖子收到了回复";
|
|
60
|
-
const content = `《${topicObj.title}》`;
|
|
61
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
62
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
63
|
-
}
|
|
64
|
-
// 回复帖子被判定为违规
|
|
65
|
-
if (msg_type === constants_1.MsgType.bbs_post_be_violation) {
|
|
66
|
-
const title = "您的帖子被判定为违规";
|
|
67
|
-
const content = `《${topicObj.title}》`;
|
|
68
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
69
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
70
|
-
}
|
|
71
|
-
// 您的帖子被收藏
|
|
72
|
-
if (msg_type === constants_1.MsgType.bbs_post_be_favorite) {
|
|
73
|
-
const title = "您的帖子被收藏";
|
|
74
|
-
const content = `《${topicObj.title}》`;
|
|
75
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
76
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (target_object_type === constants_1.TARGET_OBJECT_TYPE_BBS_REPLY) {
|
|
80
|
-
const topicObj = await this.getBBSReply(target_object_id);
|
|
81
|
-
// 点赞了一篇帖子,发送消息 给作者
|
|
82
|
-
if (msg_type === constants_1.MsgType.bbs_reply_be_like) {
|
|
83
|
-
const title = "您的评论收到了点赞";
|
|
84
|
-
const content = `《${topicObj.title}》`;
|
|
85
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
86
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
87
|
-
}
|
|
88
|
-
// 回复了一篇帖子,发送消息 给作者
|
|
89
|
-
if (msg_type === constants_1.MsgType.bbs_reply_be_reply) {
|
|
90
|
-
const title = "您的评论收到了回复";
|
|
91
|
-
const content = `《${topicObj.title}》`;
|
|
92
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
93
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
94
|
-
}
|
|
95
|
-
// 回复帖子被判定为违规
|
|
96
|
-
if (msg_type === constants_1.MsgType.bbs_reply_be_violation) {
|
|
97
|
-
const title = "您的评论被判定为违规";
|
|
98
|
-
const content = `《${topicObj.title}》`;
|
|
99
|
-
await this.medMessageService.insertMessage(title, content, topicObj.created_by, msgObj);
|
|
100
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// 联系我们 收到了回复
|
|
104
|
-
if (msg_type === constants_1.MsgType.contact_us_be_reply) {
|
|
105
|
-
const contactObj = await this.get_fa_contact(target_object_id);
|
|
106
|
-
this.logInfo("contact_us_be_reply==> " + JSON.stringify(contactObj));
|
|
107
|
-
if (contactObj && contactObj.created_by) {
|
|
108
|
-
const title = "您的主动联系收到了回复";
|
|
109
|
-
const content = contactObj.mark || "";
|
|
110
|
-
await this.medMessageService.insertMessage(title, content, contactObj.created_by, msgObj);
|
|
111
|
-
return common_dto_1.CommonResult.successRes("OK");
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return common_dto_1.CommonResult.successRes("NULL");
|
|
115
|
-
}
|
|
116
|
-
async get_fa_contact(fa_contact_id) {
|
|
117
|
-
const topicRes = await this.curdMixService.executeCrudByCfg({
|
|
118
|
-
condition: {
|
|
119
|
-
id: fa_contact_id,
|
|
120
|
-
},
|
|
121
|
-
}, {
|
|
122
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
123
|
-
sqlTable: "fa_contact",
|
|
124
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
125
|
-
});
|
|
126
|
-
return topicRes.getOneObj();
|
|
127
|
-
}
|
|
128
|
-
async getBBSTopic(topicId) {
|
|
129
|
-
const topicRes = await this.curdMixService.executeCrudByCfg({
|
|
130
|
-
condition: {
|
|
131
|
-
id: topicId,
|
|
132
|
-
},
|
|
133
|
-
}, {
|
|
134
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
135
|
-
sqlTable: "fatbiz_bbs_topic",
|
|
136
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
137
|
-
});
|
|
138
|
-
return topicRes.getOneObj();
|
|
139
|
-
}
|
|
140
|
-
async getBBSReply(replyId) {
|
|
141
|
-
const topicRes = await this.curdMixService.executeCrudByCfg({
|
|
142
|
-
condition: {
|
|
143
|
-
id: replyId,
|
|
144
|
-
},
|
|
145
|
-
}, {
|
|
146
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
147
|
-
sqlTable: "fatbiz_bbs_replies",
|
|
148
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
149
|
-
});
|
|
150
|
-
return topicRes.getOneObj();
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
__decorate([
|
|
154
|
-
(0, core_1.Inject)(),
|
|
155
|
-
__metadata("design:type", Object)
|
|
156
|
-
], MedClientController.prototype, "ctx", void 0);
|
|
157
|
-
__decorate([
|
|
158
|
-
(0, core_1.Inject)(),
|
|
159
|
-
__metadata("design:type", AuthService_1.AuthService)
|
|
160
|
-
], MedClientController.prototype, "authService", void 0);
|
|
161
|
-
__decorate([
|
|
162
|
-
(0, core_1.Inject)(),
|
|
163
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
164
|
-
], MedClientController.prototype, "workbenchService", void 0);
|
|
165
|
-
__decorate([
|
|
166
|
-
(0, core_1.Inject)(),
|
|
167
|
-
__metadata("design:type", CurdProService_1.CurdProService)
|
|
168
|
-
], MedClientController.prototype, "curdProService", void 0);
|
|
169
|
-
__decorate([
|
|
170
|
-
(0, core_1.Inject)(),
|
|
171
|
-
__metadata("design:type", MedMessageService_1.MedMessageService)
|
|
172
|
-
], MedClientController.prototype, "medMessageService", void 0);
|
|
173
|
-
__decorate([
|
|
174
|
-
(0, core_1.Post)('/recharge'),
|
|
175
|
-
__metadata("design:type", Function),
|
|
176
|
-
__metadata("design:paramtypes", []),
|
|
177
|
-
__metadata("design:returntype", Promise)
|
|
178
|
-
], MedClientController.prototype, "recharge", null);
|
|
179
|
-
__decorate([
|
|
180
|
-
(0, core_1.Post)('/send_user_received_message'),
|
|
181
|
-
__metadata("design:type", Function),
|
|
182
|
-
__metadata("design:paramtypes", []),
|
|
183
|
-
__metadata("design:returntype", Promise)
|
|
184
|
-
], MedClientController.prototype, "send_user_received_message", null);
|
|
185
|
-
MedClientController = __decorate([
|
|
186
|
-
(0, core_1.Controller)('/ns/api/medclient', { middleware: [(0, permission_middleware_1.checkLogin)()] })
|
|
187
|
-
], MedClientController);
|
|
188
|
-
exports.MedClientController = MedClientController;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { AuthService } from '../../service/AuthService';
|
|
3
|
-
import { WorkbenchService } from "../../service/WorkbenchService";
|
|
4
|
-
import { SysConfigService } from "../../service/SysConfigService";
|
|
5
|
-
import { BaseService } from "../../service/base/BaseService";
|
|
6
|
-
import { CurdProService } from "../../service/curd/CurdProService";
|
|
7
|
-
import { ISendUserReceivedMsg } from "./constants";
|
|
8
|
-
/**
|
|
9
|
-
* medstatistic 管理端
|
|
10
|
-
*/
|
|
11
|
-
export declare class MedMessageService extends BaseService {
|
|
12
|
-
protected ctx: Context;
|
|
13
|
-
protected authService: AuthService;
|
|
14
|
-
protected workbenchService: WorkbenchService;
|
|
15
|
-
protected sysConfigService: SysConfigService;
|
|
16
|
-
protected curdProService: CurdProService;
|
|
17
|
-
insertMessage(title: string, content: string, received_by: string | number, msgObj: ISendUserReceivedMsg): Promise<any>;
|
|
18
|
-
private insertMessageInner;
|
|
19
|
-
}
|
|
@@ -1,95 +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.MedMessageService = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const AuthService_1 = require("../../service/AuthService");
|
|
15
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
16
|
-
const SysConfigService_1 = require("../../service/SysConfigService");
|
|
17
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
18
|
-
const BaseService_1 = require("../../service/base/BaseService");
|
|
19
|
-
const CurdProService_1 = require("../../service/curd/CurdProService");
|
|
20
|
-
const md5 = require("md5");
|
|
21
|
-
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
22
|
-
const constants_1 = require("./constants");
|
|
23
|
-
/**
|
|
24
|
-
* medstatistic 管理端
|
|
25
|
-
*/
|
|
26
|
-
let MedMessageService = class MedMessageService extends BaseService_1.BaseService {
|
|
27
|
-
async insertMessage(title, content, received_by, msgObj) {
|
|
28
|
-
try {
|
|
29
|
-
return this.insertMessageInner(title, content, received_by, msgObj);
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
this.logWarn("[MedMessageService]insertMessageInner失败", e);
|
|
33
|
-
return Promise.resolve(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async insertMessageInner(title, content, received_by, msgObj) {
|
|
37
|
-
if (!(0, constants_1.isMsgType)(msgObj.msg_type)) {
|
|
38
|
-
throw new exceptions_1.CommonException("PARAM_IS_NOT_VALID", "msg_type 不正确");
|
|
39
|
-
}
|
|
40
|
-
const msg_type = msgObj.msg_type;
|
|
41
|
-
const userInfo = this.ctx.userSession.getSessionInfo();
|
|
42
|
-
const msg_key = md5(`${userInfo.accountId}_${userInfo.accountType}_${received_by}_${msg_type}_${msgObj.target_object_type}_${msgObj.target_object_id}`);
|
|
43
|
-
// 插入日志
|
|
44
|
-
const insertMessageRes = await this.curdProService.executeCrudByCfg({
|
|
45
|
-
data: {
|
|
46
|
-
title: title,
|
|
47
|
-
content: content,
|
|
48
|
-
content_length: content.length,
|
|
49
|
-
msg_status: constants_1.MsgStatus.unread,
|
|
50
|
-
msg_type: msg_type,
|
|
51
|
-
msg_key: msg_key,
|
|
52
|
-
status: 1,
|
|
53
|
-
target_object_type: msgObj.target_object_type,
|
|
54
|
-
target_object_id: msgObj.target_object_id,
|
|
55
|
-
received_by: received_by,
|
|
56
|
-
received_account_type: 'medstatistic',
|
|
57
|
-
created_by: userInfo.accountId,
|
|
58
|
-
created_account_type: userInfo.accountType,
|
|
59
|
-
created_nickname: userInfo.nickName,
|
|
60
|
-
created_avatar: userInfo.avatar,
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
64
|
-
sqlTable: "fatbiz_bbs_message",
|
|
65
|
-
sqlDatabase: constants_1.MED_STATISTIC_DB,
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
insertMessageRes,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
__decorate([
|
|
73
|
-
(0, core_1.Inject)(),
|
|
74
|
-
__metadata("design:type", Object)
|
|
75
|
-
], MedMessageService.prototype, "ctx", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
(0, core_1.Inject)(),
|
|
78
|
-
__metadata("design:type", AuthService_1.AuthService)
|
|
79
|
-
], MedMessageService.prototype, "authService", void 0);
|
|
80
|
-
__decorate([
|
|
81
|
-
(0, core_1.Inject)(),
|
|
82
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
83
|
-
], MedMessageService.prototype, "workbenchService", void 0);
|
|
84
|
-
__decorate([
|
|
85
|
-
(0, core_1.Inject)(),
|
|
86
|
-
__metadata("design:type", SysConfigService_1.SysConfigService)
|
|
87
|
-
], MedMessageService.prototype, "sysConfigService", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, core_1.Inject)(),
|
|
90
|
-
__metadata("design:type", CurdProService_1.CurdProService)
|
|
91
|
-
], MedMessageService.prototype, "curdProService", void 0);
|
|
92
|
-
MedMessageService = __decorate([
|
|
93
|
-
(0, core_1.Provide)()
|
|
94
|
-
], MedMessageService);
|
|
95
|
-
exports.MedMessageService = MedMessageService;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { AuthService } from '../../service/AuthService';
|
|
3
|
-
import { WorkbenchService } from "../../service/WorkbenchService";
|
|
4
|
-
import { SysConfigService } from "../../service/SysConfigService";
|
|
5
|
-
import { BaseService } from "../../service/base/BaseService";
|
|
6
|
-
import { CurdProService } from "../../service/curd/CurdProService";
|
|
7
|
-
export declare enum UpdateScorePM {
|
|
8
|
-
decrease = 0,
|
|
9
|
-
increase = 1
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* medstatistic 管理端
|
|
13
|
-
*/
|
|
14
|
-
export declare class MedScoreService extends BaseService {
|
|
15
|
-
protected ctx: Context;
|
|
16
|
-
protected authService: AuthService;
|
|
17
|
-
protected workbenchService: WorkbenchService;
|
|
18
|
-
protected sysConfigService: SysConfigService;
|
|
19
|
-
protected curdProService: CurdProService;
|
|
20
|
-
updateScore(user_id: number, pm: UpdateScorePM, score: number, memo: string): Promise<any>;
|
|
21
|
-
}
|
|
@@ -1,107 +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.MedScoreService = exports.UpdateScorePM = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const AuthService_1 = require("../../service/AuthService");
|
|
15
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
16
|
-
const SysConfigService_1 = require("../../service/SysConfigService");
|
|
17
|
-
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
18
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
|
-
const BaseService_1 = require("../../service/base/BaseService");
|
|
20
|
-
const CurdProService_1 = require("../../service/curd/CurdProService");
|
|
21
|
-
const MED_STATISTIC_DB = "medstatistic";
|
|
22
|
-
// 类型:1=增加,0=减少
|
|
23
|
-
var UpdateScorePM;
|
|
24
|
-
(function (UpdateScorePM) {
|
|
25
|
-
UpdateScorePM[UpdateScorePM["decrease"] = 0] = "decrease";
|
|
26
|
-
UpdateScorePM[UpdateScorePM["increase"] = 1] = "increase"; // 增加
|
|
27
|
-
})(UpdateScorePM = exports.UpdateScorePM || (exports.UpdateScorePM = {}));
|
|
28
|
-
/**
|
|
29
|
-
* medstatistic 管理端
|
|
30
|
-
*/
|
|
31
|
-
let MedScoreService = class MedScoreService extends BaseService_1.BaseService {
|
|
32
|
-
async updateScore(user_id, pm, score, memo) {
|
|
33
|
-
// 查询用户信息
|
|
34
|
-
const userRes = await this.curdProService.executeCrudByCfg({
|
|
35
|
-
condition: {
|
|
36
|
-
id: user_id,
|
|
37
|
-
},
|
|
38
|
-
}, {
|
|
39
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
40
|
-
sqlTable: "fa_user",
|
|
41
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
42
|
-
});
|
|
43
|
-
const userOne = userRes.getOneObj();
|
|
44
|
-
if (!userOne) {
|
|
45
|
-
throw new exceptions_1.CommonException('USER_NOT_EXIST', "用户信息没有查询到");
|
|
46
|
-
}
|
|
47
|
-
const beforeScore = Math.max(0, parseInt(userOne.score) || 0);
|
|
48
|
-
const afterScore = pm === UpdateScorePM.decrease ? (beforeScore - score) : (beforeScore + score);
|
|
49
|
-
// 插入日志
|
|
50
|
-
const insertLogRes = await this.curdProService.executeCrudByCfg({
|
|
51
|
-
data: {
|
|
52
|
-
user_id: user_id,
|
|
53
|
-
pm: pm,
|
|
54
|
-
score: score,
|
|
55
|
-
before: beforeScore,
|
|
56
|
-
after: afterScore,
|
|
57
|
-
memo: memo,
|
|
58
|
-
createtime: Math.floor(Date.now() / 1000),
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
62
|
-
sqlTable: "fa_user_score_log",
|
|
63
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
64
|
-
});
|
|
65
|
-
// 更新User余额
|
|
66
|
-
const updateUserRes = await this.curdProService.executeCrudByCfg({
|
|
67
|
-
condition: {
|
|
68
|
-
id: user_id,
|
|
69
|
-
},
|
|
70
|
-
data: {
|
|
71
|
-
score: afterScore,
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
75
|
-
sqlTable: "fa_user",
|
|
76
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
insertLogRes,
|
|
80
|
-
updateUserRes
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
__decorate([
|
|
85
|
-
(0, core_1.Inject)(),
|
|
86
|
-
__metadata("design:type", Object)
|
|
87
|
-
], MedScoreService.prototype, "ctx", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, core_1.Inject)(),
|
|
90
|
-
__metadata("design:type", AuthService_1.AuthService)
|
|
91
|
-
], MedScoreService.prototype, "authService", void 0);
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, core_1.Inject)(),
|
|
94
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
95
|
-
], MedScoreService.prototype, "workbenchService", void 0);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, core_1.Inject)(),
|
|
98
|
-
__metadata("design:type", SysConfigService_1.SysConfigService)
|
|
99
|
-
], MedScoreService.prototype, "sysConfigService", void 0);
|
|
100
|
-
__decorate([
|
|
101
|
-
(0, core_1.Inject)(),
|
|
102
|
-
__metadata("design:type", CurdProService_1.CurdProService)
|
|
103
|
-
], MedScoreService.prototype, "curdProService", void 0);
|
|
104
|
-
MedScoreService = __decorate([
|
|
105
|
-
(0, core_1.Provide)()
|
|
106
|
-
], MedScoreService);
|
|
107
|
-
exports.MedScoreService = MedScoreService;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
declare const DEFAULT_SECTION_ID = 10002;
|
|
2
|
-
declare const TARGET_OBJECT_TYPE_BBS_TOPIC = 1;
|
|
3
|
-
declare const TARGET_OBJECT_TYPE_BBS_REPLY = 2;
|
|
4
|
-
declare const TARGET_OBJECT_TYPE_BBS_GUIDE = 3;
|
|
5
|
-
declare const TARGET_OBJECT_TYPE_CONTACT_US = 4;
|
|
6
|
-
declare const TARGET_OBJECT_TYPE_USER_AUTHENTICATION = 5;
|
|
7
|
-
export { DEFAULT_SECTION_ID, TARGET_OBJECT_TYPE_BBS_TOPIC, TARGET_OBJECT_TYPE_BBS_REPLY, TARGET_OBJECT_TYPE_BBS_GUIDE, TARGET_OBJECT_TYPE_CONTACT_US, TARGET_OBJECT_TYPE_USER_AUTHENTICATION };
|
|
8
|
-
export declare const MED_STATISTIC_DB = "medstatistic";
|
|
9
|
-
export declare enum MsgStatus {
|
|
10
|
-
unread = 0,
|
|
11
|
-
read = 1
|
|
12
|
-
}
|
|
13
|
-
export declare enum MsgType {
|
|
14
|
-
unknown = 0,
|
|
15
|
-
user_auth_pass = 1,
|
|
16
|
-
bbs_post_be_like = 2,
|
|
17
|
-
bbs_post_be_reply = 3,
|
|
18
|
-
bbs_post_be_violation = 4,
|
|
19
|
-
bbs_reply_be_like = 5,
|
|
20
|
-
bbs_reply_be_reply = 6,
|
|
21
|
-
bbs_reply_be_violation = 7,
|
|
22
|
-
contact_us_be_reply = 8,
|
|
23
|
-
bbs_post_be_favorite = 9
|
|
24
|
-
}
|
|
25
|
-
export declare function isMsgType(value: number): boolean;
|
|
26
|
-
export interface IMedTargetObj {
|
|
27
|
-
target_object_id: number;
|
|
28
|
-
target_object_type: number;
|
|
29
|
-
}
|
|
30
|
-
export interface ISendUserReceivedMsg extends IMedTargetObj {
|
|
31
|
-
msg_type: MsgType;
|
|
32
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMsgType = exports.MsgType = exports.MsgStatus = exports.MED_STATISTIC_DB = exports.TARGET_OBJECT_TYPE_USER_AUTHENTICATION = exports.TARGET_OBJECT_TYPE_CONTACT_US = exports.TARGET_OBJECT_TYPE_BBS_GUIDE = exports.TARGET_OBJECT_TYPE_BBS_REPLY = exports.TARGET_OBJECT_TYPE_BBS_TOPIC = exports.DEFAULT_SECTION_ID = void 0;
|
|
4
|
-
const DEFAULT_SECTION_ID = 10002;
|
|
5
|
-
exports.DEFAULT_SECTION_ID = DEFAULT_SECTION_ID;
|
|
6
|
-
const TARGET_OBJECT_TYPE_BBS_TOPIC = 1; // bbs_topic (1)
|
|
7
|
-
exports.TARGET_OBJECT_TYPE_BBS_TOPIC = TARGET_OBJECT_TYPE_BBS_TOPIC;
|
|
8
|
-
const TARGET_OBJECT_TYPE_BBS_REPLY = 2; // bbs_reply (2)
|
|
9
|
-
exports.TARGET_OBJECT_TYPE_BBS_REPLY = TARGET_OBJECT_TYPE_BBS_REPLY;
|
|
10
|
-
const TARGET_OBJECT_TYPE_BBS_GUIDE = 3; // bbs_reply (3) // 教程
|
|
11
|
-
exports.TARGET_OBJECT_TYPE_BBS_GUIDE = TARGET_OBJECT_TYPE_BBS_GUIDE;
|
|
12
|
-
const TARGET_OBJECT_TYPE_CONTACT_US = 4; // // 联系我们
|
|
13
|
-
exports.TARGET_OBJECT_TYPE_CONTACT_US = TARGET_OBJECT_TYPE_CONTACT_US;
|
|
14
|
-
const TARGET_OBJECT_TYPE_USER_AUTHENTICATION = 5; // // 用户身份认证
|
|
15
|
-
exports.TARGET_OBJECT_TYPE_USER_AUTHENTICATION = TARGET_OBJECT_TYPE_USER_AUTHENTICATION;
|
|
16
|
-
exports.MED_STATISTIC_DB = "medstatistic";
|
|
17
|
-
// 状态;0 未读, 1 已读
|
|
18
|
-
var MsgStatus;
|
|
19
|
-
(function (MsgStatus) {
|
|
20
|
-
MsgStatus[MsgStatus["unread"] = 0] = "unread";
|
|
21
|
-
MsgStatus[MsgStatus["read"] = 1] = "read"; // 增加
|
|
22
|
-
})(MsgStatus = exports.MsgStatus || (exports.MsgStatus = {}));
|
|
23
|
-
// 状态;0 未读, 1 已读
|
|
24
|
-
var MsgType;
|
|
25
|
-
(function (MsgType) {
|
|
26
|
-
MsgType[MsgType["unknown"] = 0] = "unknown";
|
|
27
|
-
MsgType[MsgType["user_auth_pass"] = 1] = "user_auth_pass";
|
|
28
|
-
MsgType[MsgType["bbs_post_be_like"] = 2] = "bbs_post_be_like";
|
|
29
|
-
MsgType[MsgType["bbs_post_be_reply"] = 3] = "bbs_post_be_reply";
|
|
30
|
-
MsgType[MsgType["bbs_post_be_violation"] = 4] = "bbs_post_be_violation";
|
|
31
|
-
MsgType[MsgType["bbs_reply_be_like"] = 5] = "bbs_reply_be_like";
|
|
32
|
-
MsgType[MsgType["bbs_reply_be_reply"] = 6] = "bbs_reply_be_reply";
|
|
33
|
-
MsgType[MsgType["bbs_reply_be_violation"] = 7] = "bbs_reply_be_violation";
|
|
34
|
-
MsgType[MsgType["contact_us_be_reply"] = 8] = "contact_us_be_reply";
|
|
35
|
-
MsgType[MsgType["bbs_post_be_favorite"] = 9] = "bbs_post_be_favorite";
|
|
36
|
-
})(MsgType = exports.MsgType || (exports.MsgType = {}));
|
|
37
|
-
function isMsgType(value) {
|
|
38
|
-
if (typeof value === "undefined") {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return Object.values(MsgType).includes(value);
|
|
42
|
-
}
|
|
43
|
-
exports.isMsgType = isMsgType;
|