Commit 4bd7e050 authored by hujun's avatar hujun

添加部门,绑定总监关系

parent 937a5421
...@@ -11,6 +11,7 @@ namespace app\index\controller; ...@@ -11,6 +11,7 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AAgents; use app\model\AAgents;
use app\model\ADistrict;
use app\model\Agents; use app\model\Agents;
use app\model\GHousesToAgents; use app\model\GHousesToAgents;
...@@ -171,7 +172,7 @@ class Broker extends Basic ...@@ -171,7 +172,7 @@ class Broker extends Basic
} }
/** /**
* 总监列表 * 部门总监列表
* *
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
...@@ -200,9 +201,26 @@ class Broker extends Basic ...@@ -200,9 +201,26 @@ class Broker extends Basic
} }
/** /**
* 总监列表页面 * 部门总监列表页面
*/ */
public function districtList() { public function districtList() {
return view('agent/district'); return view('agent/district');
} }
/**
* 添加部门,绑定总监关系
*
* @return \think\Response
* @throws \think\exception\PDOException
*/
public function addDistrict () {
if ($this->params['department_name'] || $this->params['agents_id']) {
$district = new ADistrict();
$this->data = $district->addDepartmentAgents($this->params, $this->params['agents_id']);
} else {
$this->code = 101;
$this->msg = 'department or district is null';
}
return $this->response($this->code, $this->msg, $this->data);
}
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/2/2
* Time: 14:28
*/
namespace app\model;
class ADistrict extends BaseModel
{
/**
* 添加部门,绑定总监关系
*
* @param $data
* @param $agents_id
* @return bool
* @throws \think\exception\PDOException
*/
public function addDepartmentAgents($data, $agents_id) {
$this->startTrans();
$date = date('Y-m-d H:i:s');
$this->save([
'district_name' => $data['department_name'],
'create_time' => $date
]);
if ($this->id) {
$agents = new AAgents();
$agents_edit = $agents->save(['district_id' => $this->id],['id'=>$agents_id]);
if ($agents_edit) {
$resutlt = $this->id;
$this->commit();
} else {
$resutlt = false;
$this->rollback();
}
} else {
$resutlt = false;
$this->rollback();
}
return $resutlt;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment