Browse Source

Wesmiler 校企小程序源代码部署

wesmiler 4 years ago
parent
commit
b0a286c076

+ 21 - 0
app/api/common.php

@@ -27,3 +27,24 @@ function getPlatform()
     }
     return $value;
 }
+
+if (!function_exists('getPreview')) {
+    /**
+     * 图片资源预览地址
+     * @param $url 原始地址
+     * @return null|string|string[]
+     */
+    function getPreview($url){
+        if ($url) {
+            $host = request()->header('host');
+            $fileConfig = config('filesystem.disks');
+            $uploadPath = (isset($fileConfig['public']) && $fileConfig['public']['url'])? $fileConfig['public']['url']:'/uploads';
+            $url = preg_match("/^(https|http):\/\//", trim($url,'//')) ? $url : '//'.$host . $uploadPath .'/' . ltrim($url, '/');
+        }
+        $url = $url? preg_replace("/^(https|http):\/\//", '//', $url) : '';
+        if(preg_match("/127.0|localhost/", $host) && $url){
+            $url = preg_replace("/^\/\//", 'http://', $url);
+        }
+        return $url;
+    }
+}

+ 50 - 0
app/api/model/School.php

@@ -0,0 +1,50 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\api\model;
+use app\common\model\School as SchoolModel;
+
+/**
+ * 学校模型类
+ * Class School
+ * @package app\api\model
+ */
+class School extends SchoolModel
+{
+
+    protected $globalScope = [''];
+
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+        'update_time'
+    ];
+
+    /**
+     * 获取学校信息
+     * @param $where
+     * @param array $with
+     * @return static|array|false|null
+     */
+    public static function detail($where, array $with = [])
+    {
+        $filter = [];
+        if (is_array($where)) {
+            $filter = array_merge($filter, $where);
+        } else {
+            $filter['user_id'] = (int)$where;
+        }
+        return static::get($filter, $with);
+    }
+}

+ 6 - 0
app/api/model/User.php

@@ -67,6 +67,7 @@ class User extends UserModel
         // 用户基本信息
         $userInfo = self::detail($userId);
         $userInfo['info']=$userInfo['info']? $userInfo['info'] : [];
+        $userInfo['info']['school']=$userInfo['info']['school']? $userInfo['info']['school'] : [];
         if (empty($userInfo) || $userInfo['is_delete']) {
             throwError('很抱歉,用户信息不存在或已删除', config('status.not_logged'));
         }
@@ -161,6 +162,7 @@ class User extends UserModel
                     'user_id'=> $userInfo['user_id'],
                     'school_id'=> (int)$data['school_id'],
                     'position'=> isset($data['position'])? intval($data['position']) : 0,
+                    'speciality'=> isset($data['speciality'])? intval($data['speciality']) : 0,
                     'qq'=> isset($data['qq'])? $data['qq'] : '',
                     'idcard'=> isset($data['idcard'])? $data['idcard'] :'',
                     'idcard_front_img'=> isset($data['idcard_front_img'])? $data['idcard_front_img'] :'',
@@ -247,6 +249,10 @@ class User extends UserModel
                 throwError('请选择入学年份');
             }
 
+            if(empty($data['speciality'])){
+                throwError('请选择就读专业');
+            }
+
             if(empty($data['education_certify'])){
                 throwError('请上传教育证明');
             }

+ 32 - 0
app/common/model/School.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\relation\HasOne;
+
+/**
+ * 学校模型类
+ * Class School
+ * @package app\common\model
+ */
+class School extends BaseModel
+{
+    // 定义表名
+    protected $name = 'schools';
+
+    // 定义主键
+    protected $pk = 'id';
+
+
+}

+ 32 - 0
app/common/model/SourceSchool.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\relation\HasOne;
+
+/**
+ * 生源学校模型类
+ * Class SourceSchool
+ * @package app\common\model
+ */
+class SourceSchool extends BaseModel
+{
+    // 定义表名
+    protected $name = 'source_schools';
+
+    // 定义主键
+    protected $pk = 'source_school_id';
+
+
+}

+ 29 - 0
app/common/model/UserInfo.php

@@ -13,6 +13,7 @@ declare (strict_types=1);
 namespace app\common\model;
 
 use cores\BaseModel;
+use think\model\relation\HasOne;
 
 /**
  * 用户资料模型类
@@ -41,4 +42,32 @@ class UserInfo extends BaseModel
             ->where('u.is_delete', '=', 0)
             ->value('a.user_id');
     }
+
+    /**
+     * 身份证预览图
+     * @param $value
+     * @return string|string[]|null
+     */
+    public function getIdcardFrontImgAttr($value): string
+    {
+        return $value? getPreview($value) : '';
+    }
+
+    /**
+     * 招生学校
+     * @return HasOne
+     */
+    public function school(): HasOne
+    {
+        return $this->hasOne("School", 'id', 'school_id')->bind(['school_name']);
+    }
+
+    /**
+     * 生源学校
+     * @return HasOne
+     */
+    public function sourceSchool(): HasOne
+    {
+//        return $this->hasOne("SourceSchool", 'source_school_id', 'school_id');
+    }
 }