Initial commit

This commit is contained in:
易焱
2021-03-13 18:42:01 +08:00
commit d9a3c376d5
3243 changed files with 627198 additions and 0 deletions
@@ -0,0 +1,56 @@
<?php
namespace Admin\Model;
use Think\Model\RelationModel;
class ProductModel extends RelationModel{
protected $_link = array(
"who_add"=>array(
'mapping_type' => self::BELONGS_TO,
'class_name' => 'user',
'mapping_fields' => 'user_name',
'foreign_key' => 'product_who_add',
),
"who_modify"=>array(
'mapping_type' => self::BELONGS_TO,
'class_name' => 'user',
'mapping_fields' => 'user_name',
'foreign_key' => 'product_who_modify',
),
"flow"=>array(
'mapping_type' => self::BELONGS_TO,
'class_name' => 'flow',
'mapping_fields' => 'flow_name',
'foreign_key' => 'flow_id',
)
);
//验证
protected $_validate=array(
//array("字段","验证规则","错误提示",["验证条件","附加条件","验证时间"]),
array("product_name","require","产品名称不能为空"),
array("flow_id","require","工艺流程不能为空"),
array("product_name","","产品名称已存在",0,"unique"),
);
//保存信息
public function data_save(){
//创建数据
$data=$this->create();
$member_id = UID;
$data['product_who_modify'] = $member_id;
$data['product_time_modify'] = time();
$this->data($data)->save();
return $data['product_id'];
}
//保存信息
public function data_add(){
//创建数据
$data=$this->create();
$member_id = UID;
$data['product_who_add'] = $member_id;
$data['product_time_add'] = time();
$id = $this->data($data)->add();
return $id;
}
}