工单列表
This commit is contained in:
@@ -4,7 +4,7 @@ return [
|
||||
// 定义所有需要多语言支持的实体
|
||||
'entities' => [
|
||||
'ticket_categorie' => [
|
||||
'translation_model' => \app\ticket\model\TicketCategorieTranslation::class,
|
||||
'translation_model' => \app\ticket\model\CategorieTranslation::class,
|
||||
'foreign_key' => 'categorie_id',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace app\ticket\logic;
|
||||
|
||||
use app\ticket\model\TicketCategorie;
|
||||
use app\ticket\model\Categorie;
|
||||
use support\Log;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
@@ -13,20 +13,20 @@ class CategorieLogic
|
||||
$where = [];
|
||||
$size = $params['size'] ?? 10;
|
||||
$current = $params['current'] ?? 1;
|
||||
return TicketCategorie::with('translation')->where($where)->paginate($size, ['*'], 'page', $current);
|
||||
return Categorie::with('translation')->where($where)->paginate($size, ['*'], 'page', $current);
|
||||
}
|
||||
|
||||
public function getAll($params)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['status', '=', 1];
|
||||
return TicketCategorie::with('translation')->where($where)->get();
|
||||
return Categorie::with('translation')->where($where)->get();
|
||||
}
|
||||
|
||||
public function add(array $data)
|
||||
{
|
||||
try {
|
||||
return TicketCategorie::create($data);
|
||||
return Categorie::create($data);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('分类创建失败', [
|
||||
'data' => $data,
|
||||
@@ -39,7 +39,7 @@ class CategorieLogic
|
||||
public function edit(array $data)
|
||||
{
|
||||
try {
|
||||
$categorie = TicketCategorie::updateOrCreate(['id' => $data['id']], $data);
|
||||
$categorie = Categorie::updateOrCreate(['id' => $data['id']], $data);
|
||||
return $categorie;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('分类编辑失败', [
|
||||
@@ -53,7 +53,7 @@ class CategorieLogic
|
||||
public function delete(int $id)
|
||||
{
|
||||
try {
|
||||
$categorie = TicketCategorie::where(['id'=>$id])->delete();
|
||||
$categorie = Categorie::where(['id'=>$id])->delete();
|
||||
return $categorie;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('分类删除失败', [
|
||||
|
||||
@@ -25,7 +25,7 @@ class TicketLogic
|
||||
}
|
||||
$size = $params['size'];
|
||||
$current = $params['current'];
|
||||
return Ticket::with('attachments')->where($where)->orderBy('id','desc')->paginate($size, ['*'], 'page', $current);
|
||||
return Ticket::with('attachments')->with('categorie')->with('categorie.translation')->where($where)->orderBy('id','desc')->paginate($size, ['*'], 'page', $current);
|
||||
}
|
||||
public function add(array $data)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ use support\Model;
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at 删除时间
|
||||
*/
|
||||
class TicketCategorie extends Model
|
||||
class Categorie extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $connection = 'mysql';
|
||||
@@ -37,7 +37,7 @@ class TicketCategorie extends Model
|
||||
*/
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(TicketCategorieTranslation::class, 'categorie_id')->where('locale', locale());
|
||||
return $this->hasOne(CategorieTranslation::class, 'categorie_id')->where('locale', locale());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,6 +45,10 @@ class TicketCategorie extends Model
|
||||
*/
|
||||
public function translations()
|
||||
{
|
||||
return $this->hasMany(TicketCategorieTranslation::class, 'categorie_id');
|
||||
return $this->hasMany(CategorieTranslation::class, 'categorie_id');
|
||||
}
|
||||
|
||||
public function ticket(){
|
||||
return $this->hasOne(Ticket::class, 'categorie_id', 'id');
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ use support\Model;
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
*/
|
||||
class TicketCategorieTranslation extends Model
|
||||
class CategorieTranslation extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
protected $table = 'ticket_categorie_translation';
|
||||
@@ -70,4 +70,8 @@ class Ticket extends Model
|
||||
public function attachments(){
|
||||
return $this->hasMany(Attachment::class, 'ticket_id', 'id');
|
||||
}
|
||||
|
||||
public function categorie(){
|
||||
return $this->belongsTo(Categorie::class, 'categorie_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ class TicketService
|
||||
{
|
||||
$res = (new TicketLogic())->list($params);
|
||||
foreach ($res as $k => &$v) {
|
||||
$v['categorie']['name'] = isset($v['categorie']['translation']) ? $v['categorie']['translation']['name'] : '';
|
||||
unset($v['categorie']['translation']);
|
||||
foreach ($v['attachments'] as &$attachments) {
|
||||
$attachments['storage_path_full'] = (new \app\common\service\OssService())->generatePrivateUrl($attachments['storage_path']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user