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
0dde21e6
Commit
0dde21e6
authored
Jul 04, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
收藏或取消收藏客户2收藏或取消收藏商铺
parent
a418d5f0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
260 additions
and
0 deletions
+260
-0
CollectHouse.php
application/api_broker/controller/CollectHouse.php
+79
-0
CollectUser.php
application/api_broker/controller/CollectUser.php
+82
-0
ACollectHouse.php
application/model/ACollectHouse.php
+49
-0
ACollectUser.php
application/model/ACollectUser.php
+47
-0
route.php
application/route.php
+3
-0
No files found.
application/api_broker/controller/CollectHouse.php
0 → 100644
View file @
0dde21e6
<?php
namespace
app\api_broker\controller
;
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2018/7/4
* Time: 下午3:25
*/
use
app\api_broker\extend\Basic
;
use
app\model\ACollectHouse
;
use
think\Request
;
class
CollectHouse
extends
Basic
{
protected
$aCollectHouse
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
aCollectHouse
=
new
ACollectHouse
();
}
/**
* 收藏或取消收藏商铺
* User: 朱伟
* Date: 2018-07-04
* Time: 15:35:40
*/
public
function
addCollectHouse
(){
$params
=
$this
->
params
;
/*$params = array(
"agents_id" => 1,
"house_id" => 4,
"status" => 2,
);*/
if
(
!
isset
(
$params
[
"agents_id"
])
or
!
isset
(
$params
[
"house_id"
])
or
!
isset
(
$params
[
"status"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
//先判断是否已经存在数据
$field
=
'id,status'
;
$get_params
[
'agents_id'
]
=
$params
[
"agents_id"
];
$get_params
[
'house_id'
]
=
$params
[
"house_id"
];
$res
=
$this
->
aCollectHouse
->
getCollectHouse
(
$field
,
$get_params
);
if
(
$res
){
//如果存在
if
(
$res
[
0
][
'status'
]
!=
$params
[
"status"
]
){
//如果存在-并且状态一致 不作处理 不一致则更新状态
$insert
[
"id"
]
=
$res
[
0
][
'id'
];
$insert
[
"status"
]
=
$params
[
"status"
];
$res
=
$this
->
aCollectHouse
->
updateCollectHouse
(
$insert
);
//int(1)
}
else
{
$res
=
true
;
}
}
else
{
//不存在则新增数据
$insert
[
"agents_id"
]
=
$params
[
'agents_id'
];
$insert
[
"house_id"
]
=
$params
[
'house_id'
];
$insert
[
"status"
]
=
1
;
$res
=
$this
->
aCollectHouse
->
saveCollectHouse
(
$insert
);
//int(1)
}
if
(
$res
)
{
return
$this
->
response
(
"200"
,
"成功"
);
}
else
{
return
$this
->
response
(
"101"
,
"失败"
);
}
}
}
\ No newline at end of file
application/api_broker/controller/CollectUser.php
0 → 100644
View file @
0dde21e6
<?php
namespace
app\api_broker\controller
;
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2018/7/4
* Time: 下午3:25
*/
use
app\api_broker\extend\Basic
;
use
app\model\ACollectUser
;
use
think\Request
;
class
CollectUser
extends
Basic
{
protected
$aCollectUser
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
aCollectUser
=
new
ACollectUser
();
}
/**
* 收藏或取消收藏客户
* User: 朱伟
* Date: 2018-07-04
* Time: 15:35:40
*/
public
function
addCollectUser
()
{
$params
=
$this
->
params
;
/*$params = array(
"agents_id" => 2,
"user_id" => 3,
"status" => 2,
);*/
if
(
!
isset
(
$params
[
"agents_id"
])
or
!
isset
(
$params
[
"user_id"
])
or
!
isset
(
$params
[
"status"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
//先判断是否已经存在数据
$field
=
'id,status'
;
$get_params
[
'agents_id'
]
=
$params
[
"agents_id"
];
$get_params
[
'user_id'
]
=
$params
[
"user_id"
];
$res
=
$this
->
aCollectUser
->
getCollectUser
(
$field
,
$get_params
);
if
(
$res
){
//如果存在
if
(
$res
[
0
][
'status'
]
!=
$params
[
"status"
]
){
//如果存在-并且状态一致 不作处理 不一致则更新状态
$insert
[
"id"
]
=
$res
[
0
][
'id'
];
$insert
[
"status"
]
=
$params
[
"status"
];
$res
=
$this
->
aCollectUser
->
updateCollectUser
(
$insert
);
//int(1)
}
else
{
$res
=
true
;
}
}
else
{
//不存在则新增数据
$insert
[
"agents_id"
]
=
$params
[
'agents_id'
];
$insert
[
"user_id"
]
=
$params
[
'user_id'
];
$insert
[
"status"
]
=
1
;
$res
=
$this
->
aCollectUser
->
saveCollectUser
(
$insert
);
//int(1)
}
if
(
$res
)
{
return
$this
->
response
(
"200"
,
"成功"
);
}
else
{
return
$this
->
response
(
"101"
,
"失败"
);
}
}
}
\ No newline at end of file
application/model/ACollectHouse.php
0 → 100755
View file @
0dde21e6
<?php
namespace
app\model
;
use
think\Db
;
use
think\Model
;
class
ACollectHouse
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'a_collect_house'
;
public
function
saveCollectHouse
(
$data
)
{
$time
=
date
(
"Y-m-d h:i:sa"
,
time
());
$data
[
'create_time'
]
=
$time
;
$data
[
'update_time'
]
=
$time
;
return
$this
->
insert
(
$data
);
}
/**
* 查询数据
* 朱伟 2018-07-04
*/
public
function
getCollectHouse
(
$field
,
$params
)
{
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
//->alias('a')
->
where
(
$params
)
->
select
();
//dump($this->getLastSql());
return
$result
;
}
/**
* 更新数据
* 朱伟 2018-07-04
*/
public
function
updateCollectHouse
(
$params
)
{
$result
=
$this
->
update
(
$params
);
//dump($this->getLastSql());
return
$result
;
}
}
application/model/ACollectUser.php
0 → 100755
View file @
0dde21e6
<?php
namespace
app\model
;
use
think\Db
;
use
think\Model
;
class
ACollectUser
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'a_collect_user'
;
public
function
saveCollectUser
(
$data
)
{
$time
=
date
(
"Y-m-d h:i:sa"
,
time
());
$data
[
'create_time'
]
=
$time
;
$data
[
'update_time'
]
=
$time
;
return
$this
->
insert
(
$data
);
}
/**
* 查询数据
* 朱伟 2018-07-04
*/
public
function
getCollectUser
(
$field
,
$params
)
{
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
//->alias('a')
->
where
(
$params
)
->
select
();
//dump($this->getLastSql());
return
$result
;
}
/**
* 更新数据
* 朱伟 2018-07-04
*/
public
function
updateCollectUser
(
$params
)
{
$result
=
$this
->
update
(
$params
);
//dump($this->getLastSql());
return
$result
;
}
}
application/route.php
View file @
0dde21e6
...
...
@@ -501,6 +501,9 @@ Route::group('broker', [
'getComment'
=>
[
'api_broker/news/getComment'
,
[
'method'
=>
'GET'
]
],
//商学院评论列表
'commentNews'
=>
[
'api_broker/news/commentNews'
,
[
'method'
=>
'POST'
]
],
//评论商学院文章
'addCollectUser'
=>
[
'api_broker/CollectUser/addCollectUser'
,
[
'method'
=>
'POST|GET'
]
],
//监督执行列表 朱伟 2018-06-15
'addCollectHouse'
=>
[
'api_broker/CollectHouse/addCollectHouse'
,
[
'method'
=>
'POST|GET'
]
],
//新增-监督执行 朱伟 2018-06-20
]);
...
...
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