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
9687d606
Commit
9687d606
authored
Jul 28, 2023
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
71715610
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
35 deletions
+85
-35
server/app/Http/Controllers/V1/Chemsite/CustomerController.php
...r/app/Http/Controllers/V1/Chemsite/CustomerController.php
+44
-0
server/app/Repositories/Eloquent/BaseRepository.php
server/app/Repositories/Eloquent/BaseRepository.php
+9
-0
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
.../Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
+2
-6
server/app/Rhawn/Services/Chemsite/ChemsiteCustomerService.php
...r/app/Rhawn/Services/Chemsite/ChemsiteCustomerService.php
+2
-18
server/app/Services/Api/Chemsite/ChemsiteCustomerService.php
server/app/Services/Api/Chemsite/ChemsiteCustomerService.php
+23
-0
server/routes/api/rhawn.php
server/routes/api/rhawn.php
+5
-11
No files found.
server/app/Http/Controllers/V1/Chemsite/CustomerController.php
0 → 100644
View file @
9687d606
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Http\Controllers\V1\Chemsite
;
use
App\Services\Api\Chemsite\ChemsiteCustomerService
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
App\Http\Controllers\V1\Controller
;
use
App\Support\Traits\Helpers
;
class
CustomerController
extends
Controller
{
use
Helpers
;
public
function
__construct
(
ChemsiteCustomerService
$chemsiteCustomerService
)
{
$this
->
chemsiteCustomerService
=
$chemsiteCustomerService
;
$this
->
controllerType
=
'chemsite'
;
}
public
function
getCustomer
(
Request
$request
)
{
$customerCode
=
$request
->
get
(
'customer_code'
);
if
(
!
$customerCode
){
return
Response
::
ok
(
'客户编号不存在!'
);
}
try
{
$customer
=
$this
->
chemsiteCustomerService
->
getCustomerByNumber
(
$customerCode
);
return
Response
::
success
(
$this
->
formatKeysfromArray
(
$customer
),
'操作成功'
);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
'获取订单列表失败'
);
}
}
}
server/app/Repositories/Eloquent/BaseRepository.php
View file @
9687d606
...
...
@@ -14,6 +14,7 @@ namespace App\Repositories\Eloquent;
use
App\Repositories\Presenters\Presenter
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Pagination\LengthAwarePaginator
;
use
Illuminate\Support\Arr
;
use
Prettus\Repository\Eloquent\BaseRepository
as
BaseRepositoryEloquent
;
abstract
class
BaseRepository
extends
BaseRepositoryEloquent
...
...
@@ -82,6 +83,14 @@ abstract class BaseRepository extends BaseRepositoryEloquent
return
$returnRecord
;
}
public
function
transformData
(
$datas
,
$modelName
=
null
)
{
if
(
is_null
(
$modelName
)){
return
Arr
::
pluck
(
$datas
,
null
);
}
return
app
(
$modelName
)
->
transform
(
Arr
::
pluck
(
$datas
,
null
));
}
protected
function
getConnectionName
()
{
return
app
(
$this
->
model
())
->
getConnectionName
();
...
...
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
View file @
9687d606
...
...
@@ -23,13 +23,9 @@ class ChemsiteCustomerRepositoryEloquent extends BaseRepository implements Chems
return
ChemsiteCustomer
::
class
;
}
public
function
get
RhawnCustomerThrought
CusCode
(
$cusCode
)
public
function
get
CustomerThrough
CusCode
(
$cusCode
)
{
$customer
=
$this
->
findWhere
([
'cus_no'
=>
$cusCode
])
->
first
();
if
(
$customer
){
return
$customer
->
toArray
();
}
return
null
;
return
$this
->
findWhere
([
'cus_no'
=>
$cusCode
])
->
first
();
}
public
function
getCustomerList
(
$where
,
$offset
,
$limit
)
...
...
server/app/Rhawn/Services/Chemsite/ChemsiteCustomerService.php
View file @
9687d606
...
...
@@ -16,28 +16,12 @@ class ChemsiteCustomerService
public
function
getCustomerThroughCusCode
(
$cusCode
)
{
return
$this
->
customerRepository
->
getRhawnCustomerThroughtCusCode
(
$cusCode
);
$customer
=
$this
->
customerRepository
->
getCustomerThroughCusCode
(
$cusCode
);
return
$customer
->
toArray
();
}
public
function
getCustomerListByCusCode
(
$cusNo
,
$offset
,
$limit
)
:
?
array
{
return
$this
->
customerRepository
->
getCustomerList
([
'cus_no'
=>
$cusNo
],
$offset
,
$limit
);
}
/**
* 检查客户信息是否存在
* @param $cusCode
* @return mixed
* @throws ServerRunTimeException
*/
public
function
checkCustomerExist
(
$cusCode
)
{
//查询用户是否存在
$customer
=
$this
->
customerRepository
->
getRhawnCustomerThroughtCusCode
(
$cusCode
);
if
(
!
$customer
){
throw
new
ServerRunTimeException
(
'客户编号为:['
.
$cusCode
.
']的用户不存在!'
);
}
return
$customer
;
}
}
server/app/Services/Api/Chemsite/ChemsiteCustomerService.php
0 → 100644
View file @
9687d606
<?php
namespace
App\Services\Api\Chemsite
;
use
App\Repositories\Eloquent\BaseRepository
;
class
ChemsiteCustomerService
{
private
$chemsiteCustomerService
;
public
function
__construct
(
\App\Rhawn\Services\Chemsite\ChemsiteCustomerService
$chemsiteCustomerService
)
{
$this
->
chemsiteCustomerService
=
$chemsiteCustomerService
;
}
public
function
getCustomerByNumber
(
$customerNumber
)
{
$customer
=
$this
->
chemsiteCustomerService
->
getCustomerThroughCusCode
(
$customerNumber
);
return
app
(
BaseRepository
::
class
)
->
transformData
(
$customer
);
}
}
server/routes/api/rhawn.php
View file @
9687d606
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$api
->
version
(
'v1'
,
function
(
$api
)
{
//获取token
...
...
@@ -59,5 +48,10 @@ $api->version('v1', function($api) {
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Bhua'
,
'middleware'
=>
[
'throttle:60,1'
,
'apiAuth'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
$api
->
post
(
'/openapi/bhua/invoice/getInvoiceSorderItems'
,
[
'permission'
=>
'orders.getInvoiceSorderItems'
,
'uses'
=>
'InvoiceController@getInvoiceSorderItems'
]);
});
// chemsite接口
$api
->
group
(
namespace
'=>'
App\Http\Controllers\V1\Chemsite
','
middleware
' => ['
throttle
:
60
,
1
','
apiAuth
'], '
providers
' => '
jwt
'], function($api) {
$api->post('
/
openapi
/
chemsite
/
orders
/
getCustomer
', ['
permission
' => '
chemsite
.
customer
.
search
', '
uses
'=>'
CustomerController
@
getCustomer
'
]);
});
});
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