1
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id ID(主键)
|
||||
* @property string $username 用户名
|
||||
* @property string $nickname 昵称
|
||||
* @property string $password 密码
|
||||
* @property string $avatar 头像
|
||||
* @property string $email 邮箱
|
||||
* @property string $mobile 手机
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $login_at 登录时间
|
||||
* @property string $roles 角色
|
||||
* @property integer $status 状态 0正常 1禁用
|
||||
*/
|
||||
class Admin extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_admins';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id ID(主键)
|
||||
* @property string $admin_id 管理员id
|
||||
* @property string $role_id 角色id
|
||||
*/
|
||||
class AdminRole extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_admin_roles';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use support\Model;
|
||||
|
||||
|
||||
class Base extends Model
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $connection = 'plugin.admin.mysql';
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
*
|
||||
* @param DateTimeInterface $date
|
||||
* @return string
|
||||
*/
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
|
||||
use support\exception\BusinessException;
|
||||
|
||||
/**
|
||||
* 字典相关
|
||||
*/
|
||||
class Dict
|
||||
{
|
||||
/**
|
||||
* 获取字典
|
||||
* @param $name
|
||||
* @return mixed|null
|
||||
*/
|
||||
public static function get($name)
|
||||
{
|
||||
$value = Option::where('name', static::dictNameToOptionName($name))->value('value');
|
||||
return $value ? json_decode($value, true) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存字典
|
||||
* @param $name
|
||||
* @param $values
|
||||
* @return void
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public static function save($name, $values)
|
||||
{
|
||||
if (!preg_match('/[a-zA-Z]/', $name)) {
|
||||
throw new BusinessException('字典名只能包含字母');
|
||||
}
|
||||
$option_name = static::dictNameToOptionName($name);
|
||||
if (!$option = Option::where('name', $option_name)->first()) {
|
||||
$option = new Option;
|
||||
}
|
||||
$format_values = static::filterValue($values);
|
||||
$option->name = $option_name;
|
||||
$option->value = json_encode($format_values, JSON_UNESCAPED_UNICODE);
|
||||
$option->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @param array $names
|
||||
* @return void
|
||||
*/
|
||||
public static function delete(array $names)
|
||||
{
|
||||
foreach ($names as $index => $name) {
|
||||
$names[$index] = static::dictNameToOptionName($name);
|
||||
}
|
||||
Option::whereIn('name', $names)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典名到option名转换
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function dictNameToOptionName(string $name): string
|
||||
{
|
||||
return "dict_$name";
|
||||
}
|
||||
|
||||
/**
|
||||
* option名到字典名转换
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function optionNameToDictName(string $name): string
|
||||
{
|
||||
return substr($name, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤值
|
||||
* @param array $values
|
||||
* @return array
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public static function filterValue(array $values): array
|
||||
{
|
||||
$format_values = [];
|
||||
foreach ($values as $item) {
|
||||
if (!isset($item['value']) || !isset($item['name'])) {
|
||||
throw new BusinessException('字典格式错误', 1);
|
||||
}
|
||||
$format_values[] = ['value' => $item['value'], 'name' => $item['name']];
|
||||
}
|
||||
return $format_values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id 唯一标识(主键)
|
||||
* @property string $name 港口/仓库名称
|
||||
* @property string $name_en 英文名称
|
||||
* @property string $address 详细地址
|
||||
* @property string $area 所在地区
|
||||
* @property string $type 类型:港口/仓库
|
||||
* @property integer $num 车辆数
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property mixed $updated_at 更新时间
|
||||
*/
|
||||
class Location extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'locations';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
|
||||
/**
|
||||
* @property integer $id (主键)
|
||||
* @property string $name 键
|
||||
* @property mixed $value 值
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
*/
|
||||
class Option extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_options';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
|
||||
/**
|
||||
* @property integer $id 主键(主键)
|
||||
* @property string $name 角色名
|
||||
* @property string $rules 权限
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property integer $pid 上级id
|
||||
*/
|
||||
class Role extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_roles';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRuleIds()
|
||||
{
|
||||
return $this->rules ? explode(',', $this->rules) : [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id 主键(主键)
|
||||
* @property string $title 标题
|
||||
* @property string $icon 图标
|
||||
* @property string $key 标识
|
||||
* @property integer $pid 上级菜单
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $href url
|
||||
* @property integer $type 类型
|
||||
* @property integer $weight 排序
|
||||
*/
|
||||
class Rule extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_rules';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id 主键(主键)
|
||||
* @property string $name 名称
|
||||
* @property string $url url
|
||||
* @property integer $admin_id 管理员
|
||||
* @property integer $user_id 用户
|
||||
* @property integer $file_size 文件大小
|
||||
* @property string $mime_type mime类型
|
||||
* @property integer $image_width 图片宽度
|
||||
* @property integer $image_height 图片高度
|
||||
* @property string $ext 扩展名
|
||||
* @property string $storage 存储位置
|
||||
* @property string $created_at 上传时间
|
||||
* @property string $category 类别
|
||||
* @property string $updated_at 更新时间
|
||||
*/
|
||||
class Upload extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_uploads';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id 主键(主键)
|
||||
* @property string $username 用户名
|
||||
* @property string $nickname 昵称
|
||||
* @property string $password 密码
|
||||
* @property string $sex 性别
|
||||
* @property string $avatar 头像
|
||||
* @property string $email 邮箱
|
||||
* @property string $mobile 手机
|
||||
* @property integer $level 等级
|
||||
* @property string $birthday 生日
|
||||
* @property integer $money 余额
|
||||
* @property integer $score 积分
|
||||
* @property string $last_time 登录时间
|
||||
* @property string $last_ip 登录ip
|
||||
* @property string $join_time 注册时间
|
||||
* @property string $join_ip 注册ip
|
||||
* @property string $token token
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property integer $role 角色
|
||||
* @property integer $status 禁用
|
||||
*/
|
||||
class User extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_users';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id 自增主键(主键)
|
||||
* @property string $vin 车架号(17位国际标准)
|
||||
* @property string $classify
|
||||
* @property string $brand 车辆品牌
|
||||
* @property string $model 车辆型号
|
||||
* @property string $status 车辆状态(如:待发运/运输中/已到达)
|
||||
* @property string $purchase_location 买车地点
|
||||
* @property string $procedure_location 手续办理地
|
||||
* @property string $fbo_destination FBO最终目的地
|
||||
* @property integer $fbo_locations_id fbo目的地id
|
||||
* @property integer $locations_id 车辆所在地
|
||||
* @property integer $final_locations_id 最终目的地
|
||||
* @property string $departure_time 实际发车时间
|
||||
* @property string $arrival_time 实际到达时间
|
||||
* @property integer $shipping_cycle 运输周期(天)
|
||||
* @property string $img_url 图片
|
||||
* @property string $created_at 记录创建时间
|
||||
* @property string $updated_at 最后更新时间
|
||||
*/
|
||||
class Vehicle extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'vehicles';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user