feat: 移除了UserLogic中的冗余代码,并将相关逻辑移至UserShipLogic中,以提高代码可读性和可维护性。同时,增加了判断是否有村长或对长的API接口。
This commit is contained in:
parent
bb44d88dd1
commit
ebde5684c0
@ -78,24 +78,6 @@ class UserLogic extends BaseLogic
|
||||
|
||||
public static function StoreAdd(array $params)
|
||||
{
|
||||
$user_ship=$params['user_ship']??0;
|
||||
if($user_ship==2){
|
||||
$arr=User::where('user_ship',$user_ship)->column('id');
|
||||
if($arr){
|
||||
$find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find();
|
||||
if($find){
|
||||
self::setError('该区域又有村长请重新选择');
|
||||
}
|
||||
}
|
||||
}elseif($user_ship==3){
|
||||
$arr=User::where('user_ship',$user_ship)->column('id');
|
||||
if($arr){
|
||||
$find=UserAddress::where('uid','in',$arr)->where('brigade',$params['brigade'])->find();
|
||||
if($find){
|
||||
self::setError('该区域已有对长请重新选择');
|
||||
}
|
||||
}
|
||||
}
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password(123456, $passwordSalt);
|
||||
$defaultAvatar = config('project.default_image.admin_avatar');
|
||||
|
@ -5,6 +5,8 @@ namespace app\admin\logic\user_ship;
|
||||
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -95,4 +97,30 @@ class UserShipLogic extends BaseLogic
|
||||
{
|
||||
return UserShip::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有村长或者对长
|
||||
* @param $params array 参数数组
|
||||
*/
|
||||
public static function user_ship($params){
|
||||
$user_ship=$params['user_ship']??0;
|
||||
if($user_ship==2){
|
||||
$arr=User::where('user_ship',$user_ship)->column('id');
|
||||
if($arr){
|
||||
$find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find();
|
||||
if($find){
|
||||
self::setError('该区域又有村长请重新选择');
|
||||
}
|
||||
}
|
||||
}elseif($user_ship==3){
|
||||
$arr=User::where('user_ship',$user_ship)->column('id');
|
||||
if($arr){
|
||||
$find=UserAddress::where('uid','in',$arr)->where('brigade',$params['brigade'])->find();
|
||||
if($find){
|
||||
self::setError('该区域已有对长请重新选择');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace app\api\controller\user_ship;
|
||||
|
||||
|
||||
use app\admin\logic\user_ship\UserShipLogic;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\common\lists\user\UserShipLists;
|
||||
|
||||
@ -28,4 +28,13 @@ class UserShipController extends BaseApiController
|
||||
}
|
||||
|
||||
|
||||
public function is_user_ship(){
|
||||
$data=$this->request->post();
|
||||
UserShipLogic::user_ship($data);
|
||||
if(UserShipLogic::hasError()){
|
||||
return $this->fail(UserShipLogic::getError());
|
||||
}else{
|
||||
return $this->success('ok');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user