大宗物资增加单位

dev
Jing Li 2022-11-16 15:02:12 +08:00
parent 04ee26c92c
commit 94aa0656ed
6 changed files with 11 additions and 2 deletions

View File

@ -2,15 +2,15 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Enums\OperationType;
use App\Http\Requestes\MaterielStoreRequest; use App\Http\Requestes\MaterielStoreRequest;
use App\Http\Requestes\MaterielUpdateRequest; use App\Http\Requestes\MaterielUpdateRequest;
use App\Http\Resources\MaterielResource; use App\Http\Resources\MaterielResource;
use App\Models\Materiel; use App\Models\Materiel;
use App\Services\OperationLogService;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Http\Resources\Json\ResourceCollection;
use App\Services\OperationLogService;
use App\Enums\OperationType;
class MaterielController extends Controller class MaterielController extends Controller
{ {
@ -50,6 +50,7 @@ class MaterielController extends Controller
'quarter', 'quarter',
'lowest_price', 'lowest_price',
'highest_price', 'highest_price',
'unit',
]) ])
); );
$materiel->created_by = $user->id; $materiel->created_by = $user->id;
@ -84,6 +85,7 @@ class MaterielController extends Controller
'quarter', 'quarter',
'lowest_price', 'lowest_price',
'highest_price', 'highest_price',
'unit',
] as $key) { ] as $key) {
if ($request->filled($key)) { if ($request->filled($key)) {
$materiel->{$key} = $request->input($key); $materiel->{$key} = $request->input($key);

View File

@ -23,6 +23,7 @@ class MaterielStoreRequest extends FormRequest
'type' => ['required', new Enum(MaterielType::class)], 'type' => ['required', new Enum(MaterielType::class)],
'lowest_price' => ['required', 'int'], 'lowest_price' => ['required', 'int'],
'highest_price' => ['required', 'int', 'gte:lowest_price'], 'highest_price' => ['required', 'int', 'gte:lowest_price'],
'unit' => ['required', 'string'],
]; ];
} }
@ -35,6 +36,7 @@ class MaterielStoreRequest extends FormRequest
'type' => '类型', 'type' => '类型',
'lowest_price' => '最低价', 'lowest_price' => '最低价',
'highest_price' => '最高价', 'highest_price' => '最高价',
'unit' => '单位',
]; ];
} }
} }

View File

@ -23,6 +23,7 @@ class MaterielUpdateRequest extends FormRequest
'type' => ['filled', new Enum(MaterielType::class)], 'type' => ['filled', new Enum(MaterielType::class)],
'lowest_price' => ['filled', 'int'], 'lowest_price' => ['filled', 'int'],
'highest_price' => ['filled', 'int', 'gte:lowest_price'], 'highest_price' => ['filled', 'int', 'gte:lowest_price'],
'unit' => ['filled', 'string'],
]; ];
} }
@ -35,6 +36,7 @@ class MaterielUpdateRequest extends FormRequest
'type' => '类型', 'type' => '类型',
'lowest_price' => '最低价', 'lowest_price' => '最低价',
'highest_price' => '最高价', 'highest_price' => '最高价',
'unit' => '单位',
]; ];
} }
} }

View File

@ -22,6 +22,7 @@ class MaterielResource extends JsonResource
'quarter' => $this->quarter, 'quarter' => $this->quarter,
'lowest_price' => $this->lowest_price, 'lowest_price' => $this->lowest_price,
'highest_price' => $this->highest_price, 'highest_price' => $this->highest_price,
'unit' => $this->unit,
'created_by' => AdminUserResource::make($this->whenLoaded('createdBy')), 'created_by' => AdminUserResource::make($this->whenLoaded('createdBy')),
'updated_by' => AdminUserResource::make($this->whenLoaded('updatedBy')), 'updated_by' => AdminUserResource::make($this->whenLoaded('updatedBy')),
'created_at' => $this->created_at->unix(), 'created_at' => $this->created_at->unix(),

View File

@ -22,6 +22,7 @@ class Materiel extends Model
'quarter', 'quarter',
'lowest_price', 'lowest_price',
'highest_price', 'highest_price',
'unit',
'created_by', 'created_by',
'updated_by', 'updated_by',
]; ];

View File

@ -21,6 +21,7 @@ return new class extends Migration
$table->tinyInteger('quarter')->comment('季度'); $table->tinyInteger('quarter')->comment('季度');
$table->unsignedBigInteger('lowest_price')->comment('最低价格'); $table->unsignedBigInteger('lowest_price')->comment('最低价格');
$table->unsignedBigInteger('highest_price')->comment('最低价格'); $table->unsignedBigInteger('highest_price')->comment('最低价格');
$table->string('unit')->comment('单位');
$table->unsignedBigInteger('created_by')->comment('创建人ID'); $table->unsignedBigInteger('created_by')->comment('创建人ID');
$table->unsignedBigInteger('updated_by')->comment('修改人ID'); $table->unsignedBigInteger('updated_by')->comment('修改人ID');
$table->timestamps(); $table->timestamps();