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
4c07227a
Commit
4c07227a
authored
Jul 18, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑办公室
parent
f8a8eb06
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
21 deletions
+78
-21
StoreFee.php
application/index/controller/StoreFee.php
+63
-6
StoreFeeValidate.php
application/index/validate/StoreFeeValidate.php
+3
-3
FOffice.php
application/model/FOffice.php
+10
-12
route.php
application/route.php
+2
-0
No files found.
application/index/controller/StoreFee.php
View file @
4c07227a
...
...
@@ -25,7 +25,7 @@ class StoreFee extends Basic
}
/**
* 新增
数据
* 新增
办公室
* @return \think\Response
*/
public
function
addOffice
()
...
...
@@ -44,6 +44,10 @@ class StoreFee extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
}
$office
=
$this
->
getOffice
(
''
,
$params
[
'office_name'
]);
if
(
$office
)
{
return
$this
->
response
(
"101"
,
'已存在该办公室!'
);
}
$data
[
"site_id"
]
=
$params
[
'site_id'
];
$data
[
"office_name"
]
=
$params
[
'office_name'
];
...
...
@@ -61,6 +65,37 @@ class StoreFee extends Basic
}
/**
* 编辑办公室
* @return \think\Response
*/
public
function
editOffice
()
{
$params
=
$this
->
params
;
$params
=
array
(
"id"
=>
'1'
,
//id
"site_id"
=>
'10001'
,
//站点id
"office_name"
=>
'鳖12222'
,
//办公室名
"office_address"
=>
'上海市黄浦区龙华东路800号'
,
//办公室地址
"rent"
=>
5000
,
//租金每月
);
$checkResult
=
$this
->
validate
(
$params
,
"StoreFeeValidate.editOffice"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$office
=
$this
->
getOffice
(
$params
[
'id'
],
$name
=
''
);
if
(
!
$office
)
{
return
$this
->
response
(
"101"
,
'不存在该办公室!'
);
}
$this
->
f_office
->
updateOffice
(
$params
);
return
$this
->
response
(
"200"
,
"成功"
);
}
/**
* 办公室列表
* @return \think\Response
...
...
@@ -108,15 +143,15 @@ class StoreFee extends Basic
{
$params
=
$this
->
params
;
//
$params = array(
//
"id" => '1',//id
//
);
$params
=
array
(
"id"
=>
'1'
,
//id
);
$checkResult
=
$this
->
validate
(
$params
,
"StoreFeeValidate.getOfficeInfo"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$conditions
=
[
];
$field
=
'id,site_id,office_name,office_address'
;
$conditions
[
'id'
]
=
$params
[
'id'
];
$field
=
'id,
rent,
site_id,office_name,office_address'
;
$result
=
$this
->
f_office
->
findByOne
(
$field
,
$conditions
);
if
(
!
$result
)
{
return
$this
->
response
(
"101"
,
'此办公室不存在'
);
...
...
@@ -126,6 +161,27 @@ class StoreFee extends Basic
}
/**
* 根据ID或者办公室名字查询是否存在
* @param $id
* @param $name
* @return array|false|\PDOStatement|string|\think\Model
*/
public
function
getOffice
(
$id
=
''
,
$name
=
''
)
{
$conditions
=
[];
if
(
$id
)
{
$conditions
[
'id'
]
=
$id
;
}
if
(
$name
)
{
$conditions
[
'office_name'
]
=
$name
;
}
$field
=
'id'
;
$result
=
$this
->
f_office
->
findByOne
(
$field
,
$conditions
);
return
$result
;
}
}
\ No newline at end of file
application/index/validate/StoreFeeValidate.php
View file @
4c07227a
...
...
@@ -13,8 +13,6 @@ class StoreFeeValidate extends Validate {
'rent'
=>
'require|number|gt:0'
,
'id'
=>
'require|number|gt:0'
,
];
protected
$message
=
[
...
...
@@ -32,7 +30,8 @@ class StoreFeeValidate extends Validate {
protected
$scene
=
[
'addOffice'
=>
[
'site_id'
,
'office_name'
,
'office_address'
,
'rent'
],
'getOfficeInfo'
=>
[
'id'
],
'getOfficeInfo'
=>
[
'id'
],
'editOffice'
=>
[
'id'
,
'site_id'
,
'office_name'
,
'office_address'
,
'rent'
],
];
}
\ No newline at end of file
application/model/FOffice.php
View file @
4c07227a
...
...
@@ -74,18 +74,16 @@ class FOffice extends BaseModel
->
count
();
return
$result
;
}
//
// /**
// * 更新数据
// * 朱伟 2018-10-18 10:41:10
// */
// public function updateOffice($params)
// {
// $result = $this->db_->update($params);
// //dump($this->db_->getLastSql());
// return $result;
//
// }
/**
* 更新数据
* @param $params
* @return int|string
*/
public
function
updateOffice
(
$params
)
{
return
$this
->
db_
->
update
(
$params
);
}
//
// /**
// * 根据id获取单个字段值
...
...
application/route.php
View file @
4c07227a
...
...
@@ -520,6 +520,8 @@ Route::group('index', [
'addOffice'
=>
[
'index/StoreFee/addOffice'
,
[
'method'
=>
'POST|GET'
]
],
'getOfficeList'
=>
[
'index/StoreFee/getOfficeList'
,
[
'method'
=>
'POST|GET'
]
],
'getOfficeInfo'
=>
[
'index/StoreFee/getOfficeInfo'
,
[
'method'
=>
'POST|GET'
]
],
'editOffice'
=>
[
'index/StoreFee/editOffice'
,
[
'method'
=>
'POST|GET'
]
],
]);
...
...
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