新增行政合同
This commit is contained in:
parent
734265d495
commit
17dc611c28
@ -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\contract;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\contract\AdministrativeContractLists;
|
||||
use app\adminapi\logic\contract\AdministrativeContractLogic;
|
||||
use app\adminapi\validate\contract\AdministrativeContractValidate;
|
||||
|
||||
|
||||
/**
|
||||
* AdministrativeContract控制器
|
||||
* Class AdministrativeContractController
|
||||
* @package app\adminapi\controller\contract
|
||||
*/
|
||||
class AdministrativeContractController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AdministrativeContractLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new AdministrativeContractValidate())->post()->goCheck('add');
|
||||
$result = AdministrativeContractLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AdministrativeContractLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new AdministrativeContractValidate())->post()->goCheck('edit');
|
||||
$result = AdministrativeContractLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AdministrativeContractLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new AdministrativeContractValidate())->post()->goCheck('delete');
|
||||
AdministrativeContractLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new AdministrativeContractValidate())->goCheck('detail');
|
||||
$result = AdministrativeContractLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
77
app/adminapi/lists/contract/AdministrativeContractLists.php
Normal file
77
app/adminapi/lists/contract/AdministrativeContractLists.php
Normal 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\adminapi\lists\contract;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\contract\AdministrativeContract;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* AdministrativeContract列表
|
||||
* Class AdministrativeContractLists
|
||||
* @package app\adminapi\listscontract
|
||||
*/
|
||||
class AdministrativeContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['supplier_id', 'contract_no', 'contract_name', 'procurement_type', 'asset_apply_no'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return AdministrativeContract::where($this->searchWhere)
|
||||
->field(['*'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return AdministrativeContract::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
132
app/adminapi/logic/contract/AdministrativeContractLogic.php
Normal file
132
app/adminapi/logic/contract/AdministrativeContractLogic.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?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\contract;
|
||||
|
||||
|
||||
use app\common\model\contract\AdministrativeContract;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* AdministrativeContract逻辑
|
||||
* Class AdministrativeContractLogic
|
||||
* @package app\adminapi\logic\contract
|
||||
*/
|
||||
class AdministrativeContractLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
AdministrativeContract::create([
|
||||
'supplier_id' => $params['supplier_id'] ?? 0,
|
||||
'contract_no' => $params['contract_no'] ?? '',
|
||||
'contract_name' => $params['contract_name'] ?? '',
|
||||
'procurement_type' => $params['procurement_type'] ?? 0,
|
||||
'asset_apply_no' => $params['asset_apply_no'] ?? '',
|
||||
'start_date' => $params['start_date'] ?? '',
|
||||
'end_date' => $params['end_date'] ?? '',
|
||||
'signing_date' => $params['signing_date'] ?? '',
|
||||
'pay_type' => $params['pay_type'] ?? 0,
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'amount_daxie' => $params['amount_daxie'] ?? '',
|
||||
'main_content' => $params['main_content'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
AdministrativeContract::where('id', $params['id'])->update([
|
||||
'supplier_id' => $params['supplier_id'] ?? 0,
|
||||
'contract_no' => $params['contract_no'] ?? '',
|
||||
'contract_name' => $params['contract_name'] ?? '',
|
||||
'procurement_type' => $params['procurement_type'] ?? 0,
|
||||
'asset_apply_no' => $params['asset_apply_no'] ?? '',
|
||||
'start_date' => $params['start_date'] ?? '',
|
||||
'end_date' => $params['end_date'] ?? '',
|
||||
'signing_date' => $params['signing_date'] ?? '',
|
||||
'pay_type' => $params['pay_type'] ?? 0,
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'amount_daxie' => $params['amount_daxie'] ?? '',
|
||||
'main_content' => $params['main_content'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return AdministrativeContract::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return AdministrativeContract::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?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\contract;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* AdministrativeContract验证器
|
||||
* Class AdministrativeContractValidate
|
||||
* @package app\adminapi\validate\contract
|
||||
*/
|
||||
class AdministrativeContractValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'supplier_id' => 'require',
|
||||
'contract_no' => 'require',
|
||||
'contract_name' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return AdministrativeContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return AdministrativeContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'supplier_id', 'contract_no', 'contract_name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return AdministrativeContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return AdministrativeContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/13 11:40
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
34
app/common/model/contract/AdministrativeContract.php
Normal file
34
app/common/model/contract/AdministrativeContract.php
Normal file
@ -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\contract;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* AdministrativeContract模型
|
||||
* Class AdministrativeContract
|
||||
* @package app\common\model\contract
|
||||
*/
|
||||
class AdministrativeContract extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'administrative_contract';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user