feat: 初始化进销存数据开放平台项目
初始化完整的前后端项目结构,包含ThinkPHP后端API服务和Next.js前端管理系统,添加基础配置、中间件、模型、路由等核心代码,以及项目文档和静态资源。
This commit is contained in:
54
thinkphp/app/model/Client.php
Normal file
54
thinkphp/app/model/Client.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
protected $name = 'clients';
|
||||
protected $pk = 'id';
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'created_at';
|
||||
protected $updateTime = 'updated_at';
|
||||
protected $append = ['api_keys'];
|
||||
|
||||
// 客户类型枚举
|
||||
const TYPE_SUPPLIER = 'supplier';
|
||||
const TYPE_DISTRIBUTOR = 'distributor';
|
||||
const TYPE_HOSPITAL = 'hospital';
|
||||
const TYPE_OTHER = 'other';
|
||||
|
||||
// 状态枚举
|
||||
const STATUS_ENABLED = 1;
|
||||
const STATUS_DISABLED = 0;
|
||||
|
||||
/**
|
||||
* 关联API密钥
|
||||
*/
|
||||
public function apiKeys()
|
||||
{
|
||||
return $this->hasMany(ApiKey::class, 'client_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取api_keys字段(下划线命名)
|
||||
*/
|
||||
public function getApiKeysAttr()
|
||||
{
|
||||
return $this->apiKeys()->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户类型列表
|
||||
*/
|
||||
public static function getClientTypes()
|
||||
{
|
||||
return [
|
||||
self::TYPE_SUPPLIER => '供应商',
|
||||
self::TYPE_DISTRIBUTOR => '分销商',
|
||||
self::TYPE_HOSPITAL => '医院',
|
||||
self::TYPE_OTHER => '其他',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user