Commit 91d8f8eb authored by zhuwei's avatar zhuwei

新增数据

parent cde2d35d
<?php
namespace app\index\controller;
/**
* Created by PhpStorm.
* User: zhuwei
* Date:2019-07-17
* Time:16:45:37
*/
use app\index\extend\Basic;
use app\model\FOffice;
use think\Request;
class StoreFee extends Basic
{
protected $f_office;
public function __construct($request = null)
{
parent::__construct($request);
$this->f_office = new FOffice();
}
/**
* 新增数据
* @return \think\Response
*/
public function addFeeOffice()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
$params = array(
"site_id" => '10001',//站点id
"office_name" => '鳖',//办公室名
"office_address" =>'上海市黄浦区龙华东路800号',//办公室地址
"rent" => 5000,//租金每月
"operator_id" => 5775,
);
$checkResult = $this->validate($params, "StoreFeeValidate.addFeeOffice");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$data["site_id"] = $params['name'];
$data["office_name"] = $params['city'];
$data["office_address"] = $params['city'];
$data["rent"] = $params['city'];
$data["operator_id"] = $this->userId;
$res = $this->f_office->saveOffice($data);//int(1)
if ($res) {
return $this->response("200", "成功");
} else {
return $this->response("101", "失败");
}
}
// /**
// * 获取站点列表
// * User: 朱伟
// * Date:2018-10-18
// * Time:10:50:55
// */
// public function getSiteList()
// {
// $params = $this->params;
//
// /*$params = array(
// "id" => 5740
// );*/
//
// $field = 'id,name,city,is_del';
//
// if ($params['is_del']) {
// $params['is_del'] = 0;
// }
//
// $res = $this->aSite->getSite($field, $params);
// $data['list'] = $res;
//
// return $this->response("200", "成功", $data);
// }
//
//
//
// /**
// * 关闭或开启站点
// * @return \think\Response
// */
// public function delImageDepot(){
// $params = $this->params;
// $checkResult = $this->validate($params, "Site.delImageDepot");
// if (true !== $checkResult) {
// return $this->response("101", $checkResult);
// }
// $params_['id'] = $params['id'];
// $params_['is_del'] = $params['is_del'];
// $res = $this->aSite->updateSite($params_);//int(1)
// if($res == 1){
// return $this->response("200", "成功",['data'=>$res]);
// }else{
// return $this->response("300", "失败");
// }
// }
//
// public function siteLogList()
// {
// if (!$this->request->isAjax()) {
// return view('site/siteLogList');
// }
// }
}
\ No newline at end of file
<?php
namespace app\index\validate;
use think\Validate;
class StoreFeeValidate extends Validate {
protected $rule = [
'site_id' => 'require',
'office_name' => 'require',
'office_address' => 'require',
'rent' => 'require|number|gt:0',
];
protected $message = [
'site_id.require' => '站点不能为空',
'office_name.require' => '办公室名不能为空',
'office_address.require' => '办公室地址不能为空',
'rent.require' => '租金每月不能为空',
'rent.number' => '租金每月只能为数字',
'rent.gt' => '租金每月必须大于0',
];
protected $scene = [
'addFeeOffice' => [ 'site_id', 'office_name', 'office_address', 'rent' ],
];
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ class FOffice extends BaseModel ...@@ -13,7 +13,7 @@ class FOffice extends BaseModel
public function __construct($data = []) public function __construct($data = [])
{ {
parent::__construct($data); parent::__construct($data);
$this->db_->db_ = Db::name($this->db_->table); $this->db_ = Db::name($this->table);
} }
...@@ -24,7 +24,7 @@ class FOffice extends BaseModel ...@@ -24,7 +24,7 @@ class FOffice extends BaseModel
*/ */
public function saveOffice($data) { public function saveOffice($data) {
$time = date("Y-m-d H:i:s", time()); $time = date("Y-m-d H:i:s", time());
$data["is_del"] = 0;
$data['create_time'] = $time; $data['create_time'] = $time;
$data['update_time'] = $time; $data['update_time'] = $time;
return $this->db_->insert($data); return $this->db_->insert($data);
......
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