Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yuyiAdminServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
yuyiAdminServer
Commits
7d48d9de
Commit
7d48d9de
authored
Mar 25, 2026
by
chenjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
936cbd63
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
147 additions
and
6 deletions
+147
-6
serverConfig.xml
serverConfig.xml
+1
-0
admin.ts
src/biz/admin.ts
+2
-1
userRuFu.ts
src/biz/userRuFu.ts
+102
-0
errorEnum.ts
src/config/enum/errorEnum.ts
+4
-1
serverConfig.ts
src/config/serverConfig.ts
+4
-1
systemClass.ts
src/config/systemClass.ts
+3
-0
main.ts
src/main.ts
+6
-0
http_server.ts
src/net/http_server.ts
+1
-1
userRuFu.ts
src/routers/userRuFu.ts
+16
-0
request.ts
src/util/request.ts
+1
-1
tsconfig.json
tsconfig.json
+7
-1
No files found.
serverConfig.xml
View file @
7d48d9de
<config>
<port>
9098
</port>
<sign>
xxx90909082fsdahfjosadjfpoiwausjorip2hjklrhn1ioud0u124rx0qwejfokasjfolksaujfoas
</sign>
<usersign>
OwyCGbUkW7yHxUmYNGykhG4gsE7GVzdC8wob01VYq7olO8rbFeMuFwpOkEpJ2AnucjomnpODN
</usersign>
<SECRET_TOKEN>
Ngz86cuAKxblwXR9OiKSWbfkj7oZ8R0lMU8pTfpVYBDCkvtUb0ZwbaBvwWyfv2O9
</SECRET_TOKEN>
<dbServer>
http://192.168.0.71:40012
</dbServer>
<imgUrl>
http://192.168.0.71:9098
</imgUrl>
...
...
src/biz/admin.ts
View file @
7d48d9de
...
...
@@ -281,7 +281,8 @@ export async function enterpriseExamineUpdate( mId, param) {
* @returns {dataList, dataCount} 列表数据,数据总量
*/
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
(
quarter
)
selectParam
.
quarter
=
quarter
;
...
...
src/biz/userRuFu.ts
View file @
7d48d9de
...
...
@@ -15,6 +15,7 @@ import { changeAdd, extractData } from "../util/piecemeal";
import
{
EnterpriseApplyForConfig
}
from
"../config/splitResult/enterprise"
;
import
{
CHANGESTATE
,
CHANGETYPE
,
FUHUASTATE
,
RUFUSTATE
,
STATE
}
from
"../config/enum/enum"
;
import
{
createMessageReminder
}
from
"./message"
;
import
{
systemConfig
}
from
"../config/serverConfig"
;
/**
...
...
@@ -506,3 +507,104 @@ function getFileNameAndFormat(fileName: string | null | undefined): string {
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
);
}
src/config/enum/errorEnum.ts
View file @
7d48d9de
...
...
@@ -45,7 +45,10 @@ export enum ERRORENUM {
原密码错误
,
密码不一致
,
系统错误
,
该企业当前不在迁出状态
该企业当前不在迁出状态
,
签名验证失败
,
请求已过期
,
无效的时间戳
}
export
enum
ERRORCODEENUM
{
...
...
src/config/serverConfig.ts
View file @
7d48d9de
...
...
@@ -16,7 +16,7 @@ export async function initConfig() {
if
(
!
configInfo
||
!
configInfo
.
config
)
throw
new
BizError
(
'xml中无配置'
);
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
.
secretToken
=
SECRET_TOKEN
[
0
];
...
...
@@ -32,6 +32,9 @@ export async function initConfig() {
systemConfig
.
qccSecretKey
=
qcc
[
0
].
SecretKey
[
0
];
systemConfig
.
unZipFileUrl
=
unZipFileUrl
[
0
];
/**免登录 */
systemConfig
.
usersign
=
usersign
[
0
];
}
console
.
log
(
"config init success"
);
...
...
src/config/systemClass.ts
View file @
7d48d9de
...
...
@@ -16,4 +16,6 @@ export class ServerConfig {
qccKey
:
string
;
qccSecretKey
:
string
;
unZipFileUrl
:
string
;
/**免登录 */
usersign
:
string
;
}
\ No newline at end of file
src/main.ts
View file @
7d48d9de
...
...
@@ -7,9 +7,13 @@ import { updateItemQCCData } from "./biz/qccInit";
import
{
initConfig
,
systemConfig
}
from
"./config/serverConfig"
;
import
{
initApiDataStorage
}
from
"./data/dataInterfaceWithCache"
;
import
{
httpServer
}
from
"./net/http_server"
;
import
{
getPwdMd5
}
from
"./tools/system"
;
async
function
lanuch
()
{
const
encryptedPwd
=
getPwdMd5
(
"ur_50e39e678e8bc8d19fd4b5aa98196a27"
,
"123456"
);
console
.
log
();
await
initConfig
();
httpServer
.
createServer
(
systemConfig
.
port
);
console
.
log
(
'This indicates that the server is started successfully.'
);
...
...
@@ -32,6 +36,8 @@ async function lanuch() {
// ]
// }};
// await newDow(eIds, options);
}
...
...
src/net/http_server.ts
View file @
7d48d9de
...
...
@@ -5,7 +5,7 @@ import compression = require('compression');
import
{
watch
}
from
'../middleware/watch'
;
import
{
httpErrorHandler
}
from
'../middleware/httpErrorHandler'
;
import
*
as
path
from
"path"
;
import
*
as
fallback
from
'express-history-api-fallback'
;
import
fallback
from
'express-history-api-fallback'
;
export
class
httpServer
{
static
createServer
(
port
:
number
)
{
...
...
src/routers/userRuFu.ts
View file @
7d48d9de
...
...
@@ -13,6 +13,8 @@ export function setRouter(httpServer) {
httpServer
.
post
(
'/admin/enterprise/rufu/settleininfo'
,
asyncHandler
(
settleInById
));
httpServer
.
post
(
'/admin/enterprise/rufu/info'
,
asyncHandler
(
getRuFu
));
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) {
}
/**
* 管理员编辑企业材料
* @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
);
}
src/util/request.ts
View file @
7d48d9de
...
...
@@ -2,7 +2,7 @@
* 请求工具
*/
import
*
as
request
from
'request'
;
import
request
from
'request'
;
import
{
BizError
}
from
'./bizError'
;
/**
...
...
tsconfig.json
View file @
7d48d9de
...
...
@@ -4,7 +4,13 @@
"target"
:
"ES2020"
,
"sourceMap"
:
true
,
"rootDir"
:
"./src"
,
"outDir"
:
"./out"
"outDir"
:
"./out"
,
"esModuleInterop"
:
true
,
"allowSyntheticDefaultImports"
:
true
,
"strict"
:
false
,
"noImplicitAny"
:
false
,
"strictNullChecks"
:
false
,
"types"
:
[
"node"
]
},
"exclude"
:
[
"node_modules"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment