林海涛 пре 1 година
родитељ
комит
17b5ba0268

+ 108 - 0
app/adminapi/controller/firm/FirmRegisterController.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\firm;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\firm\FirmRegisterLists;
+use app\adminapi\logic\firm\FirmRegisterLogic;
+use app\adminapi\validate\firm\FirmRegisterValidate;
+
+
+/**
+ * FirmRegister控制器
+ * Class FirmRegisterController
+ * @package app\adminapi\controller\firm
+ */
+class FirmRegisterController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function lists()
+    {
+        return $this->dataLists(new FirmRegisterLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function add()
+    {
+        $params = (new FirmRegisterValidate())->post()->goCheck('add');
+        $result = FirmRegisterLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(FirmRegisterLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function edit()
+    {
+        $params = (new FirmRegisterValidate())->post()->goCheck('edit');
+        $result = FirmRegisterLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(FirmRegisterLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function delete()
+    {
+        $params = (new FirmRegisterValidate())->post()->goCheck('delete');
+        FirmRegisterLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function detail()
+    {
+        $params = (new FirmRegisterValidate())->goCheck('detail');
+        $result = FirmRegisterLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 77 - 0
app/adminapi/lists/firm/FirmRegisterLists.php

@@ -0,0 +1,77 @@
+<?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\firm;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\firm\FirmRegister;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * FirmRegister列表
+ * Class FirmRegisterLists
+ * @package app\adminapi\listsfirm
+ */
+class FirmRegisterLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['firm_name', 'user_name', 'mobile', 'status', 'user_id', 'create_time', 'update_time'],

+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function lists(): array
+    {
+        return FirmRegister::where($this->searchWhere)
+            ->field(['id', 'firm_name', 'user_name', 'mobile', 'address', 'cooperate_description', 'status', 'user_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function count(): int
+    {
+        return FirmRegister::where($this->searchWhere)->count();
+    }
+
+}

+ 1 - 1
app/adminapi/lists/user/UserLists.php

@@ -51,7 +51,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
      */
      */
     public function lists(): array
     public function lists(): array
     {
     {
-        $field = "id,sn,nickname,sex,avatar,account,mobile,channel,create_time";
+        $field = "id,sn,nickname,sex,avatar,account,user_type,mobile,channel,create_time";
         $lists = User::withSearch($this->setSearch(), $this->params)
         $lists = User::withSearch($this->setSearch(), $this->params)
             ->limit($this->limitOffset, $this->limitLength)
             ->limit($this->limitOffset, $this->limitLength)
             ->field($field)
             ->field($field)

+ 122 - 0
app/adminapi/logic/firm/FirmRegisterLogic.php

@@ -0,0 +1,122 @@
+<?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\firm;
+
+
+use app\common\enum\YesNoEnum;
+use app\common\model\firm\FirmRegister;
+use app\common\logic\BaseLogic;
+use app\common\model\user\User;
+use think\facade\Db;
+
+
+/**
+ * FirmRegister逻辑
+ * Class FirmRegisterLogic
+ * @package app\adminapi\logic\firm
+ */
+class FirmRegisterLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            FirmRegister::create([
+                'firm_name' => $params['firm_name'],
+                'user_name' => $params['user_name'],
+                'mobile' => $params['mobile'],
+                'address' => $params['address'],
+                'cooperate_description' => $params['cooperate_description'],
+                'status' => $params['status'],
+                'user_id' => $params['user_id'],
+            ]);
+
+            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/12 14:50
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $firmRegister =   FirmRegister::where('id', $params['id'])->findOrEmpty();
+            if(!$firmRegister->isEmpty()){
+                $firmRegister->status = $params['status'];
+                $firmRegister->save();
+                if($params['status'] === YesNoEnum::YES){
+                    $user = User::findOrEmpty($firmRegister->user_id);
+                    if($user->isEmpty()){
+                        $user->user_type = YesNoEnum::YES;
+                        $user->save();
+                    }
+                }
+            }
+            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/12 14:50
+     */
+    public static function delete(array $params): bool
+    {
+        return FirmRegister::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public static function detail($params): array
+    {
+        return FirmRegister::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 1 - 1
app/adminapi/logic/user/UserLogic.php

@@ -39,7 +39,7 @@ class UserLogic extends BaseLogic
     {
     {
         $field = [
         $field = [
             'id', 'sn', 'account', 'nickname', 'avatar', 'real_name',
             'id', 'sn', 'account', 'nickname', 'avatar', 'real_name',
-            'sex', 'mobile', 'create_time', 'login_time', 'channel',
+            'sex', 'mobile', 'create_time', 'login_time', 'channel','user_type',
             'user_money',
             'user_money',
         ];
         ];
 
 

+ 102 - 0
app/adminapi/validate/firm/FirmRegisterValidate.php

@@ -0,0 +1,102 @@
+<?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\firm;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * FirmRegister验证器
+ * Class FirmRegisterValidate
+ * @package app\adminapi\validate\firm
+ */
+class FirmRegisterValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'firm_name' => 'require',
+        'user_name' => 'require',
+        'mobile' => 'require',
+        'user_id' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'firm_name' => '公司名称',
+        'user_name' => '用户名称',
+        'mobile' => '联系电话',
+        'user_id' => '用户ID',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return FirmRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['firm_name','user_name','mobile','user_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return FirmRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','firm_name','user_name','mobile','user_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return FirmRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return FirmRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/12 14:50
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 27 - 0
app/api/controller/FirmController.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\logic\FirmLogic;
+use app\api\validate\FirmRegisterValidate;
+
+class FirmController extends BaseApiController
+{
+    public array $notNeedLogin = [];
+
+    /**
+     * 企业注册
+     * @return \think\response\Json
+     * @author 林海涛
+     * @date 2024/7/12 下午2:17
+     */
+    public function register()
+    {
+        $params = (new FirmRegisterValidate())->post()->goCheck('register');
+        $result = FirmLogic::register($params,$this->userId);
+        if (true === $result) {
+            return $this->success('已提交', [], 1, 1);
+        }
+        return $this->fail(FirmLogic::getError());
+    }
+}

+ 30 - 0
app/api/logic/FirmLogic.php

@@ -0,0 +1,30 @@
+<?php
+namespace app\api\logic;
+use app\common\logic\BaseLogic;
+use app\common\model\firm\FirmRegister;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/12 下午2:28
+ */
+class FirmLogic  extends BaseLogic
+{
+
+   public static function register($params,$userId)
+   {
+       try {
+           FirmRegister::create([
+               'firm_name' => $params['firm_name'],
+               'user_name' => $params['user_name'],
+               'mobile' => $params['mobile'],
+               'address' => $params['address'],
+               'cooperate_description' => $params['cooperate_description'],
+               'user_id' => $userId
+           ]);
+           return true;
+       } catch (\Exception $e) {
+           self::setError($e->getMessage());
+           return false;
+       }
+   }
+}

+ 29 - 0
app/api/validate/FirmRegisterValidate.php

@@ -0,0 +1,29 @@
+<?php
+namespace app\api\validate;
+
+use app\common\model\firm\FirmRegister;
+use app\common\validate\BaseValidate;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/12 下午2:19
+ */
+class FirmRegisterValidate extends BaseValidate
+{
+    protected $rule = [
+        'firm_name' => 'require|unique:'.FirmRegister::class,
+        'user_name' => 'require',
+        'mobile' => 'require|mobile|unique:'.FirmRegister::class,
+        'address' => 'require',
+    ];
+
+
+    protected $message = [
+        'firm_name.require' => '请输入公司名称',
+        'firm_name.unique' => '公司名称已存在',
+        'user_name.mobile' => '请输入用户姓名',
+        'mobile.require' => '请填写手机号',
+        'mobile.unique' => '手机号已经注册',
+        'mobile.mobile' => '手机号格式不正确',
+    ];
+}

+ 34 - 0
app/common/model/firm/FirmRegister.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\firm;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * FirmRegister模型
+ * Class FirmRegister
+ * @package app\common\model\firm
+ */
+class FirmRegister extends BaseModel
+{
+    
+    protected $name = 'firm_register';
+    
+
+    
+}

+ 0 - 2
app/workerapi/http/middleware/LoginMiddleware.php

@@ -17,9 +17,7 @@ namespace app\workerapi\http\middleware;
 
 
 
 
 use app\common\cache\MasterWokerTokenCache;
 use app\common\cache\MasterWokerTokenCache;
-use app\common\cache\UserTokenCache;
 use app\common\service\JsonService;
 use app\common\service\JsonService;
-use app\api\service\UserTokenService;
 use app\workerapi\service\MasterWokerTokenService;
 use app\workerapi\service\MasterWokerTokenService;
 use think\facade\Config;
 use think\facade\Config;