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
c9e666c8
Commit
c9e666c8
authored
Mar 19, 2018
by
hujun
Committed by
hujun
Mar 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商铺新增图片和删除图片
parent
26096ed9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
16 deletions
+35
-16
Shop.php
application/api_broker/controller/Shop.php
+19
-16
GHousesImgs.php
application/model/GHousesImgs.php
+16
-0
No files found.
application/api_broker/controller/Shop.php
View file @
c9e666c8
...
...
@@ -302,7 +302,10 @@ class Shop extends Basic
$info
=
$file
->
validate
([
'size'
=>
1024000
,
'ext'
=>
'jpg,png'
])
->
move
(
$path
);
if
(
$info
){
$img_path
=
$info
->
getSaveName
();
//生成的图片路径
$data
[
'img_type'
]
=
$this
->
params
[
'img_type'
];
$data
[
'img_name'
]
=
$img_path
;
$img
=
new
GHousesImgs
();
$img
->
addHouseImg
(
$data
,
$this
->
params
[
'house_id'
]);
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
'上传成功'
;
$data
[
'data'
]
=
[
...
...
@@ -333,23 +336,23 @@ class Shop extends Basic
$data
[
'msg'
]
=
''
;
$data
[
'data'
]
=
''
;
if
(
isset
(
$this
->
params
[
'house_id'
]))
{
$img
=
new
GHousesImgs
();
$id
=
$img
->
getHouseImagesInfo
(
'id'
,[
'house_id'
=>
$this
->
params
[
'house_id'
],
'img_name'
=>
$this
->
params
[
'save_path'
]
]);
if
(
empty
(
$this
->
params
[
'save_path'
])
||
empty
(
$this
->
params
[
'house_id'
])){
return
$this
->
response
(
$data
[
'status'
],
'Save_path or id house_id null'
,
$data
[
'data'
]);
}
if
(
empty
(
$id
[
'id'
]))
{
$data
[
'status'
]
=
200
;
$img
->
editData
([
'img_status'
=>
1
],
$this
->
params
[
'house_id'
],
'id'
);
}
$img
=
new
GHousesImgs
();
$id
=
$img
->
getHouseImagesInfo
(
'id'
,[
'house_id'
=>
$this
->
params
[
'house_id'
],
'img_name'
=>
$this
->
params
[
'save_path'
]
]);
if
(
isset
(
$this
->
params
[
'save_path'
]))
{
$path
=
ROOT_PATH
.
'public'
.
DS
.
'resource'
.
DS
.
'lib'
.
DS
.
'Attachments'
.
DS
.
'Images/'
;
@
unlink
(
$path
.
$this
->
params
[
'save_path'
]);
$data
[
'status'
]
=
200
;
}
if
(
empty
(
$id
[
'id'
]))
{
$data
[
'msg'
]
=
'没有该文件'
;
}
else
{
$path
=
ROOT_PATH
.
'public'
.
DS
.
'resource'
.
DS
.
'lib'
.
DS
.
'Attachments'
.
DS
.
'Images/'
;
@
unlink
(
$path
.
$this
->
params
[
'save_path'
]);
$img
->
editData
([
'img_status'
=>
1
],
$this
->
params
[
'house_id'
],
'id'
);
$data
[
'status'
]
=
200
;
}
return
$this
->
response
(
$data
[
'status'
],
$data
[
'msg'
],
$data
[
'data'
]);
...
...
application/model/GHousesImgs.php
View file @
c9e666c8
...
...
@@ -205,4 +205,19 @@ class GHousesImgs extends BaseModel
public
function
getHouseImagesInfo
(
$field
,
$where
)
{
return
$this
->
field
(
$field
)
->
where
(
$where
)
->
find
();
}
/**
* 添加楼盘图片
*
* @param array $data
* @param $house_id
* @return false|int
*/
public
function
addHouseImg
(
$data
=
[],
$house_id
)
{
return
$this
->
save
([
'house_id'
=>
$house_id
,
'img_type'
=>
$data
[
'img_type'
],
'img_name'
=>
$data
[
'img_name'
]
]);
}
}
\ No newline at end of file
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