Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-collect-api
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyi.chen
data-collect-api
Commits
173e63d1
Commit
173e63d1
authored
Mar 22, 2024
by
wenyi.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
綫上0322完整版本
parent
7ae05594
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
40 deletions
+66
-40
app/api/controller/Norm.php
+12
-19
app/api/controller/NormReceives.php
+0
-6
app/api/controller/UserInfo.php
+49
-13
app/api/route/api.php
+2
-1
app/common/lib/Arr.php
+1
-0
app/common/model/mysql/Norm.php
+1
-0
config/config.php
+1
-1
No files found.
app/api/controller/Norm.php
View file @
173e63d1
...
...
@@ -105,7 +105,7 @@ class Norm
// 开启数据库事务
Db
::
startTrans
();
$
index
=
1
;
$
control
=
1
;
// 指标数据
$normData
=
[
'task_id'
=>
$data
[
'task_id'
],
...
...
@@ -120,14 +120,13 @@ class Norm
$normBus
=
new
CommonBus
(
'NormBus'
);
// 通过公共业务初始化指标类
// 检查指标名称是否有重复
$query
=
$normBus
->
getConditionalQuery
([
'task_id'
=>
$data
[
'task_id'
],
'name'
=>
$data
[
'name'
]]);
var_dump
(
$query
);
if
(
$query
){
return
returnResult
(
config
(
"config.code.error"
),
'指标名称已存在!'
);
}
// 添加到指标表中
$normId
=
$normBus
->
addData
(
$normData
);
if
(
empty
(
$normId
)){
$
index
++
;
$
control
++
;
}
// 指标扩展数据
$normExtendList
=
[];
...
...
@@ -145,7 +144,7 @@ class Norm
// 添加自定义数据到指标扩展表中
$normExtend
=
$normExtendBus
->
addData
(
$normExtendList
);
if
(
empty
(
$normExtend
)){
$
index
++
;
$
control
++
;
}
// 格式化数据
...
...
@@ -156,28 +155,22 @@ class Norm
array_push
(
$extend
,[
'name'
=>
$value
[
'name'
],
'value'
=>
$value
[
'value'
]]);
}
}
$keyName
=
[];
//每个值对应的名称
$ordering
=
[];
// 需要排列组合的数据
foreach
(
$extend
as
$value
){
$exp
=
explode
(
','
,
$value
[
'value'
]);
array_push
(
$ordering
,
$exp
);
foreach
(
$exp
as
$value1
){
array_push
(
$keyName
,[
$value
[
'name'
]
=>
$value1
]);
}
}
// 格式化数据
$processedData
=
\app\common\lib\Arr
::
format
(
$ordering
);
// 格式化每个数据表需要的数据格式
foreach
(
$processedData
as
$value
){
$exp
=
explode
(
','
,
$value
);
foreach
(
$exp
as
$value1
){
foreach
(
$exp
as
$
index
=>
$
value1
){
$normList
=
[];
// 指标待领取数据
$normListExtend
=
[];
// 指标待领取数据扩展
$key
=
\app\common\lib\Arr
::
deepGetKey
(
$value1
,
$keyName
);
// 添加到用户待领取数据表
if
(
$
key
==
'名称'
){
if
(
$
index
==
0
){
$normList
[
'task_id'
]
=
$data
[
'task_id'
];
$normList
[
'norm_id'
]
=
$normId
;
$normList
[
'name'
]
=
$value1
;
...
...
@@ -191,29 +184,29 @@ class Norm
$normListBus
=
new
CommonBus
(
'NormListBus'
);
// 通过公共业务初始化用户待领取指标类
$normListId
=
$normListBus
->
addData
(
$normList
);
if
(
empty
(
$normListId
)){
$
index
++
;
$
control
++
;
}
// 添加到用户待领取扩展数据表
// 添加到用户待领取扩展数据表
}
else
{
$normListExtend
[
'norm_id'
]
=
$normId
;
$normListExtend
[
'norm_list_id'
]
=
$normListId
;
$normListExtend
[
'extend_name'
]
=
$
key
;
$normListExtend
[
'extend_name'
]
=
$
extend
[
$index
][
'name'
]
;
$normListExtend
[
'extend_value'
]
=
$value1
;
$normListExtend
[
'extend_type'
]
=
1
;
$normListExtendBus
=
new
CommonBus
(
'NormListExtendBus'
);
// 通过公共业务初始化用户待领取指标扩展类
$res
=
$normListExtendBus
->
addData
(
$normListExtend
);
if
(
empty
(
$res
)){
$
index
++
;
$
control
++
;
}
}
}
}
// 全部添加完成提交
if
(
$
index
==
1
){
if
(
$
control
==
1
){
Db
::
commit
();
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$res
);
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
[]
);
}
else
{
return
returnResult
(
config
(
"config.code.
success"
),
config
(
"config.describe.null_data
"
),[]);
return
returnResult
(
config
(
"config.code.
error"
),
config
(
"config.describe.add_error
"
),[]);
}
}
catch
(
\Exception
$e
){
Db
::
rollback
();
...
...
app/api/controller/NormReceives.php
View file @
173e63d1
...
...
@@ -39,9 +39,6 @@ class NormReceives extends AuthBase
$result
=
$NormReceivesBus
->
listData
(
$data
);
//获取所有账号信息
foreach
(
$result
as
$index
=>
$value
){
$normListInfo
=
$NormListBus
->
getConditionalQueryAll
([
'id'
=>
$value
[
'norm_list_id'
]]);
if
(
empty
(
$normListInfo
)){
return
returnResult
(
config
(
"config.code.error"
),
'无法获取领取指标信息!'
,
''
);
}
$result
[
$index
][
'norm_list_info'
]
=
$normListInfo
;
$NormExtendBus
=
new
\app\api\business\CommonBus
(
'NormExtendBus'
);
// 通过公共业务初始化用户待领取指标类
$user_filled
=
$NormExtendBus
->
getConditionalQuery
([
'norm_id'
=>
$value
[
'norm_id'
],
'user_filled'
=>
1
]);
...
...
@@ -61,9 +58,6 @@ class NormReceives extends AuthBase
$result
=
$NormReceivesBus
->
pagingListData
(
$data
);
//获取所有账号信息
foreach
(
$result
[
'data'
]
as
$index
=>
$value
){
$normListInfo
=
$NormListBus
->
getConditionalQuery
([
'id'
=>
$value
[
'norm_list_id'
]]);
if
(
empty
(
$normListInfo
)){
return
returnResult
(
config
(
"config.code.error"
),
'无法获取领取指标信息!'
,
''
);
}
$result
[
'data'
][
$index
][
'norm_list_info'
]
=
$normListInfo
;
$NormExtendBus
=
new
\app\api\business\CommonBus
(
'NormExtendBus'
);
// 通过公共业务初始化用户待领取指标类
$user_filled
=
$NormExtendBus
->
getConditionalQueryAll
([
'norm_id'
=>
$value
[
'norm_id'
],
'user_filled'
=>
1
]);
...
...
app/api/controller/UserInfo.php
View file @
173e63d1
...
...
@@ -265,6 +265,44 @@ class UserInfo extends AuthBase
}
/**
* 修改密码
* @return \josn
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public
function
changePassword
()
{
try
{
$password
=
input
(
'param.password'
);
$newPassword
=
input
(
'param.newPassword'
);
$confirmNewPassword
=
input
(
'param.confirmNewPassword'
);
if
(
$newPassword
!==
$confirmNewPassword
){
return
returnResult
(
config
(
"config.code.error"
),
'新密码与确认密码正确!'
,
''
);
}
// 业务处理
$bus
=
new
UserInfoBus
();
$info
=
$bus
->
getUserByUserId
(
$this
->
userId
);
if
(
empty
(
$info
)){
return
returnResult
(
config
(
"config.code.error"
),
'用戶不存在!'
,
''
);
}
if
(
$info
[
'password'
]
!==
md5
(
$password
)){
return
returnResult
(
config
(
"config.code.error"
),
'原始密码有误!'
,
''
);
}
$data
=
[
'id'
=>
$this
->
userId
,
'password'
=>
md5
(
$newPassword
)];
$result
=
$bus
->
updateData
(
$data
);
if
(
$result
){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),[]);
}
else
{
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.deletion_failed"
),[]);
}
}
catch
(
\Exception
$e
){
exception
(
$e
,
'UserInfo.changePassword'
);
}
}
/**
* 重置密码
* @return \josn
* @throws \think\Exception
...
...
@@ -274,19 +312,17 @@ class UserInfo extends AuthBase
*/
public
function
resetPassword
()
{
$id
=
input
(
'param.id'
,
''
,
"intval"
);
// 业务处理
$bus
=
new
UserInfoBus
();
$info
=
$bus
->
getUserByUserId
(
$id
);
if
(
empty
(
$info
)){
return
returnResult
(
config
(
"config.code.error"
),
'ID不存在!'
,
''
);
}
$data
=
[
'id'
=>
$id
,
'password'
=>
md5
(
123456
)];
$result
=
$bus
->
updateData
(
$data
);
if
(
$result
){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),[]);
}
else
{
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.deletion_failed"
),[]);
try
{
$bus
=
new
UserInfoBus
();
$data
=
[
'id'
=>
$this
->
userId
,
'password'
=>
md5
(
'123456'
)];
$result
=
$bus
->
updateData
(
$data
);
if
(
$result
){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),[]);
}
else
{
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.deletion_failed"
),[]);
}
}
catch
(
\Exception
$e
){
exception
(
$e
,
'UserInfo.resetPassword'
);
}
}
...
...
app/api/route/api.php
View file @
173e63d1
...
...
@@ -12,7 +12,6 @@ Route::miss(function() {
/***************************鉴权相关 */
Route
::
rule
(
"auth/login"
,
"login/signIn"
);
// 登录
Route
::
rule
(
"getToken"
,
"login/getToken"
);
// 登录获取token
Route
::
rule
(
"logout"
,
"UserInfo/logout"
);
// 退出登录
/***************************账号信息相关 */
Route
::
rule
(
"user/list"
,
"UserInfo/list"
);
// 获取账号信息
...
...
@@ -23,6 +22,8 @@ Route::rule("user/delete","UserInfo/delete"); // 删除用户信息
Route
::
rule
(
"user/heartbeat"
,
"UserInfo/heartbeat"
);
// 更新token时间
Route
::
rule
(
"user/tokenInfo"
,
"UserInfo/tokenInfo"
);
// 获取信息
Route
::
rule
(
"user/changeStatus"
,
"UserInfo/changeStatus"
);
// 修改账号状态
Route
::
rule
(
"user/changePassword"
,
"UserInfo/changePassword"
);
// 重置密码
Route
::
rule
(
"logout"
,
"UserInfo/logout"
);
// 退出登录
Route
::
rule
(
"user/resetPassword"
,
"UserInfo/resetPassword"
);
// 重置密码
Route
::
rule
(
"user/me"
,
"UserInfo/me"
);
// 查看个人详细信息
...
...
app/common/lib/Arr.php
View file @
173e63d1
...
...
@@ -102,6 +102,7 @@ class Arr
}
/***********************==============================二位数组排列组合
*
/**
* 二位数组排列组合
* @param $arr1
...
...
app/common/model/mysql/Norm.php
View file @
173e63d1
...
...
@@ -85,6 +85,7 @@ class Norm extends Model
{
try
{
return
$this
->
where
(
$where
)
->
find
();
}
catch
(
\Exception
$e
){
exception
(
$e
,
'mysql.Norm.getFindModel'
);
}
...
...
config/config.php
View file @
173e63d1
...
...
@@ -69,5 +69,5 @@ return [
"table_delete"
=>
99
,
// 删除
],
// "resource_address"=>'https://data-collect.raisound.com/data-collect-api/',
"resource_address"
=>
'http://192.168.10.168/data-collect-api/'
,
"resource_address"
=>
'http://192.168.10.168/data-collect-api/'
];
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