Bläddra i källkod

增加师傅表注册接口

林海涛 1 år sedan
förälder
incheckning
a0be2ccbcb

+ 108 - 0
app/adminapi/controller/master_worker_register/MasterWorkerRegisterController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\master_worker_register;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\master_worker_register\MasterWorkerRegisterLists;
+use app\adminapi\logic\master_worker_register\MasterWorkerRegisterLogic;
+use app\adminapi\validate\master_worker_register\MasterWorkerRegisterValidate;
+
+
+/**
+ * MasterWorkerRegister控制器
+ * Class MasterWorkerRegisterController
+ * @package app\adminapi\controller\master_worker_register
+ */
+class MasterWorkerRegisterController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerRegisterLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerRegisterValidate())->post()->goCheck('add');
+        $result = MasterWorkerRegisterLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRegisterLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerRegisterValidate())->post()->goCheck('edit');
+        $result = MasterWorkerRegisterLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRegisterLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerRegisterValidate())->post()->goCheck('delete');
+        MasterWorkerRegisterLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerRegisterValidate())->goCheck('detail');
+        $result = MasterWorkerRegisterLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 79 - 0
app/adminapi/lists/master_worker_register/MasterWorkerRegisterLists.php

@@ -0,0 +1,79 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\master_worker_register;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerRegister列表
+ * Class MasterWorkerRegisterLists
+ * @package app\adminapi\listsmaster_worker_register
+ */
+class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['maintain_exp_type', 'other_exp_type', 'city', 'vehicle_type', 'status'],
+            '%like%' => ['name', 'mobile'],
+            'between' => ['age'],

