Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
2f5b6b2f
Commit
2f5b6b2f
authored
Jun 12, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交
parent
848cbaad
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
645 additions
and
3 deletions
+645
-3
server/app/Http/Controllers/V1/Chemicals/MsdsController.php
server/app/Http/Controllers/V1/Chemicals/MsdsController.php
+5
-3
server/app/Repositories/Contracts/FileManageRepository.php
server/app/Repositories/Contracts/FileManageRepository.php
+9
-0
server/app/Repositories/Criteria/BaseCriteria.php
server/app/Repositories/Criteria/BaseCriteria.php
+48
-0
server/app/Repositories/Eloquent/FileManageRepositoryEloquent.php
...pp/Repositories/Eloquent/FileManageRepositoryEloquent.php
+61
-0
server/app/Repositories/Models/FileManage.php
server/app/Repositories/Models/FileManage.php
+49
-0
server/app/Services/Api/ChemicalsMsdsService.php
server/app/Services/Api/ChemicalsMsdsService.php
+33
-0
server/app/Services/FileService.php
server/app/Services/FileService.php
+333
-0
server/app/Services/Traits/BaseService.php
server/app/Services/Traits/BaseService.php
+66
-0
server/database/migrations/2025_06_12_144833_create_file_manage_table.php
...migrations/2025_06_12_144833_create_file_manage_table.php
+41
-0
No files found.
server/app/Http/Controllers/V1/Chemicals/MsdsController.php
View file @
2f5b6b2f
...
...
@@ -11,6 +11,7 @@
namespace
App\Http\Controllers\V1\Chemicals
;
use
App\Services\Api\ChemicalsMsdsService
;
use
App\Services\Api\RhawnOrdersService
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
...
...
@@ -30,15 +31,16 @@ class MsdsController extends Controller
{
use
Helpers
;
public
function
__construct
(
RhawnOrdersService
$rhawnOrder
sService
)
public
function
__construct
(
ChemicalsMsdsService
$chemicalsMsd
sService
)
{
$this
->
rhawnOrdersService
=
$rhawnOrdersService
;
$this
->
controllerType
=
'rhawn'
;
$this
->
chemicalsMsdsService
=
$chemicalsMsdsService
;
}
public
function
getMsds
(
Request
$request
)
{
$this
->
chemicalsMsdsService
->
getMsds
(
'270912-72-6'
);
$customerCode
=
$request
->
get
(
'customer_code'
);
$companyCode
=
$request
->
get
(
'company_code'
);
...
...
server/app/Repositories/Contracts/FileManageRepository.php
0 → 100644
View file @
2f5b6b2f
<?php
namespace
App\Repositories\Contracts
;
use
Prettus\Repository\Contracts\RepositoryInterface
;
interface
FileManageRepository
extends
RepositoryInterface
{
}
server/app/Repositories/Criteria/BaseCriteria.php
0 → 100644
View file @
2f5b6b2f
<?php
namespace
App\Repositories\Criteria
;
use
Illuminate\Database\Eloquent\Builder
;
use
App\Repositories\Criteria\Criteria
;
class
BaseCriteria
extends
Criteria
{
protected
function
condition
(
Builder
$query
)
:
void
{
if
(
$this
->
request
->
has
(
'created_at'
))
{
$createdAt
=
$this
->
request
->
offsetGet
(
'created_at'
);
if
(
!
empty
(
$createdAt
)){
list
(
$start
,
$end
)
=
explode
(
','
,
$createdAt
);
if
(
!
preg_match
(
'/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i'
,
$start
)){
$start
=
$start
.
' 00:00:00'
;
}
if
(
!
preg_match
(
'/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i'
,
$end
)){
$end
=
$end
.
' 23:59:59'
;
}
if
(
!
empty
(
$start
)
&&
!
empty
(
$end
)){
$query
->
whereRaw
(
'created_at >= "'
.
$start
.
'" and created_at < "'
.
$end
.
'"'
);
}
}
}
if
(
$this
->
request
->
has
(
'createdAt'
))
{
$createdAt
=
$this
->
request
->
offsetGet
(
'createdAt'
);
if
(
!
empty
(
$createdAt
)){
list
(
$start
,
$end
)
=
explode
(
','
,
$createdAt
);
if
(
!
preg_match
(
'/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i'
,
$start
)){
$start
=
$start
.
' 00:00:00'
;
}
if
(
!
preg_match
(
'/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i'
,
$end
)){
$end
=
$end
.
' 23:59:59'
;
}
if
(
!
empty
(
$start
)
&&
!
empty
(
$end
)){
$query
->
whereRaw
(
'created_at >= "'
.
$start
.
'" and created_at < "'
.
$end
.
'"'
);
}
}
}
}
}
server/app/Repositories/Eloquent/FileManageRepositoryEloquent.php
0 → 100644
View file @
2f5b6b2f
<?php
namespace
App\Repositories\Eloquent
;
use
App\Repositories\Contracts\FileManageRepository
;
use
App\Repositories\Models\FileManage
;
use
Prettus\Validator\Contracts\ValidatorInterface
;
use
App\Repositories\BaseRepository
;
class
FileManageRepositoryEloquent
extends
BaseRepository
implements
FileManageRepository
{
/**
* 定义validator的检索规则
* @var \string[][]
*/
public
$rules
=
[
ValidatorInterface
::
RULE_CREATE
=>
[
'uniqueid'
=>
'required|string'
,
'name'
=>
'required|string'
,
'type'
=>
'required|string'
,
'extension'
=>
'required|string'
,
'path'
=>
'required|string'
,
'mime_type'
=>
'required|string'
,
'byte_size'
=>
'required'
,
],
];
/**
* Specify Model class name.
*
* @return string
*/
public
function
model
()
{
return
FileManage
::
class
;
}
public
function
saveUplodFiles
(
$fileImage
)
{
$saveParams
=
$fileImage
;
if
(
$file
=
$this
->
getFileByUniqueId
(
$saveParams
[
'uniqueid'
])){
$saveParams
[
'updated_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$file
=
$file
->
update
(
$saveParams
);
}
else
{
$saveParams
[
'type'
]
=
(
isset
(
$saveParams
[
'type'
])
&&
!
empty
(
$saveParams
[
'type'
]))
?
$saveParams
[
'type'
]
:
'image'
;
$saveParams
[
'created_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$file
=
$this
->
create
(
$saveParams
);
}
return
$file
;
}
public
function
getFileByUniqueId
(
$id
)
{
$file
=
$this
->
findWhere
([
'uniqueid'
=>
$id
]);
return
$file
->
first
();
}
}
server/app/Repositories/Models/FileManage.php
0 → 100644
View file @
2f5b6b2f
<?php
/**
* Created by Reliese Model.
*/
namespace
App\Repositories\Models
;
use
Carbon\Carbon
;
/**
* Class FileManage
*
* @property int $id
* @property string $uniqueid
* @property string $name
* @property string $extension
* @property string $type
* @property string $path
* @property string $mime_type
* @property int $byte_size
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string $model_name
* @property string $model_data_id
*
* @package App\Repositories\Models
*/
class
FileManage
extends
Model
{
protected
$table
=
'file_manage'
;
protected
$casts
=
[
'byte_size'
=>
'int'
];
protected
$fillable
=
[
'uniqueid'
,
'name'
,
'extension'
,
'type'
,
'path'
,
'mime_type'
,
'byte_size'
,
'model_name'
,
'model_data_id'
,
'created_by'
];
}
server/app/Services/Api/ChemicalsMsdsService.php
0 → 100644
View file @
2f5b6b2f
<?php
namespace
App\Services\Api
;
use
App\Services\FileService
;
use
Illuminate\Support\Facades\Storage
;
class
ChemicalsMsdsService
{
public
function
__construct
()
{
}
public
function
getMsds
(
$cas
)
{
$findResult
=
shell_exec
(
'find '
.
env
(
'MSDS_FILE_DIR'
)
.
' -iname \''
.
$cas
.
'\' -print'
);
if
(
is_null
(
$findResult
)){
return
null
;
}
$msds_html
=
file_get_contents
(
env
(
'MSDS_FILE_DIR'
)
.
'/'
.
$cas
.
'/'
.
$cas
.
'_sds_cn.html'
);
dd
(
$msds_html
);
dd
(
Storage
::
exists
(
env
(
'MSDS_FILE_DIR'
)));
if
(
Storage
::
exists
(
env
(
'MSDS_FILE_DIR'
)
.
'/'
.
$cas
)){
dd
(
123
);
}
$fileService
=
app
(
FileService
::
class
);
dd
(
$fileService
->
getFileFolderPath
());
}
}
server/app/Services/FileService.php
0 → 100644
View file @
2f5b6b2f
This diff is collapsed.
Click to expand it.
server/app/Services/Traits/BaseService.php
0 → 100644
View file @
2f5b6b2f
<?php
namespace
App\Services\Traits
;
use
App\Exceptions\ServerRunTimeException
;
use
App\Repositories\Criteria\BaseCriteria
;
use
App\Services\AuthService
as
adminAuth
;
use
App\Services\Traits\DataEntriesService
;
use
App\Services\YyBao\Auth\AuthService
as
frontAuth
;
use
App\Services\YyBao\CustomersService
;
use
App\Services\YyBao\ImportExportTasksService
;
use
Illuminate\Support\Facades\DB
;
trait
BaseService
{
protected
$repository
;
protected
$guard
;
public
function
setRepository
(
$repository
)
{
$this
->
repository
=
$repository
;
}
public
function
getRepository
()
{
return
$this
->
repository
;
}
public
function
setGuard
(
$guardName
)
{
$this
->
guard
=
$guardName
;
}
public
function
getGuard
()
{
return
$this
->
guard
;
}
public
function
moneyFromat
(
$money
,
$fromat
=
true
)
{
$money
=
bcdiv
(
$money
,
100
,
2
);
if
(
$fromat
){
return
is_numeric
(
$money
)
?
sprintf
(
"%.2f"
,
substr
(
sprintf
(
"%.3f"
,
$money
),
0
,
-
1
))
:
''
;
}
return
$money
;
}
public
function
getList
(
$requestParams
,
BaseCriteria
$pushCriteria
)
{
$this
->
getRepository
()
->
pushCriteria
(
$pushCriteria
);
if
(
empty
(
$requestParams
[
'page_size'
])
||
$requestParams
[
'page_size'
]
==
0
){
$requestParams
[
'page_size'
]
=
10
;
}
return
$this
->
getRepository
()
->
listPageByPaginate
(
$requestParams
[
'page_size'
]);
}
public
function
collectionToArray
(
$collection
,
$model
=
null
)
{
return
$this
->
getRepository
()
->
transformData
(
collect
(
$collection
)
->
map
(
function
(
$collect
){
return
!
is_array
(
$collect
)
?
$collect
->
toArray
()
:
$collect
;
}),
$model
);
}
}
server/database/migrations/2025_06_12_144833_create_file_manage_table.php
0 → 100644
View file @
2f5b6b2f
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateFileManageTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'file_manage'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
longText
(
'uniqueid'
)
->
comment
(
'uniqueid'
)
->
nullable
(
false
);
$table
->
string
(
'name'
)
->
comment
(
'文件名称'
)
->
nullable
(
false
);
$table
->
string
(
'extension'
)
->
comment
(
'扩展名'
)
->
nullable
(
false
);
$table
->
string
(
'type'
)
->
comment
(
'图片类型'
)
->
nullable
(
false
)
->
default
(
'image'
);
$table
->
text
(
'path'
)
->
nullable
(
false
)
->
comment
(
'保存路径'
);
$table
->
string
(
'mime_type'
)
->
nullable
(
false
)
->
comment
(
'mime类型'
);
$table
->
integer
(
'byte_size'
)
->
nullable
(
false
)
->
comment
(
'文件大小'
);
$table
->
string
(
'model_name'
)
->
nullable
()
->
comment
(
'模型名称'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'file_manage'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment