初始化代码

This commit is contained in:
2025-12-22 14:32:54 +08:00
parent e27ab90d9f
commit d02b31a8b9
1459 changed files with 240973 additions and 0 deletions

160
app/farm/model/Source.php Normal file
View File

@@ -0,0 +1,160 @@
<?php
namespace app\farm\model;
use app\BaseModel;
use think\facade\Db;
class Source extends BaseModel
{
//定义表名
protected $name = 'lbfarm_source';
protected $append = [
'stage'
];
/**
* @author chenniang
* @DataTime: 2021-12-14 17:23
* @功能说明:
*/
public function getStageAttr($value,$data){
if(!empty($data['id'])){
$source_text_model = new SourceText();
$list = $source_text_model->where(['source_id'=>$data['id']])->select()->toArray();
return $list;
}
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:04
* @功能说明:添加
*/
public function dataAdd($data){
$data['create_time'] = time();
if(!empty($data['stage'])){
$stage= $data['stage'];
unset($data['stage']);
}
$res = $this->insert($data);
$id = $this->getLastInsID();
if(!empty($stage)){
$this->updateSome($id,$stage,$data['uniacid']);
}
return $id;
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:05
* @功能说明:编辑
*/
public function dataUpdate($dis,$data){
if(!empty($data['stage'])){
$stage = $data['stage'];
unset($data['stage']);
}
$res = $this->where($dis)->update($data);
if(!empty($stage)){
$this->updateSome($dis['id'],$stage,$data['uniacid']);
}
return $res;
}
/**
* @author chenniang
* @DataTime: 2021-12-14 17:14
* @功能说明:
*/
public function updateSome($id,$data,$uniacid){
$source_text_model = new SourceText();
$source_text_model->where(['source_id'=>$id])->delete();
if(!empty($data)){
foreach ($data as $v){
$v['uniacid'] = $uniacid;
$v['source_id'] = $id;
$source_text_model->insert($v);
}
}
return true;
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:06
* @功能说明:列表
*/
public function dataList($dis,$page){
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
return $data;
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:43
* @功能说明:
*/
public function dataInfo($dis){
$data = $this->where($dis)->find();
return !empty($data)?$data->toArray():[];
}
}