+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function lists(): array
+    {
+        return MasterWorkerRegister::where($this->searchWhere)
+            ->field(['id', 'maintain_exp_type', 'other_exp_type', 'city', 'vehicle_type', 'name', 'age', 'mobile', 'status'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function count(): int
+    {
+        return MasterWorkerRegister::where($this->searchWhere)->count();
+    }
+
+}

+ 120 - 0
app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php

@@ -0,0 +1,120 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\master_worker_register;
+
+
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerRegister逻辑
+ * Class MasterWorkerRegisterLogic
+ * @package app\adminapi\logic\master_worker_register
+ */
+class MasterWorkerRegisterLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRegister::create([
+                'maintain_exp_type' => $params['maintain_exp_type'],
+                'other_exp_type' => $params['other_exp_type'],
+                'city' => $params['city'],
+                'vehicle_type' => $params['vehicle_type'],
+                'name' => $params['name'],
+                'age' => $params['age'],
+                'mobile' => $params['mobile'],
+                'status' => $params['status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRegister::where('id', $params['id'])->update([
+                'maintain_exp_type' => $params['maintain_exp_type'],
+                'other_exp_type' => $params['other_exp_type'],
+                'city' => $params['city'],
+                'vehicle_type' => $params['vehicle_type'],
+                'name' => $params['name'],
+                'age' => $params['age'],
+                'mobile' => $params['mobile'],
+                'status' => $params['status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerRegister::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerRegister::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 106 - 0
app/adminapi/validate/master_worker_register/MasterWorkerRegisterValidate.php

@@ -0,0 +1,106 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\master_worker_register;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerRegister验证器
+ * Class MasterWorkerRegisterValidate
+ * @package app\adminapi\validate\master_worker_register
+ */
+class MasterWorkerRegisterValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'maintain_exp_type' => 'require',
+        'other_exp_type' => 'require',
+        'city' => 'require',
+        'vehicle_type' => 'require',
+        'name' => 'require',
+        'mobile' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'maintain_exp_type' => '维修经验',
+        'other_exp_type' => '其他经验',
+        'city' => '城市',
+        'vehicle_type' => '交通工具',
+        'name' => '姓名',
+        'mobile' => '电话',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['maintain_exp_type','other_exp_type','city','vehicle_type','name','mobile']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','maintain_exp_type','other_exp_type','city','vehicle_type','name','mobile']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 2 - 0
app/api/logic/GoodsLogic.php

@@ -28,6 +28,8 @@ class GoodsLogic extends BaseLogic
     public static function getHotData()
     {
         return Goods::where('is_hot', '=', 1)
+            ->with('goodsCategory')
+            ->visible(['id','goods_name','goods_category_id','goods_image','goods_video','goodsCategory'])
             ->order(['top_weight' => 'desc', 'id' => 'desc'])
             ->select()->toArray();
     }

+ 7 - 0
app/common/enum/notice/NoticeEnum.php

@@ -36,6 +36,7 @@ class NoticeEnum
     const BIND_MOBILE_CAPTCHA = 102;
     const CHANGE_MOBILE_CAPTCHA = 103;
     const FIND_LOGIN_PASSWORD_CAPTCHA = 104;
+    const OTHER_CAPTCHA = 105;
 
 
     /**
@@ -46,6 +47,7 @@ class NoticeEnum
         self::BIND_MOBILE_CAPTCHA,
         self::CHANGE_MOBILE_CAPTCHA,
         self::FIND_LOGIN_PASSWORD_CAPTCHA,
+        self::OTHER_CAPTCHA,
     ];
 
 
@@ -89,6 +91,7 @@ class NoticeEnum
             self::BIND_MOBILE_CAPTCHA => '绑定手机验证码',
             self::CHANGE_MOBILE_CAPTCHA => '变更手机验证码',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '找回登录密码验证码',
+            self::OTHER_CAPTCHA => '其它',
         ];
 
         if ($flag) {
@@ -117,6 +120,8 @@ class NoticeEnum
             'BGSJHM' => self::CHANGE_MOBILE_CAPTCHA,
             // 找回登录密码
             'ZHDLMM' => self::FIND_LOGIN_PASSWORD_CAPTCHA,
+            //其它
+            'OTHER' => self::OTHER_CAPTCHA,
         ];
         return $scene[$tag] ?? '';
     }
@@ -137,6 +142,7 @@ class NoticeEnum
             self::BIND_MOBILE_CAPTCHA => '验证码:code',
             self::CHANGE_MOBILE_CAPTCHA => '验证码:code',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '验证码:code',
+            self::OTHER_CAPTCHA => '验证码:code',
         ];
 
         if ($flag) {
@@ -182,6 +188,7 @@ class NoticeEnum
             self::BIND_MOBILE_CAPTCHA => '您正在绑定手机号,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::CHANGE_MOBILE_CAPTCHA => '您正在变更手机号,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '您正在找回登录密码,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
+            self::OTHER_CAPTCHA => '您的验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
         ];
 
         if ($flag) {

+ 34 - 0
app/common/model/MasterWorkerRegister.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * MasterWorkerRegister模型
+ * Class MasterWorkerRegister
+ * @package app\common\model
+ */
+class MasterWorkerRegister extends BaseModel
+{
+    
+    protected $name = 'master_worker_register';
+    
+
+    
+}

+ 4 - 1
app/common/model/dict/DictType.php

@@ -43,5 +43,8 @@ class DictType extends BaseModel
     {
         return $data['status'] ? '正常' : '停用';
     }
-
+    public function dictData()
+    {
+        return $this->hasMany(DictData::class,'type_id','id')->where('status',1)->order('sort','desc')->field('id,type_id,name');
+    }
 }

+ 7 - 1
app/common/model/goods/Goods.php

@@ -16,7 +16,7 @@ namespace app\common\model\goods;
 
 
 use app\common\model\BaseModel;
-
+use app\common\model\goods_category\GoodsCategory;
 
 
 /**
@@ -33,4 +33,10 @@ class Goods extends BaseModel
     protected $type = [
         'goods_category_ids' =>  'array',
     ];
+
+    public function goodsCategory()
+    {
+        return $this->hasOne(GoodsCategory::class, 'id', 'goods_category_id')
+            ->field('id,name,picture');
+    }
 }

+ 34 - 0
app/common/model/master_worker_register/MasterWorkerRegister.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\master_worker_register;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * MasterWorkerRegister模型
+ * Class MasterWorkerRegister
+ * @package app\common\model\master_worker_register
+ */
+class MasterWorkerRegister extends BaseModel
+{
+    
+    protected $name = 'master_worker_register';
+    
+
+    
+}

+ 31 - 0
app/workerapi/controller/BaseApiController.php

@@ -0,0 +1,31 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\workerapi\controller;
+
+use app\common\controller\BaseLikeAdminController;
+
+class BaseApiController extends BaseLikeAdminController
+{
+    protected int $userId = 0;
+    protected array $userInfo = [];
+
+    public function initialize()
+    {
+        if (isset($this->request->userInfo) && $this->request->userInfo) {
+            $this->userInfo = $this->request->userInfo;
+            $this->userId = $this->request->userInfo['user_id'];
+        }
+    }
+}

+ 222 - 0
app/workerapi/controller/LoginController.php

@@ -0,0 +1,222 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\workerapi\controller;
+
+use app\workerapi\controller\BaseApiController;
+use app\workerapi\logic\LoginLogic;
+use app\workerapi\validate\RegisterValidate;
+
+
+/**
+ * 登录注册
+ * Class LoginController
+ * @package app\api\controller
+ */
+class LoginController extends BaseApiController
+{
+
+    public array $notNeedLogin = ['register', 'account', 'logout'];
+
+
+    /**
+     * @notes 注册账号
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/7 15:38
+     */
+    public function register()
+    {
+        $params = (new RegisterValidate())->post()->goCheck('register');
+        $res = LoginLogic::confirmMobile($params);
+        if(!$res){
+            return $this->fail(LoginLogic::getError());
+        }
+        $result = LoginLogic::register($params);
+        if (true === $result) {
+            return $this->success('注册成功', [], 1, 1);
+        }
+        return $this->fail(LoginLogic::getError());
+    }
+
+
+    /**
+     * @notes 账号密码/手机号密码/手机号验证码登录
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/16 10:42
+     */
+    public function account()
+    {
+        $params = (new LoginAccountValidate())->post()->goCheck();
+        $result = LoginLogic::login($params);
+        if (false === $result) {
+            return $this->fail(LoginLogic::getError());
+        }
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 退出登录
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:42
+     */
+    public function logout()
+    {
+        LoginLogic::logout($this->userInfo);
+        return $this->success();
+    }
+
+
+    /**
+     * @notes 获取微信请求code的链接
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/15 18:27
+     */
+    public function codeUrl()
+    {
+        $url = $this->request->get('url');
+        $result = ['url' => LoginLogic::codeUrl($url)];
+        return $this->success('获取成功', $result);
+    }
+
+
+    /**
+     * @notes 公众号登录
+     * @return \think\response\Json
+     * @throws \GuzzleHttp\Exception\GuzzleException
+     * @author 段誉
+     * @date 2022/9/20 19:48
+     */
+    public function oaLogin()
+    {
+        $params = (new WechatLoginValidate())->post()->goCheck('oa');
+        $res = LoginLogic::oaLogin($params);
+        if (false === $res) {
+            return $this->fail(LoginLogic::getError());
+        }
+        return $this->success('', $res);
+    }
+
+
+    /**
+     * @notes 小程序-登录接口
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/20 19:48
+     */
+    public function mnpLogin()
+    {
+        $params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
+        $res = LoginLogic::mnpLogin($params);
+        if (false === $res) {
+            return $this->fail(LoginLogic::getError());
+        }
+        return $this->success('', $res);
+    }
+
+
+    /**
+     * @notes 小程序绑定微信
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/20 19:48
+     */
+    public function mnpAuthBind()
+    {
+        $params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
+        $params['user_id'] = $this->userId;
+        $result = LoginLogic::mnpAuthLogin($params);
+        if ($result === false) {
+            return $this->fail(LoginLogic::getError());
+        }
+        return $this->success('绑定成功', [], 1, 1);
+    }
+
+
+
+    /**
+     * @notes 公众号绑定微信
+     * @return \think\response\Json
+     * @throws \GuzzleHttp\Exception\GuzzleException
+     * @author 段誉
+     * @date 2022/9/20 19:48
+     */
+    public function oaAuthBind()
+    {
+        $params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
+        $params['user_id'] = $this->userId;
+        $result = LoginLogic::oaAuthLogin($params);
+        if ($result === false) {
+            return $this->fail(LoginLogic::getError());
+        }
+        return $this->success('绑定成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取扫码地址
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/10/20 18:25
+     */
+    public function getScanCode()
+    {
+        $redirectUri = $this->request->get('url/s');
+        $result = LoginLogic::getScanCode($redirectUri);
+        if (false === $result) {
+            return $this->fail(LoginLogic::getError() ?? '未知错误');
+        }
+        return $this->success('', $result);
+    }
+
+
+    /**
+     * @notes 网站扫码登录
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/10/21 10:28
+     */
+    public function scanLogin()
+    {
+        $params = (new WebScanLoginValidate())->post()->goCheck();
+        $result = LoginLogic::scanLogin($params);
+        if (false === $result) {
+            return $this->fail(LoginLogic::getError() ?? '登录失败');
+        }
+        return $this->success('', $result);
+    }
+
+
+    /**
+     * @notes 更新用户头像昵称
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/22 11:15
+     */
+    public function updateUser()
+    {
+        $params = (new WechatLoginValidate())->post()->goCheck("updateUser");
+        LoginLogic::updateUser($params, $this->userId);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+}

+ 18 - 0
app/workerapi/controller/SettingController.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace app\workerapi\controller;
+
+use app\workerapi\logic\DictLogic;
+use app\workerapi\validate\DictValidate;
+
+class SettingController extends BaseApiController
+{
+    public array $notNeedLogin = ['dictData'];
+
+    public function dictData()
+    {
+       $params = (new DictValidate())->post()->goCheck('dictData');
+       $res = DictLogic::groupData($params);
+       return $this->success('', $res);
+   }
+}

+ 21 - 0
app/workerapi/logic/DictLogic.php

@@ -0,0 +1,21 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\logic\BaseLogic;
+use app\common\model\dict\DictType;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+class DictLogic extends BaseLogic
+{
+    public static function groupData($params): array
+    {
+        $typeArr = $params['type'];
+        return DictType::with('dictData')->whereIn('type',$typeArr)
+            ->field('id,type,name')
+            ->where('status',1)
+            ->select()
+            ->toArray();
+    }
+}

+ 57 - 0
app/workerapi/logic/LoginLogic.php

@@ -0,0 +1,57 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\enum\notice\NoticeEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\service\sms\SmsDriver;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+class LoginLogic extends BaseLogic
+{
+
+    /**
+     * @notes 确认手机号
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/9/21 17:28
+     */
+    public static function confirmMobile(array $params)
+    {
+        try {
+            // 变更手机号场景
+            $sceneId = NoticeEnum::OTHER_CAPTCHA;
+            // 校验短信
+//            $checkSmsCode = (new SmsDriver())->verify($params['mobile'], $params['code'], $sceneId);
+//            if (!$checkSmsCode) {
+//                throw new \Exception('验证码错误');
+//            }
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function register(array $params)
+    {
+        try {
+            MasterWorkerRegister::create([
+                'maintain_exp_type' => $params['maintain_exp_type'],
+                'other_exp_type' => $params['other_exp_type'],
+                'city' => $params['city'],
+                'vehicle_type' => $params['vehicle_type'],
+                'name' => $params['name'],
+                'age' => $params['age'],
+                'mobile' => $params['mobile'],
+            ]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 20 - 0
app/workerapi/validate/DictValidate.php

@@ -0,0 +1,20 @@
+<?php
+namespace app\workerapi\validate;
+use app\common\validate\BaseValidate;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+
+class DictValidate extends BaseValidate
+{
+    protected $rule = [
+        'type' => 'require|array',
+    ];
+
+    protected $message = [
+        'type.require' => '字典类型名称必填',
+        'type.array' => '字典类型名称值必须是数组',
+    ];
+}

+ 38 - 0
app/workerapi/validate/RegisterValidate.php

@@ -0,0 +1,38 @@
+<?php
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+namespace app\workerapi\validate;
+
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\validate\BaseValidate;
+
+/**
+ * 注册验证器
+ * Class RegisterValidate
+ * @package app\api\validate
+ */
+class RegisterValidate extends BaseValidate
+{
+    protected $rule = [
+        'other_exp_type' => 'require',
+        'vehicle_type' => 'require',
+        'name' => 'require',
+        'age' => 'require|number|between:18,55',
+        'mobile' => 'require|mobile|unique:' . MasterWorkerRegister::class,
+        'code' => 'require'
+    ];
+
+    protected $message = [
+        'other_exp_type.require' => '其他经验必填',
+        'vehicle_type.require' => '交通工具必填',
+        'name.require' => '账号必填',
+        'age.require' => '年龄必填',
+        'age.number' => '年龄必须为数字',
+        'age.between' => '年龄只能在18-55之间',
+        'mobile.unique' => '手机号重复',
+        'mobile.mobile' => '请输入正确手机号',
+        'code.require' => '请输入验证码',
+    ];
+}