Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qingdaoMuseumPlatform
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
qingdaoMuseumPlatform
Commits
c8dee5c3
Commit
c8dee5c3
authored
Jun 03, 2026
by
PC-20251223ZVQQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接飞奕API、用户注册和登录
parent
316d5da8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
19 deletions
+58
-19
device.ts
src/biz/device.ts
+6
-4
region.ts
src/biz/region.ts
+37
-1
users.ts
src/biz/users.ts
+9
-9
device.ts
src/routers/device.ts
+4
-5
router.ts
src/routers/router.ts
+2
-0
No files found.
src/biz/device.ts
View file @
c8dee5c3
...
...
@@ -11,20 +11,22 @@ import { controlAcByEnvironment } from "./running";
/**
* 注册或更新设备信息
* @param deviceId 设备唯一标识(必填)
* @param r
egionKey 区域编号(必填),对应 region 表的
id
* @param r
oomId 房间编号(必填),对应 region 表的 room_
id
* @param deviceType 设备类型(必填),如“灯光”“空调”
* @param deviceName 设备名称(可选),如“主照明灯”
* @param controlParams 设备支持的参数定义(可选),JSON对象
* @returns {Promise<{success: boolean}>}
* @throws 如果 regionKey 对应的区域不存在,则抛出错误
*/
export
async
function
registerOrUpdateDevice
(
deviceId
:
string
,
r
egionKey
:
number
,
deviceType
:
string
,
deviceName
?:
string
|
null
,
controlParams
?:
any
)
{
export
async
function
registerOrUpdateDevice
(
deviceId
:
string
,
r
oomId
:
string
,
deviceType
:
string
,
deviceName
?:
string
|
null
,
controlParams
?:
any
)
{
// 校验区域是否存在
let
region
=
await
selectOneDataByParam
(
TABLENAME
.
区域表
,
{
id
:
regionKey
});
let
region
=
await
selectOneDataByParam
(
TABLENAME
.
区域表
,
{
room_id
:
roomId
});
if
(
!
region
.
data
)
{
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`区域编号
${
r
egionKey
}
不存在`
);
throw
new
BizError
(
ERRORENUM
.
参数错误
,
`区域编号
${
r
oomId
}
不存在`
);
}
let
regionKey
=
region
.
data
.
id
;
let
exist
=
await
selectOneDataByParam
(
TABLENAME
.
设备表
,
{
device_id
:
deviceId
});
let
now
=
new
Date
().
toISOString
().
slice
(
0
,
19
).
replace
(
'T'
,
' '
);
...
...
src/biz/region.ts
View file @
c8dee5c3
...
...
@@ -2,7 +2,7 @@ import { selectDataListByParam } from "../data/findData";
import
{
TABLENAME
}
from
"../config/dbEnum"
;
/**
* 获取
所有
区域列表(供前端下拉选择)
* 获取
楼栋
区域列表(供前端下拉选择)
* @returns 区域列表,按 sort_order 排序
*/
export
async
function
getRegionList
(
regionGroup
:
string
)
{
...
...
@@ -34,4 +34,39 @@ export async function getRegionList( regionGroup: string ) {
return
{
list
:
regionMap
};
}
/**
* 获取所有区域列表(供前端下拉选择)
* @returns 区域列表,按 sort_order 排序
*/
export
async
function
getRegionAllList
(
regionGroup
:
string
)
{
let
where
:
any
=
{
"%orderAsc%"
:
"sort_order"
};
if
(
regionGroup
)
{
where
.
groups
=
regionGroup
;
}
let
regionList
=
await
selectDataListByParam
(
TABLENAME
.
区域表
,
where
,
[
"id"
,
"room_id"
,
"name"
,
"type"
,
"groups"
],
);
let
regionGroupTypeArr
:
any
=
[];
let
regionMap
:
any
=
{};
regionList
.
data
.
forEach
((
r
:
any
)
=>
{
let
regionArr
=
[];
if
(
regionMap
[
r
.
groups
])
{
regionArr
=
regionMap
[
r
.
groups
];
}
if
(
!
regionGroupTypeArr
.
includes
(
r
.
groups
+
"-"
+
r
.
type
))
{
regionGroupTypeArr
.
push
(
r
.
groups
+
"-"
+
r
.
type
);
regionArr
.
push
({
regionKey
:
r
.
id
,
roomId
:
r
.
room_id
,
regionName
:
r
.
name
,
regionType
:
r
.
type
,
regionGroup
:
r
.
groups
});
regionMap
[
r
.
groups
]
=
regionArr
;
}
});
console
.
log
(
"区域列表:"
,
regionMap
);
return
{
list
:
regionMap
};
}
\ No newline at end of file
src/biz/users.ts
View file @
c8dee5c3
...
...
@@ -32,26 +32,26 @@ export async function registerUser(loginId:string, pwd:string, name:string) {
* @returns
*/
export
async
function
adminLogin
(
loginId
:
string
,
pwd
:
string
)
{
let
filesList
=
[
"name"
,
"id"
,
"
pw
d"
,
"pwd"
];
let
filesList
=
[
"name"
,
"id"
,
"
loginI
d"
,
"pwd"
];
let
adminUserInfo
:
any
=
await
selectOneDataByParam
(
TABLENAME
.
用户信息表
,
{
loginId
},
filesList
);
console
.
log
(
adminUserInfo
.
pwd
);
if
(
!
adminUserInfo
||
!
adminUserInfo
.
id
)
{
console
.
log
(
adminUserInfo
.
data
);
if
(
!
adminUserInfo
.
data
||
!
adminUserInfo
.
data
.
id
)
{
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
}
const
encryptedPwd
=
getPwdMd5
(
adminUserInfo
.
i
d
,
pwd
);
if
(
adminUserInfo
.
pwd
!=
encryptedPwd
)
{
const
encryptedPwd
=
getPwdMd5
(
adminUserInfo
.
data
.
loginI
d
,
pwd
);
if
(
adminUserInfo
.
data
.
pwd
!=
encryptedPwd
)
{
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
}
let
updateUserInfo
=
{
token
:
getToken
(
adminUserInfo
.
loginId
),
token
:
getToken
(
adminUserInfo
.
data
.
loginId
),
tokenMs
:
getMySqlMs
()
};
await
updateManyData
(
TABLENAME
.
用户信息表
,
updateUserInfo
,
{
id
:
adminUserInfo
.
id
});
await
updateManyData
(
TABLENAME
.
用户信息表
,
updateUserInfo
,
{
id
:
adminUserInfo
.
data
.
id
});
let
userInfo
=
{
userId
:
adminUserInfo
.
id
,
userName
:
adminUserInfo
.
name
,
userId
:
adminUserInfo
.
data
.
id
,
userName
:
adminUserInfo
.
data
.
name
,
token
:
updateUserInfo
.
token
,
};
...
...
src/routers/device.ts
View file @
c8dee5c3
...
...
@@ -8,7 +8,6 @@ import * as regionBiz from '../biz/region';
import
*
as
runningBiz
from
'../biz/running'
;
import
{
eccReqParamater
}
from
'../util/verificationParam'
;
import
{
checkUser
}
from
'../middleware/user'
;
import
{
worker
}
from
'cluster'
;
export
function
setRouter
(
httpServer
)
{
/** 注册/更新设备信息 */
...
...
@@ -40,10 +39,10 @@ export function setRouter(httpServer) {
* 注册或更新设备信息
*/
async
function
registerDevice
(
req
,
res
)
{
let
reqConf
=
{
deviceId
:
'String'
,
r
egionKey
:
'Number
'
,
deviceType
:
'String'
,
deviceName
:
'String'
,
controlParams
:
'Object'
};
let
reqConf
=
{
deviceId
:
'String'
,
r
oomId
:
'String
'
,
deviceType
:
'String'
,
deviceName
:
'String'
,
controlParams
:
'Object'
};
const
NotMustHaveKeys
=
[];
let
{
deviceId
,
r
egionKey
,
deviceType
,
deviceName
,
controlParams
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
NotMustHaveKeys
);
const
result
=
await
deviceBiz
.
registerOrUpdateDevice
(
deviceId
,
r
egionKey
,
deviceType
,
deviceName
,
controlParams
);
let
{
deviceId
,
r
oomId
,
deviceType
,
deviceName
,
controlParams
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
NotMustHaveKeys
);
const
result
=
await
deviceBiz
.
registerOrUpdateDevice
(
deviceId
,
r
oomId
,
deviceType
,
deviceName
,
controlParams
);
res
.
success
(
result
);
}
...
...
@@ -80,7 +79,7 @@ async function getRegionList(req, res) {
let
reqConf
=
{
regionGroup
:
'String'
};
const
NotMustHaveKeys
=
[];
let
{
regionGroup
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
NotMustHaveKeys
);
const
result
=
await
regionBiz
.
getRegionList
(
regionGroup
);
const
result
=
await
regionBiz
.
getRegion
All
List
(
regionGroup
);
res
.
success
(
result
);
}
...
...
src/routers/router.ts
View file @
c8dee5c3
...
...
@@ -2,10 +2,12 @@
* 总路由入口
*/
import
*
as
usersRouter
from
'./users'
;
import
*
as
deviceRouter
from
'./device'
;
import
*
as
feiyiClientRouter
from
'./feiyiClient'
;
export
function
setRouter
(
httpServer
)
{
usersRouter
.
setRouter
(
httpServer
);
deviceRouter
.
setRouter
(
httpServer
);
feiyiClientRouter
.
setRouter
(
httpServer
);
}
...
...
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