Commit 7d48d9de by chenjinjing

no message

parent 936cbd63
<config> <config>
<port>9098</port> <port>9098</port>
<sign>xxx90909082fsdahfjosadjfpoiwausjorip2hjklrhn1ioud0u124rx0qwejfokasjfolksaujfoas</sign> <sign>xxx90909082fsdahfjosadjfpoiwausjorip2hjklrhn1ioud0u124rx0qwejfokasjfolksaujfoas</sign>
<usersign>OwyCGbUkW7yHxUmYNGykhG4gsE7GVzdC8wob01VYq7olO8rbFeMuFwpOkEpJ2AnucjomnpODN</usersign>
<SECRET_TOKEN>Ngz86cuAKxblwXR9OiKSWbfkj7oZ8R0lMU8pTfpVYBDCkvtUb0ZwbaBvwWyfv2O9</SECRET_TOKEN> <SECRET_TOKEN>Ngz86cuAKxblwXR9OiKSWbfkj7oZ8R0lMU8pTfpVYBDCkvtUb0ZwbaBvwWyfv2O9</SECRET_TOKEN>
<dbServer>http://192.168.0.71:40012</dbServer> <dbServer>http://192.168.0.71:40012</dbServer>
<imgUrl>http://192.168.0.71:9098</imgUrl> <imgUrl>http://192.168.0.71:9098</imgUrl>
......
...@@ -281,7 +281,8 @@ export async function enterpriseExamineUpdate( mId, param) { ...@@ -281,7 +281,8 @@ export async function enterpriseExamineUpdate( mId, param) {
* @returns {dataList, dataCount} 列表数据,数据总量 * @returns {dataList, dataCount} 列表数据,数据总量
*/ */
export async function enterpriseManageList(enterpriseName:string, year:number, quarter:number, page:number) { export async function enterpriseManageList(enterpriseName:string, year:number, quarter:number, page:number) {
let selectParam:any = {isSubmit:enumConfig.STATE.}; // let selectParam:any = {isSubmit:enumConfig.STATE.是};
let selectParam:any = {};
if (year) selectParam.annual = `${moment(year).format("YYYY")}-01-01 00:00:00`; if (year) selectParam.annual = `${moment(year).format("YYYY")}-01-01 00:00:00`;
// 季度筛选条件 // 季度筛选条件
if (quarter) selectParam.quarter = quarter; if (quarter) selectParam.quarter = quarter;
......
...@@ -15,6 +15,7 @@ import { changeAdd, extractData } from "../util/piecemeal"; ...@@ -15,6 +15,7 @@ import { changeAdd, extractData } from "../util/piecemeal";
import { EnterpriseApplyForConfig } from "../config/splitResult/enterprise"; import { EnterpriseApplyForConfig } from "../config/splitResult/enterprise";
import { CHANGESTATE, CHANGETYPE, FUHUASTATE, RUFUSTATE, STATE } from "../config/enum/enum"; import { CHANGESTATE, CHANGETYPE, FUHUASTATE, RUFUSTATE, STATE } from "../config/enum/enum";
import { createMessageReminder } from "./message"; import { createMessageReminder } from "./message";
import { systemConfig } from "../config/serverConfig";
/** /**
...@@ -506,3 +507,104 @@ function getFileNameAndFormat(fileName: string | null | undefined): string { ...@@ -506,3 +507,104 @@ function getFileNameAndFormat(fileName: string | null | undefined): string {
return `${name.trim()}.${format}`; return `${name.trim()}.${format}`;
} }
/**
* 免登录接口(用于A程序跳转或调用)
* @param mobile 用户手机号
* @param timestamp 13位毫秒级时间戳
* @param usersign 签名
* @returns
*/
export async function autoLogin(mobile: string, timestamp: string, usersign: string) {
const FuncName = "免登录接口";
const SECRET_KEY = systemConfig.usersign;
// 1. 校验必填参数
if (!mobile || !timestamp || !usersign) {
throw new BizError(ERRORENUM.参数错误);
}
// 2. 校验时间戳是否在有效时间范围内(5分钟内)
// const currentTime = Date.now();
// const requestTime = parseInt(timestamp);
// if (isNaN(requestTime)) {
// throw new BizError(ERRORENUM.无效的时间戳);
// }
// const timeDiff = Math.abs(currentTime - requestTime);
// const FIVE_MINUTES = 5 * 60 * 1000;
// if (timeDiff > FIVE_MINUTES) {
// throw new BizError(ERRORENUM.请求已过期);
// }
// 3. 重新计算签名进行校验
// 签名算法:md5(mobile + timestamp + SECRET_KEY)
const calculatedSign = getPwdMd5(SECRET_KEY, mobile + timestamp); // 使用现有的getPwdMd5函数
if (calculatedSign !== usersign) {
throw new BizError(ERRORENUM.签名验证失败);
}
// 4. 查询用户是否存在
let enterpriseUserInfo = await selectData(
OPERATIONALDATATYPE.查询单个,
TABLENAME.企业用户表,
{phone: mobile},
["uId", "phone", "userName", "eId"]
);
// 5. 用户不存在,返回提示信息
if (!enterpriseUserInfo || !enterpriseUserInfo.uId) {
return {
isSuccess: false,
message: "用户未注册,请先注册账号",
code: "USER_NOT_REGISTERED"
};
}
// 6. 用户存在,生成新的token并更新
const newToken = getToken(enterpriseUserInfo.uId);
const updateUserInfo = {
token: newToken,
tokenMs: getMySqlMs()
};
await operationalData(
OPERATIONALDATATYPE.修改,
TABLENAME.企业用户表,
updateUserInfo,
{uId: enterpriseUserInfo.uId}
);
// 7. 准备返回的用户信息
const userInfo = {
userId: enterpriseUserInfo.uId,
userName: enterpriseUserInfo.userName,
phone: enterpriseUserInfo.phone,
token: newToken,
eId: enterpriseUserInfo.eId || ""
};
// 8. 直接返回登录成功信息
return {
isSuccess: true,
message: "自动登录成功",
dataInfo: userInfo
};
}
/**
* 生成免登录请求的签名(供A程序使用)
* @param mobile 用户手机号
* @param timestamp 13位毫秒级时间戳
* @returns usersign
*/
export function generateAutoLoginSign(mobile: string, timestamp: string): string {
const SECRET_KEY = systemConfig.usersign;
return getPwdMd5(SECRET_KEY, mobile + timestamp);
}
...@@ -45,7 +45,10 @@ export enum ERRORENUM { ...@@ -45,7 +45,10 @@ export enum ERRORENUM {
原密码错误, 原密码错误,
密码不一致, 密码不一致,
系统错误, 系统错误,
该企业当前不在迁出状态 该企业当前不在迁出状态,
签名验证失败,
请求已过期,
无效的时间戳
} }
export enum ERRORCODEENUM { export enum ERRORCODEENUM {
......
...@@ -16,7 +16,7 @@ export async function initConfig() { ...@@ -16,7 +16,7 @@ export async function initConfig() {
if (!configInfo || !configInfo.config) throw new BizError('xml中无配置'); if (!configInfo || !configInfo.config) throw new BizError('xml中无配置');
else { else {
let {port, sign, SECRET_TOKEN, dbServer, imgUrl, imgFileUrl, qcc, unZipFileUrl } = configInfo.config; let {port, sign, SECRET_TOKEN, dbServer, imgUrl, imgFileUrl, qcc, unZipFileUrl, usersign } = configInfo.config;
systemConfig.port = parseInt(port[0]); systemConfig.port = parseInt(port[0]);
systemConfig.secretToken = SECRET_TOKEN[0]; systemConfig.secretToken = SECRET_TOKEN[0];
...@@ -32,6 +32,9 @@ export async function initConfig() { ...@@ -32,6 +32,9 @@ export async function initConfig() {
systemConfig.qccSecretKey = qcc[0].SecretKey[0]; systemConfig.qccSecretKey = qcc[0].SecretKey[0];
systemConfig.unZipFileUrl = unZipFileUrl[0]; systemConfig.unZipFileUrl = unZipFileUrl[0];
/**免登录 */
systemConfig.usersign = usersign[0];
} }
console.log("config init success"); console.log("config init success");
......
...@@ -16,4 +16,6 @@ export class ServerConfig { ...@@ -16,4 +16,6 @@ export class ServerConfig {
qccKey:string; qccKey:string;
qccSecretKey:string; qccSecretKey:string;
unZipFileUrl:string; unZipFileUrl:string;
/**免登录 */
usersign:string;
} }
\ No newline at end of file
...@@ -7,9 +7,13 @@ import { updateItemQCCData } from "./biz/qccInit"; ...@@ -7,9 +7,13 @@ import { updateItemQCCData } from "./biz/qccInit";
import { initConfig, systemConfig } from "./config/serverConfig"; import { initConfig, systemConfig } from "./config/serverConfig";
import { initApiDataStorage } from "./data/dataInterfaceWithCache"; import { initApiDataStorage } from "./data/dataInterfaceWithCache";
import { httpServer } from "./net/http_server"; import { httpServer } from "./net/http_server";
import { getPwdMd5 } from "./tools/system";
async function lanuch() { async function lanuch() {
const encryptedPwd = getPwdMd5("ur_50e39e678e8bc8d19fd4b5aa98196a27", "123456");
console.log();
await initConfig(); await initConfig();
httpServer.createServer(systemConfig.port); httpServer.createServer(systemConfig.port);
console.log('This indicates that the server is started successfully.'); console.log('This indicates that the server is started successfully.');
...@@ -32,6 +36,8 @@ async function lanuch() { ...@@ -32,6 +36,8 @@ async function lanuch() {
// ] // ]
// }}; // }};
// await newDow(eIds, options); // await newDow(eIds, options);
} }
......
...@@ -5,7 +5,7 @@ import compression = require('compression'); ...@@ -5,7 +5,7 @@ import compression = require('compression');
import { watch } from '../middleware/watch'; import { watch } from '../middleware/watch';
import { httpErrorHandler } from '../middleware/httpErrorHandler'; import { httpErrorHandler } from '../middleware/httpErrorHandler';
import * as path from "path"; import * as path from "path";
import * as fallback from 'express-history-api-fallback'; import fallback from 'express-history-api-fallback';
export class httpServer { export class httpServer {
static createServer(port:number) { static createServer(port:number) {
......
...@@ -13,6 +13,8 @@ export function setRouter(httpServer) { ...@@ -13,6 +13,8 @@ export function setRouter(httpServer) {
httpServer.post('/admin/enterprise/rufu/settleininfo', asyncHandler(settleInById)); httpServer.post('/admin/enterprise/rufu/settleininfo', asyncHandler(settleInById));
httpServer.post('/admin/enterprise/rufu/info', asyncHandler(getRuFu)); httpServer.post('/admin/enterprise/rufu/info', asyncHandler(getRuFu));
httpServer.post('/admin/enterprise/rufu/update', asyncHandler(updateRuFu)); httpServer.post('/admin/enterprise/rufu/update', asyncHandler(updateRuFu));
// 免登录请求接口
httpServer.post('/admin/enterprise/rufu/autologin', asyncHandler(autoLogin));
} }
...@@ -105,6 +107,20 @@ async function settleInById(req, res) { ...@@ -105,6 +107,20 @@ async function settleInById(req, res) {
} }
/**
* 管理员编辑企业材料
* @param req
* @param res
*/
async function autoLogin(req, res) {
let { mobile, timestamp, usersign } = req.body
let result = await userRuFuBiz.autoLogin(mobile, timestamp, usersign);
res.success(result);
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 请求工具 * 请求工具
*/ */
import * as request from 'request'; import request from 'request';
import { BizError } from './bizError'; import { BizError } from './bizError';
/** /**
......
...@@ -4,7 +4,13 @@ ...@@ -4,7 +4,13 @@
"target": "ES2020", "target": "ES2020",
"sourceMap": true, "sourceMap": true,
"rootDir":"./src", "rootDir":"./src",
"outDir":"./out" "outDir":"./out",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"noImplicitAny": false,
"strictNullChecks": false,
"types": ["node"]
}, },
"exclude": [ "exclude": [
"node_modules", "node_modules",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment