Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ruer_cms
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蔡闯
ruer_cms
Commits
b8bdabb9
Commit
b8bdabb9
authored
May 26, 2021
by
蔡闯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2021-5-26
parent
bbf3b451
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
172 additions
and
53 deletions
+172
-53
app/admin/controller/Feedback.php
app/admin/controller/Feedback.php
+47
-0
app/api/controller/Feedback.php
app/api/controller/Feedback.php
+32
-0
app/api/controller/User.php
app/api/controller/User.php
+1
-9
app/common.php
app/common.php
+48
-0
app/middleware/AdminAfter.php
app/middleware/AdminAfter.php
+44
-44
No files found.
app/admin/controller/Feedback.php
0 → 100644
View file @
b8bdabb9
<?php
namespace
app\admin\controller
;
use
think\facade\Request
;
use
think\facade\Db
;
class
Feedback
extends
Base
{
//意见反馈列表
public
function
feedBackList
(){
$page
=
Request
::
param
(
'page'
,
1
);
$limit
=
Request
::
param
(
'limit'
,
config
(
'app.limit'
));
$list
=
Db
::
name
(
'feedback'
)
->
alias
(
'f'
)
->
leftJoin
(
'user u'
,
'f.uid = u.uid'
)
->
order
(
'f.create_time'
,
'desc'
)
->
field
(
'f.*,u.nickname'
)
->
page
(
$page
,
$limit
)
->
select
()
->
toArray
();
foreach
(
$list
as
$k
=>
$v
)
{
$list
[
$k
][
'content'
]
=
mb_substr
(
$v
[
'content'
],
0
,
50
,
'utf-8'
);
if
(
$v
[
'pics'
])
{
$list
[
$k
][
'pics'
]
=
json_decode
(
$v
[
'pics'
],
true
);
}
else
{
$list
[
$k
][
'pics'
]
=
[];
}
}
$count
=
Db
::
name
(
'feedback'
)
->
count
();
$res
[
'total'
]
=
$count
;
$res
[
'data'
]
=
changeField
(
$list
);
return
$this
->
returnJson
(
$res
,
'success'
);
}
//意见反馈详情
public
function
feedBackDetail
(){
$id
=
Request
::
param
(
'feedback_id'
);
$where
[
'feedback_id'
]
=
$id
;
$info
=
Db
::
name
(
'feedback'
)
->
where
(
$where
)
->
alias
(
'f'
)
->
leftJoin
(
'user u'
,
'f.uid = u.uid'
)
->
field
(
'f.*,u.nickname'
)
->
find
();
if
(
$info
[
'pics'
])
{
$info
[
'pics'
]
=
json_decode
(
$info
[
'pics'
],
true
);
}
else
{
$info
[
'pics'
]
=
[];
}
return
$this
->
returnJson
(
changeField
(
$info
),
'success'
);
}
}
\ No newline at end of file
app/api/controller/Feedback.php
0 → 100644
View file @
b8bdabb9
<?php
namespace
app\api\controller
;
use
think\facade\Db
;
use
think\facade\Request
;
class
Feedback
extends
Base
{
public
function
uploadFeedBack
(){
$data
[
'content'
]
=
Request
::
param
(
'content'
);
$data
[
'uid'
]
=
$this
->
uid
;
$data
[
'type'
]
=
Request
::
param
(
'type'
,
1
);
$data
[
'create_time'
]
=
time
();
$pics
=
Request
::
param
(
'pics'
);
if
(
$pics
)
{
$data
[
'pics'
]
=
json_encode
(
$pics
);
}
$add
=
Db
::
name
(
'feedback'
)
->
insert
(
$data
);
if
(
$add
)
{
return
$this
->
returnJson
([],
200
);
}
else
{
return
$this
->
returnJson
([],
'添加失败!'
,
'400'
);
}
}
}
\ No newline at end of file
app/api/controller/User.php
View file @
b8bdabb9
...
...
@@ -19,15 +19,7 @@ class User extends Base
// $city_id = Request::param('city_id');
// $area_id = Request::param('area_id');
$where
=
[];
// if($province_id) {
// $where['province_id'] = $province_id;
// }
// if($city_id) {
// $where['city_id'] = $city_id;
// }
// if($area_id) {
// $where['area_id'] = $area_id;
// }
if
(
$keyword
)
{
//如果有关键字就搜索关键字的小区
$villages
=
Db
::
name
(
'house_village'
)
->
where
(
$where
)
->
where
(
'village_name'
,
'like'
,
'%'
.
$keyword
.
'%'
)
->
field
(
'village_name,village_id,province_name,city_name,area_name,village_logo,village_address'
)
->
page
(
$page
,
config
(
'app.limit'
))
->
select
()
->
toArray
();
$res
[
'total'
]
=
Db
::
name
(
'house_village'
)
->
where
(
$where
)
->
where
(
'village_name'
,
'like'
,
'%'
.
$keyword
.
'%'
)
->
count
();
...
...
app/common.php
View file @
b8bdabb9
...
...
@@ -233,6 +233,54 @@ function isHTTPS()
}
//对数组中的时间字段进行日期转换
function
changeField
(
$data
,
$field
=
"create_time"
,
$format
=
"Y-m-d H:i:s"
)
{
$prompt
=
"暂无"
;
if
(
empty
(
$data
))
{
return
$data
;
}
foreach
(
$data
as
$k
=>
$v
)
{
if
(
is_array
(
$v
))
{
if
(
is_array
(
$field
))
{
foreach
(
$field
as
$value
)
{
if
(
$v
[
$value
]
!=
0
||
!
is_null
(
$v
[
$value
])){
$data
[
$k
][
$value
]
=
date
(
$format
,
$v
[
$value
]);
}
else
{
$data
[
$k
][
$value
]
=
$prompt
;
}
}
}
else
{
if
(
$v
[
$field
]
!=
0
||
!
is_null
(
$v
[
$field
])){
$data
[
$k
][
$field
]
=
date
(
$format
,
$v
[
$field
]);
}
else
{
$data
[
$k
][
$field
]
=
$prompt
;
}
}
}
else
{
if
(
is_array
(
$field
))
{
foreach
(
$field
as
$value
)
{
if
(
isset
(
$data
[
$value
])
||
$data
[
$value
]
!=
0
){
$data
[
$value
]
=
date
(
$format
,
$data
[
$value
]);
}
else
{
$data
[
$value
]
=
$prompt
;
}
}
break
;
}
else
{
if
(
isset
(
$data
[
$field
])
||
$data
[
$field
]
!=
0
)
{
$data
[
$field
]
=
date
(
$format
,
$data
[
$field
]);
}
else
{
$data
[
$field
]
=
$prompt
;
}
break
;
}
}
}
return
$data
;
}
...
...
app/middleware/AdminAfter.php
View file @
b8bdabb9
<?php
declare
(
strict_types
=
1
);
namespace
app\middleware
;
use
Firebase\JWT\JWT
;
use
think\facade\Cache
;
use
think\facade\Request
;
/**
* Class Logincheck
* @package app\middleware
* admin后台登入后置中间件,有操作之后更新redis缓存过期时间
*/
class
AdminAfter
{
/**
* 处理请求
*
* @param \think\Request $request
* @param \Closure $next
* @return Response
*/
public
function
handle
(
$request
,
\Closure
$next
)
{
$response
=
$next
(
$request
);
$token
=
Request
::
header
(
'token'
);
//判断是否在redis中
$decodeData
=
(
array
)
JWT
::
decode
(
$token
,
"zhihuishequ"
,
array
(
"HS256"
));
$redis
=
Cache
::
store
(
'redis'
)
->
handler
();
$keys
[]
=
"admin_tokens_"
.
$decodeData
[
'uid'
];
foreach
(
$keys
as
$value
){
if
(
$redis
->
exists
(
$value
))
{
$redis
->
EXPIRE
(
$value
,
3600
);
//设置过期时间,
}
}
return
$response
;
}
}
<?php
declare
(
strict_types
=
1
);
namespace
app\middleware
;
use
Firebase\JWT\JWT
;
use
think\facade\Cache
;
use
think\facade\Request
;
/**
* Class Logincheck
* @package app\middleware
* admin后台登入后置中间件,有操作之后更新redis缓存过期时间
*/
class
AdminAfter
{
/**
* 处理请求
*
* @param \think\Request $request
* @param \Closure $next
* @return Response
*/
public
function
handle
(
$request
,
\Closure
$next
)
{
$response
=
$next
(
$request
);
$token
=
Request
::
header
(
'token'
);
//判断是否在redis中
$decodeData
=
(
array
)
JWT
::
decode
(
$token
,
"zhihuishequ"
,
array
(
"HS256"
));
$redis
=
Cache
::
store
(
'redis'
)
->
handler
();
$keys
[]
=
"admin_tokens_"
.
$decodeData
[
'uid'
];
foreach
(
$keys
as
$value
){
if
(
$redis
->
exists
(
$value
))
{
$redis
->
EXPIRE
(
$value
,
3600
);
//设置过期时间,
}
}
return
$response
;
}
}
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