港口翻译
This commit is contained in:
@@ -5,6 +5,8 @@ namespace app\admin\service;
|
||||
use app\admin\validate\SysPortValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysPort;
|
||||
use app\common\utils\translation\service\TranslationService;
|
||||
use app\queue\utils\Translat;
|
||||
use support\Request;
|
||||
|
||||
class SysPortService
|
||||
@@ -22,6 +24,8 @@ class SysPortService
|
||||
*/
|
||||
protected $validator = SysPortValidate::class;
|
||||
|
||||
public $translatFields = ['port_name','description'];
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
@@ -97,6 +101,20 @@ class SysPortService
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function afterServiceStore($res)
|
||||
{
|
||||
$sourceLocale = locale();
|
||||
$data = $res->toArray();
|
||||
$traitsourceFields = Translat::extractSourceFields($data, $this->translatFields);
|
||||
|
||||
(new TranslationService())->queueTranslations(
|
||||
'sys_port_translation',
|
||||
$res['id'],
|
||||
$sourceLocale,
|
||||
$traitsourceFields
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加前置处理
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace app\admin\service;
|
||||
use app\admin\validate\VehColorValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\VehColor;
|
||||
use app\common\utils\translation\service\TranslationService;
|
||||
use app\queue\utils\Translat;
|
||||
|
||||
class VehColorService
|
||||
{
|
||||
@@ -21,6 +23,8 @@ class VehColorService
|
||||
*/
|
||||
protected $validator = VehColorValidate::class;
|
||||
|
||||
public $translatFields = ['color_text'];
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
@@ -28,4 +32,18 @@ class VehColorService
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
public function afterServiceStore($res)
|
||||
{
|
||||
$sourceLocale = locale();
|
||||
$data = $res->toArray();
|
||||
$traitsourceFields = Translat::extractSourceFields($data, $this->translatFields);
|
||||
|
||||
(new TranslationService())->queueTranslations(
|
||||
'veh_color_translation',
|
||||
$res['id'],
|
||||
$sourceLocale,
|
||||
$traitsourceFields
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class SysPortTranslation extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_port_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'port_id', 'locale', 'port_name', 'description', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehColorTranslation extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'veh_color_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'color_id', 'locale', 'color_text', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -19,6 +19,14 @@ return [
|
||||
'translation_model' => app\common\model\SysDictItemTranslation::class,
|
||||
'foreign_key' => 'dict_item_id',
|
||||
],
|
||||
'sys_port_translation' => [
|
||||
'translation_model' => app\common\model\SysPortTranslation::class,
|
||||
'foreign_key' => 'port_id',
|
||||
],
|
||||
'veh_color_translation' => [
|
||||
'translation_model' => app\common\model\VehColorTranslation::class,
|
||||
'foreign_key' => 'color_id',
|
||||
],
|
||||
],
|
||||
|
||||
// 默认支持的目标语种列表
|
||||
|
||||
Reference in New Issue
Block a user