Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7084aa32
authored
May 12, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
云芯采购员
parent
96c5013b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
1 deletions
app/Http/Controllers/Api/SupplierAccountApiController.php
app/Http/Validators/SupplierAccountValidator.php
resources/views/web/SupplierAccountList.blade.php
app/Http/Controllers/Api/SupplierAccountApiController.php
View file @
7084aa32
...
...
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use
App\Http\Controllers\Filter\SupplierAccountFilter
;
use
App\Http\Services\SupplierAccountService
;
use
App\Http\Transformers\SupplierLogTransformer
;
use
App\Http\Validators\SupplierAccountValidator
;
use
App\Model\LogModel
;
use
App\Model\SupplierAccountModel
;
use
App\Model\SupplierChannelModel
;
...
...
@@ -38,6 +39,11 @@ class SupplierAccountApiController extends Controller
'password_raw'
,
'a_type'
,
]);
$validator
=
new
SupplierAccountValidator
();
$check
=
$validator
->
checkSave
(
$request
);
if
(
$check
!==
true
)
{
$this
->
response
(
-
1
,
$check
);
}
$supplierModel
=
new
SupplierChannelModel
();
$supplierId
=
$supplierModel
->
where
(
'supplier_code'
,
$data
[
'supplier_code'
])
->
value
(
'supplier_id'
);
$data
[
'supplier_id'
]
=
$supplierId
;
...
...
@@ -63,6 +69,11 @@ class SupplierAccountApiController extends Controller
'password_raw'
,
'a_type'
,
]);
$validator
=
new
SupplierAccountValidator
();
$check
=
$validator
->
checkSave
(
$request
);
if
(
!
$check
)
{
$this
->
response
(
-
1
,
$check
);
}
$supplierModel
=
new
SupplierChannelModel
();
$supplierId
=
$supplierModel
->
where
(
'supplier_code'
,
$data
[
'supplier_code'
])
->
value
(
'supplier_id'
);
$data
[
'supplier_id'
]
=
$supplierId
;
...
...
app/Http/Validators/SupplierAccountValidator.php
0 → 100644
View file @
7084aa32
<?php
namespace
App\Http\Validators
;
use
App\Model\SupplierAccountModel
;
use
App\Model\SupplierChannelModel
;
use
Validator
;
class
SupplierAccountValidator
{
//保存相关的验证,别问我为什么不用laravel自带的form-request类
//因为控制器那边已经被之前的人魔改的难用的一比,而且控制器那边还接收了一大堆统一变量
public
function
checkSave
(
$request
)
{
//整理下请求数据
$receipt
=
$request
->
all
();
$rules
=
[
"supplier_code"
=>
"required"
,
"mobile"
=>
"required|regex:/^1[0-9][0-9]
{
9
}
$/"
,
"password_raw"
=>
"required"
,
];
$messages
=
$this
->
messages
();
$validator
=
Validator
::
make
(
$receipt
,
$rules
,
$messages
);
//判断联系方式的表单验证
if
(
$validator
->
fails
())
{
return
$validator
->
errors
()
->
first
();
}
if
(
empty
(
$receipt
[
'id'
]))
{
$model
=
new
SupplierAccountModel
();
$count
=
$model
->
where
(
'supplier_code'
,
$receipt
[
'supplier_code'
])
->
where
(
'mobile'
,
$receipt
[
'mobile'
])
->
count
();
if
(
$count
>
0
)
{
return
'该供应商以及对应的账号已经存在,请更换手机号'
;
}
}
return
true
;
}
private
function
messages
()
{
return
[
'supplier_code.required'
=>
'请选择一个供应商'
,
'mobile.required'
=>
'登陆账号不能为空'
,
'mobile.regex'
=>
'账号格式必须为手机号'
,
'password_raw.required'
=>
'账号密码不能为空'
,
];
}
}
\ No newline at end of file
resources/views/web/SupplierAccountList.blade.php
View file @
7084aa32
...
...
@@ -50,7 +50,7 @@
<div
class=
"layui-btn-group demoTable"
style=
"margin-top: 15px"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"add_supplier_account"
>
新增账号
</button>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"update_supplier_account"
>
修改
</button>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"
forbid
_supplier_account"
>
禁用
</button>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"
disable
_supplier_account"
>
禁用
</button>
</div>
<table
class=
"layui-table"
id=
"supplierAccountList"
lay-filter=
"supplierAccountList"
></table>
...
...
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