Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
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
hujun
tl_estate
Commits
9bb78f52
Commit
9bb78f52
authored
Aug 31, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取随机图片
parent
8273e915
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
36 deletions
+39
-36
ImageDepot.php
application/api/controller/ImageDepot.php
+16
-36
GImageDepot.php
application/model/GImageDepot.php
+22
-0
route.php
application/route.php
+1
-0
No files found.
application/api/controller/ImageDepot.php
View file @
9bb78f52
...
...
@@ -177,49 +177,29 @@ class ImageDepot extends Basic
* 获取随机图片
* @return \think\Response
*/
public
function
getImageWidthRand
(
$img_type
,
$label
)
public
function
getImageWidthRand
(
$img_type
=
0
,
$label
=
'商场美食'
)
{
if
(
$img_type
==
0
)
{
}
elseif
(
$img_type
==
1
)
{
}
else
{
$params_
[
'img_status'
]
=
0
;
if
(
!
empty
(
$img_type
))
{
$params_
[
'img_type'
]
=
$img_type
;
}
//todo 根据条件 查询所有符合要求的记录的ID
if
(
!
empty
(
$params
[
'label'
]
))
{
$params_
[
'label'
]
=
[
'LIKE'
,
'%'
.
$params
[
'label'
]
.
'%'
];
if
(
$img_type
==
0
or
$img_type
==
1
)
{
if
(
!
empty
(
$label
))
{
$params_
[
'label'
]
=
[
'LIKE'
,
'%'
.
$label
.
'%'
];
}
if
(
!
empty
(
$this
->
params
[
'img_type'
]))
{
$params_
[
'img_type'
]
=
$params
[
'img_type'
];
}
/*$params = array(
"agents_id" => 5740
);*/
/**
`id`
`img_type` '图片类型:0室外图 ,1室内图 ,2人群图',
`label_type` '业态标签:0商场美食、1沿街餐饮、2百货零售、3服饰鞋包、4休闲娱乐、5亲子教育、6百货超市、7办公',
`img_name` '图片名称',
`img_status` '删除状态 0正常 1删除',
`update_time` '更新时间',
`create_time` '创建时间',
*/
$
pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
]
;
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$field
=
'id,img_type,label,img_name,create_time'
;
$
params_
[
'img_status'
]
=
0
;
$
result
=
$this
->
imageDepot
->
getImageDepotIDList
(
$params_
)
;
if
(
!
$result
){
//TODO 返回一个默认图片
return
$result
;
}
$
random_keys
=
array_rand
(
$result
,
1
)
;
$
res
=
$this
->
imageDepot
->
getImageDepotList
(
$field
,
$params_
,
$pageNo
,
$pageSize
)
;
$
img_file_path
=
CURRENT_URL
.
'static/shop_image_depot/'
.
$result
[
$random_keys
][
'img_name'
]
;
//
return
$img_file_path
;
}
...
...
application/model/GImageDepot.php
View file @
9bb78f52
...
...
@@ -49,6 +49,28 @@ class GImageDepot extends Model
return
$result
;
}
/**
* 查询id集合
*/
public
function
getImageDepotIDList
(
$params
)
{
$field
=
"id,img_name"
;
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
where
(
$params
)
->
select
();
if
(
!
$result
){
return
$result
;
}
foreach
(
$result
as
$k
=>
$v
)
{
$result_
[
'id'
]
=
$v
[
'id'
];
$result_
[
'img_name'
]
=
$v
[
'img_name'
];
$result__
[]
=
$result_
;
}
//dump($this->getLastSql());
return
$result__
;
}
/**
* 查询统计数据
*/
...
...
application/route.php
View file @
9bb78f52
...
...
@@ -384,6 +384,7 @@ Route::group('api', [
'getImageDepotList'
=>
[
'api/ImageDepot/getImageDepotList'
,
[
'method'
=>
'get | post'
]
],
//获取图片列表
'getImageDepotById'
=>
[
'api/ImageDepot/getImageDepotById'
,
[
'method'
=>
'get | post'
]
],
//根据ID获取记录
'delImageDepot'
=>
[
'api/ImageDepot/delImageDepot'
,
[
'method'
=>
'get | post'
]
],
//删除
'getImageWidthRand'
=>
[
'api/ImageDepot/getImageWidthRand'
,
[
'method'
=>
'get | post'
]
],
//删除
...
...
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