add 驱虫记录

This commit is contained in:
chenbo 2024-01-15 10:05:18 +08:00
parent 261344d831
commit 67f2020170
5 changed files with 455 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller\suyuan_operation;
use app\common\controller\BaseLikeAdminController;
use app\api\lists\suyuan_operation\OperationDewormingLogLists;
use app\api\logic\suyuan_operation\OperationDewormingLogLogic;
use app\api\validate\suyuan_operation\OperationDewormingLogValidate;
/**
* OperationDewormingLog控制器
* Class OperationDewormingLogController
* @package app\api\controller\suyuan_operation
*/
class OperationDewormingLogController extends BaseLikeAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function lists()
{
return $this->dataLists(new OperationDewormingLogLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function add()
{
$params = (new OperationDewormingLogValidate())->post()->goCheck('add');
$result = OperationDewormingLogLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(OperationDewormingLogLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function edit()
{
$params = (new OperationDewormingLogValidate())->post()->goCheck('edit');
$result = OperationDewormingLogLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(OperationDewormingLogLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function delete()
{
$params = (new OperationDewormingLogValidate())->post()->goCheck('delete');
OperationDewormingLogLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function detail()
{
$params = (new OperationDewormingLogValidate())->goCheck('detail');
$result = OperationDewormingLogLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,77 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\lists\suyuan_operation;
use app\common\lists\BaseDataLists;
use app\common\model\suyuan_operation\OperationDewormingLog;
use app\common\lists\ListsSearchInterface;
/**
* OperationDewormingLog列表
* Class OperationDewormingLogLists
* @package app\api\listssuyuan_operation
*/
class OperationDewormingLogLists extends BaseDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function setSearch(): array
{
return [
'=' => ['fence_house_id', 'animal_info_id'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function lists(): array
{
return OperationDewormingLog::where($this->searchWhere)
->field(['id', 'fence_house_id', 'animal_info_id', 'vermifuge_name', 'deworming_date', 'deworming_method', 'operator', 'remark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function count(): int
{
return OperationDewormingLog::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,120 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\logic\suyuan_operation;
use app\common\model\suyuan_operation\OperationDewormingLog;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* OperationDewormingLog逻辑
* Class OperationDewormingLogLogic
* @package app\api\logic\suyuan_operation
*/
class OperationDewormingLogLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/01/15 10:04
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
OperationDewormingLog::create([
'fence_house_id' => $params['fence_house_id'],
'animal_info_id' => $params['animal_info_id'],
'vermifuge_name' => $params['vermifuge_name'],
'deworming_date' => $params['deworming_date'],
'deworming_method' => $params['deworming_method'],
'operator' => $params['operator'],
'image' => $params['image'],
'remark' => $params['remark'],
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/01/15 10:04
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
OperationDewormingLog::where('id', $params['id'])->update([
'fence_house_id' => $params['fence_house_id'],
'animal_info_id' => $params['animal_info_id'],
'vermifuge_name' => $params['vermifuge_name'],
'deworming_date' => $params['deworming_date'],
'deworming_method' => $params['deworming_method'],
'operator' => $params['operator'],
'image' => $params['image'],
'remark' => $params['remark'],
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/01/15 10:04
*/
public static function delete(array $params): bool
{
return OperationDewormingLog::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/01/15 10:04
*/
public static function detail($params): array
{
return OperationDewormingLog::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,94 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\validate\suyuan_operation;
use app\common\validate\BaseValidate;
/**
* OperationDewormingLog验证器
* Class OperationDewormingLogValidate
* @package app\api\validate\suyuan_operation
*/
class OperationDewormingLogValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return OperationDewormingLogValidate
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return OperationDewormingLogValidate
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function sceneEdit()
{
return $this->only(['id']);
}
/**
* @notes 删除场景
* @return OperationDewormingLogValidate
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return OperationDewormingLogValidate
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,56 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\suyuan_operation;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* OperationDewormingLog模型
* Class OperationDewormingLog
* @package app\common\model\suyuan_operation
*/
class OperationDewormingLog extends BaseModel
{
use SoftDelete;
protected $name = 'operation_deworming_log';
protected $deleteTime = 'delete_time';
/**
* @notes 关联fenceHouseAttr
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function fenceHouseAttr()
{
return $this->hasOne(\app\common\model\fence_house\FenceHouse::class, 'id', 'fence_house_id');
}
/**
* @notes 关联animalInfo
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2024/01/15 10:04
*/
public function animalInfo()
{
return $this->hasOne(\app\common\model\animal_info\AnimalInfo::class, 'id', 'animal_info_id');
}
}