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
6fbdfc73
Commit
6fbdfc73
authored
Aug 31, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c端图库-根据ID获取记录
parent
8ded75ae
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
2 deletions
+54
-2
ImageDepot.php
application/api/controller/ImageDepot.php
+34
-1
ImageDepot.php
application/api/validate/ImageDepot.php
+7
-1
GImageDepot.php
application/model/GImageDepot.php
+12
-0
route.php
application/route.php
+1
-0
No files found.
application/api/controller/ImageDepot.php
View file @
6fbdfc73
...
@@ -88,6 +88,12 @@ class ImageDepot extends Basic
...
@@ -88,6 +88,12 @@ class ImageDepot extends Basic
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
if
(
!
empty
(
$params
[
'label'
]))
{
$params_
[
'label'
]
=
[
'LIKE'
,
'%'
.
$params
[
'label'
]
.
'%'
];
}
if
(
!
empty
(
$this
->
params
[
'img_type'
]))
{
$params_
[
'img_type'
]
=
$params
[
'img_type'
];
}
/*$params = array(
/*$params = array(
"agents_id" => 5740
"agents_id" => 5740
);*/
);*/
...
@@ -105,7 +111,7 @@ class ImageDepot extends Basic
...
@@ -105,7 +111,7 @@ class ImageDepot extends Basic
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$field
=
'id,img_type,label,img_name,
img_status,
create_time'
;
$field
=
'id,img_type,label,img_name,create_time'
;
$params_
[
'img_status'
]
=
0
;
$params_
[
'img_status'
]
=
0
;
...
@@ -122,5 +128,32 @@ class ImageDepot extends Basic
...
@@ -122,5 +128,32 @@ class ImageDepot extends Basic
return
$this
->
response
(
"200"
,
"成功"
,
$data
);
return
$this
->
response
(
"200"
,
"成功"
,
$data
);
}
}
/**
* 根据ID获取记录
* @return \think\Response
*/
public
function
getImageDepotById
()
{
$params
=
$this
->
params
;
$checkResult
=
$this
->
validate
(
$params
,
"ImageDepot.getImageDepotById"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$params_
[
'id'
]
=
$params
[
'id'
];
$params_
[
'img_status'
]
=
0
;
$field
=
'id,img_type,label,img_name,create_time'
;
$res
=
$this
->
imageDepot
->
getImageDepotById
(
$field
,
$params_
);
if
(
!
$res
){
return
$this
->
response
(
"101"
,
"查无数据"
);
}
$res
[
0
][
'img_file_path'
]
=
CURRENT_URL
.
'static/shop_image_depot/'
.
$res
[
'img_name'
];
$data
[
'list'
]
=
$res
[
0
];
return
$this
->
response
(
"200"
,
"成功"
,
$data
);
}
}
}
application/api/validate/ImageDepot.php
View file @
6fbdfc73
...
@@ -11,16 +11,21 @@ class ImageDepot extends Validate {
...
@@ -11,16 +11,21 @@ class ImageDepot extends Validate {
protected
$rule
=
[
protected
$rule
=
[
'img_type'
=>
'require'
,
'img_type'
=>
'require'
,
'img_name'
=>
'require'
'img_name'
=>
'require'
,
'id'
=>
'require|number|gt:0'
];
];
protected
$message
=
[
protected
$message
=
[
'img_type.require'
=>
'图片类型不能为空'
,
'img_type.require'
=>
'图片类型不能为空'
,
'img_name.require'
=>
'图片名不能为空'
,
'img_name.require'
=>
'图片名不能为空'
,
'id.require'
=>
'id为必填字段'
,
'id.number'
=>
'id只能为数字'
,
'id.gt'
=>
'id必须大于0'
,
];
];
protected
$scene
=
[
protected
$scene
=
[
'addImageDepot'
=>
[
'img_type'
,
'img_name'
],
'addImageDepot'
=>
[
'img_type'
,
'img_name'
],
'getImageDepotById'
=>
[
'id'
],
];
];
}
}
\ No newline at end of file
application/model/GImageDepot.php
View file @
6fbdfc73
...
@@ -60,4 +60,16 @@ class GImageDepot extends Model
...
@@ -60,4 +60,16 @@ class GImageDepot extends Model
//dump($this->getLastSql());
//dump($this->getLastSql());
return
$result
;
return
$result
;
}
}
/**
* 根据ID获取记录
*/
public
function
getImageDepotById
(
$field
,
$params
)
{
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
where
(
$params
)
->
select
();
//dump($this->getLastSql());
return
$result
;
}
}
}
application/route.php
View file @
6fbdfc73
...
@@ -382,6 +382,7 @@ Route::group('api', [
...
@@ -382,6 +382,7 @@ Route::group('api', [
'addImageDepot'
=>
[
'api/ImageDepot/addImageDepot'
,
[
'method'
=>
'get | post'
]
],
//上传保存图片
'addImageDepot'
=>
[
'api/ImageDepot/addImageDepot'
,
[
'method'
=>
'get | post'
]
],
//上传保存图片
'getImageTypeLabel'
=>
[
'api/ImageDepot/getImageTypeLabel'
,
[
'method'
=>
'get | post'
]
],
//获取图片类型与标签
'getImageTypeLabel'
=>
[
'api/ImageDepot/getImageTypeLabel'
,
[
'method'
=>
'get | post'
]
],
//获取图片类型与标签
'getImageDepotList'
=>
[
'api/ImageDepot/getImageDepotList'
,
[
'method'
=>
'get | post'
]
],
//获取图片列表
'getImageDepotList'
=>
[
'api/ImageDepot/getImageDepotList'
,
[
'method'
=>
'get | post'
]
],
//获取图片列表
'getImageDepotById'
=>
[
'api/ImageDepot/getImageDepotById'
,
[
'method'
=>
'get | post'
]
],
//根据ID获取记录
...
...
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