Merge branch 'develop' into feature/crmAdmin0717
# Conflicts: # app/admin/controller/RoleController.php # app/common/controller/AuthController.php # app/common/logic/AuthLogic.php # app/common/logic/PermLogic.php # app/common/model/User.php # app/common/service/PermService.php # app/common/validate/RoleValidate.php # app/controller/IndexController.php # app/functions.php # app/ticket/controller/ConversationController.php # app/ticket/controller/TicketController.php # app/ticket/logic/TicketLogic.php # app/ticket/service/CategorieService.php # app/ticket/service/TicketService.php # app/view/index/qrcode.html # composer.json # composer.lock # config/middleware.php # config/route.php # config/whitelist.php
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
class BaseLogic
|
||||
{
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
public function getList(array $params, string $modelClass)
|
||||
{
|
||||
$query = $modelClass::query();
|
||||
|
||||
// 你可以在此处添加分页、排序等功能
|
||||
if (isset($params['page']) && isset($params['per_page'])) {
|
||||
$query->paginate($params['per_page'], ['*'], 'page', $params['page']);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个记录
|
||||
*/
|
||||
public function getDetail(int $id, string $modelClass)
|
||||
{
|
||||
$record = $modelClass::find($id);
|
||||
if (!$record) {
|
||||
throw new BusinessException("记录不存在", 404);
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建记录
|
||||
*/
|
||||
public function create(array $data, string $modelClass)
|
||||
{
|
||||
$model = new $modelClass;
|
||||
$model->fill($data); // 根据字段填充数据
|
||||
try {
|
||||
$model->save();
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("创建记录失败: " . $e->getMessage(), 500);
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*/
|
||||
public function update(array $data, string $modelClass)
|
||||
{
|
||||
$record = $modelClass::find($data['id']);
|
||||
if (!$record) {
|
||||
throw new BusinessException("记录不存在", 404);
|
||||
}
|
||||
|
||||
$record->update($data);
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*/
|
||||
public function delete(int $id, string $modelClass)
|
||||
{
|
||||
$record = $modelClass::find($id);
|
||||
if (!$record) {
|
||||
throw new BusinessException("记录不存在", 404);
|
||||
}
|
||||
|
||||
try {
|
||||
$record->delete();
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("删除记录失败: " . $e->getMessage(), 500);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\model\CorpFeishuApp;
|
||||
|
||||
class CorpFeishuAppLogic
|
||||
{
|
||||
|
||||
|
||||
public function getFeishuApp($corpId)
|
||||
{
|
||||
return CorpFeishuApp::where('corp_id', $corpId)->first(['id', 'corp_id', 'name', 'app_id', 'r_url', 'state']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\model\Corp;
|
||||
|
||||
class CorpLogic
|
||||
{
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return Corp::where('status', 1)->orderBy('sort', 'asc')->get(['id', 'name', 'abbr', 'tenant_key']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user