add 资料接收

This commit is contained in:
chenbo 2024-02-23 09:22:08 +08:00
parent ab51708606
commit 65e801ce32
5 changed files with 449 additions and 0 deletions

@ -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\adminapi\controller;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\DataReceptionLists;
use app\adminapi\logic\DataReceptionLogic;
use app\adminapi\validate\DataReceptionValidate;
/**
* DataReception控制器
* Class DataReceptionController
* @package app\adminapi\controller
*/
class DataReceptionController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function lists()
{
return $this->dataLists(new DataReceptionLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function add()
{
$params = (new DataReceptionValidate())->post()->goCheck('add');
$result = DataReceptionLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(DataReceptionLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function edit()
{
$params = (new DataReceptionValidate())->post()->goCheck('edit');
$result = DataReceptionLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(DataReceptionLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function delete()
{
$params = (new DataReceptionValidate())->post()->goCheck('delete');
DataReceptionLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function detail()
{
$params = (new DataReceptionValidate())->goCheck('detail');
$result = DataReceptionLogic::detail($params);
return $this->data($result);
}
}

@ -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\adminapi\lists;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\DataReception;
use app\common\lists\ListsSearchInterface;
/**
* DataReception列表
* Class DataReceptionLists
* @package app\adminapi\lists
*/
class DataReceptionLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function setSearch(): array
{
return [
'=' => ['num', 'project', 'project_num'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function lists(): array
{
return DataReception::where($this->searchWhere)
->field(['id', 'dataid', 'num', 'project', 'project_num', 'apptime', 'person', 'number', 'position', 'tips'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function count(): int
{
return DataReception::where($this->searchWhere)->count();
}
}

@ -0,0 +1,136 @@
<?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\adminapi\logic;
use app\common\model\DataReception;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* DataReception逻辑
* Class DataReceptionLogic
* @package app\adminapi\logic
*/
class DataReceptionLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/23 09:21
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
DataReception::create([
'dataid' => $params['dataid'],
'num' => $params['num'],
'project' => $params['project'],
'project_num' => $params['project_num'],
'apptime' => $params['apptime'],
'person' => $params['person'],
'number' => $params['number'],
'position' => $params['position'],
'tips' => $params['tips'],
'bidding_file' => $params['bidding_file'],
'zbkzj_file' => $params['zbkzj_file'],
'gczjht_file' => $params['gczjht_file'],
'xmbgqzzl_file' => $params['xmbgqzzl_file'],
'ssgsysjs_file' => $params['ssgsysjs_file'],
'wlhj_file' => $params['wlhj_file'],
'other_file' => $params['other_file'],
]);
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/02/23 09:21
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
DataReception::where('id', $params['id'])->update([
'dataid' => $params['dataid'],
'num' => $params['num'],
'project' => $params['project'],
'project_num' => $params['project_num'],
'apptime' => $params['apptime'],
'person' => $params['person'],
'number' => $params['number'],
'position' => $params['position'],
'tips' => $params['tips'],
'bidding_file' => $params['bidding_file'],
'zbkzj_file' => $params['zbkzj_file'],
'gczjht_file' => $params['gczjht_file'],
'xmbgqzzl_file' => $params['xmbgqzzl_file'],
'ssgsysjs_file' => $params['ssgsysjs_file'],
'wlhj_file' => $params['wlhj_file'],
'other_file' => $params['other_file'],
]);
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/02/23 09:21
*/
public static function delete(array $params): bool
{
return DataReception::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/23 09:21
*/
public static function detail($params): array
{
return DataReception::findOrEmpty($params['id'])->toArray();
}
}

@ -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\adminapi\validate;
use app\common\validate\BaseValidate;
/**
* DataReception验证器
* Class DataReceptionValidate
* @package app\adminapi\validate
*/
class DataReceptionValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return DataReceptionValidate
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return DataReceptionValidate
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function sceneEdit()
{
return $this->only(['id']);
}
/**
* @notes 删除场景
* @return DataReceptionValidate
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return DataReceptionValidate
* @author likeadmin
* @date 2024/02/23 09:21
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

@ -0,0 +1,34 @@
<?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;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* DataReception模型
* Class DataReception
* @package app\common\model
*/
class DataReception extends BaseModel
{
use SoftDelete;
protected $name = 'data_reception';
protected $deleteTime = 'delete_time';
}