开放字段验证

This commit is contained in:
monanxiao 2023-03-23 11:09:52 +08:00
parent f09ba703ea
commit b430a4c162
5 changed files with 102 additions and 12 deletions

View File

@ -23,7 +23,9 @@ class SupplyAccount extends BaseController
* 构造函数
*/
public function __construct()
{
{
$this->adminInfo = get_login_admin();
$this->model = new SupplyAccountModel();
$this->uid = get_login_admin('id');
}
@ -37,6 +39,11 @@ class SupplyAccount extends BaseController
$where = [];
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
if($this->adminInfo['group_access'] != 1){ //不是超级管理员
$where['fa_supply_team_id'] = $this->uid;
}
$list = SupplyAccountModel::with('team')->where($where)
->paginate($rows, false, ['query' => $param]);

View File

@ -24,6 +24,7 @@ class SupplyBrokerage extends BaseController
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->model = new SupplyBrokerageModel();
$this->uid = get_login_admin('id');
}
@ -36,8 +37,35 @@ class SupplyBrokerage extends BaseController
$param = get_params();
$where = [];
$list = $this->model->with(['merchant', 'supplyChain', 'level'])->order('id desc')->select(); // 只读取来源为供应链小组的订单
if($this->adminInfo['group_access'] != 1){ // 不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')
->where($www)
->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where['village'] = $user_address['village_id'];
}elseif ($user_address['auth_range'] == 2){
$where['township'] = $user_address['street_id'];
}elseif ($user_address['auth_range'] == 3){
$where['county'] = $user_address['area_id'];
}else{
$where['village'] = $user_address['village_id'];
}
}else{
$where['village'] = '';
}
}
$list = $this->model->with(['merchant', 'supplyChain', 'level'])
->order('id desc')
->select(); // 只读取来源为供应链小组的订单
$total = $this->model->count();
foreach ($list as $k =>$v){
// $list[$k]['fa_supply_chain_id'] = Db::table('fa_supply_team')->where('id',$v['fa_supply_chain_id'])->value('name');

View File

@ -1483,11 +1483,11 @@ class Maintainentry extends BaseController
public function userEntry()
{
$post = get_params();
// try {
// validate('Maintainentry.myadd')->check($post);
// } catch (\Exception $e) {
// $this->apiError($e->getMessage());
// }
try {
validate('Maintainentry.myadd')->check($post);
} catch (\Exception $e) {
$this->apiError($e->getMessage());
}
if ($post) {
//// 验证验证码

View File

@ -95,11 +95,17 @@ class Userinfo extends BaseController
public function Binding()
{
$post = get_params();
if(!$post['idcard'] || !$post['area_id'] || !$post['street_id'] || !$post['village_id'] || !$post['name']){
$this->apiError('缺少参数');
}
if($post['phone'] == 'undefined'){
$this->apiError('手机号错误');
// if(!$post['idcard'] || !$post['area_id'] || !$post['street_id'] || !$post['village_id'] || !$post['name']){
// $this->apiError('缺少参数');
// }
// if($post['phone'] == 'undefined'){
// $this->apiError('手机号错误');
// }
try {
validate('UserInfo.myadd')->check($post);
} catch (\Exception $e) {
$this->apiError($e->getMessage());
}
// $where['id'] = $this->request->uid; // 废弃

View File

@ -0,0 +1,49 @@
<?php
namespace app\api\validate;
use think\Validate;
class UserInfo extends Validate
{
/**
* 验证规则.
*/
protected $rule = [
'name' => 'require',
'idcard' => 'require|idCard',
'area_id' => 'require',
'street_id' => 'require',
'village_id' => 'require',
];
/**
* 提示消息.
*/
protected $message = [
'name' => '请输入姓名',
'idcard' => '请输入身份证号',
'idcard.idCard' => '身份证号不正确',
'area_id' => '请选择村组信息',
'street_id' => '请选择村组信息',
'village_id' => '请选择村组信息',
];
/**
* 字段描述.
*/
protected $field = [
];
/**
* 验证场景.
*/
protected $scene = [
'add' => ['name', 'area_id', 'idcard', 'street_id', 'village_id'],
];
public function __construct()
{
parent::__construct();
}
}