Procházet zdrojové kódy

pc端接口转移到app/company

lizhen_gitee před 7 měsíci
rodič
revize
519dc27374

+ 14 - 0
application/company/behavior/PcAdminLog.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace app\company\behavior;
+
+class PcAdminLog
+{
+    public function run(&$response)
+    {
+        //只记录POST请求的日志
+        if (request()->isPost() && config('pc_admin.auto_record_log')) {
+            \app\common\model\PcAdminLog::record();
+        }
+    }
+}

+ 1 - 0
application/company/common.php

@@ -0,0 +1 @@
+<?php

+ 6 - 0
application/company/config.php

@@ -0,0 +1,6 @@
+<?php
+
+//配置文件
+return [
+    'exception_handle'        => '\\app\\company\\library\\ExceptionHandle',
+];

+ 30 - 0
application/company/controller/Baseconfig.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace app\company\controller;
+
+use app\common\controller\Apic;
+use think\Db;
+/**
+ * 基础配置接口
+ */
+class Baseconfig extends Apic
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+   
+    public function index(){
+
+        $config = [
+
+        ];
+
+        $this->success('success',$config);
+    }
+
+
+
+
+
+
+}

+ 141 - 0
application/company/controller/Index.php

@@ -0,0 +1,141 @@
+<?php
+
+namespace app\company\controller;
+
+use app\common\controller\Apic;
+use app\common\model\PcAdminLog;
+use fast\Random;
+use think\Config;
+use think\Validate;
+
+use think\Db;
+
+/**
+ * 会员接口
+ */
+class Index extends Apic
+{
+    protected $noNeedLogin = ['login'];
+    protected $noNeedRight = '*';
+
+    public function _initialize()
+    {
+        parent::_initialize();
+
+    }
+
+    //员工账号+密码登录
+    public function login()
+    {
+        $username = input('username');
+        $password = input('password');
+        if (!$username || !$password) {
+            $this->error(__('Invalid parameters'));
+        }
+
+        PcAdminLog::setTitle(__('Login'));
+
+        //找员工
+        $ret = $this->auth->login($username, $password);
+        if ($ret) {
+            $data = $this->auth->getUserinfo_simple();
+            $this->success('登录成功', $data);
+        } else {
+            $msg = $this->auth->getError();
+            $msg = $msg ? $msg : __('Username or password is incorrect');
+            $this->error($msg);
+        }
+    }
+
+
+
+    /**
+     * 退出登录
+     * @ApiMethod (POST)
+     */
+    public function logout()
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__('Invalid parameters'));
+        }
+        $this->auth->logout();
+        $this->success('退出成功');
+    }
+
+
+    //用户详细资料
+    public function getUserinfo(){
+        $info = $this->auth->getUserinfo();
+
+        $this->success(__('success'),$info);
+    }
+
+    //用户申请资料
+    public function getUserapplyinfo(){
+        $field = [
+            'company_name',
+            'company_code',
+            'company_registerdate',
+            'company_address',
+            'company_image',
+
+            'truename',
+            'idcard',
+            'idcard_images',
+
+            'bank_name',
+            'bank_branchname',
+            'bank_account',
+            'bank_card',
+        ];
+
+        $info = Db::name('company')->field($field)->where('id',$this->auth->id)->find();
+        $info = info_domain_image($info,['company_image','idcard_images']);
+        $this->success(1,$info);
+    }
+
+
+    /**
+     * 修改会员个人信息
+     *
+     * @ApiMethod (POST)
+     * @param string $avatar   头像地址
+     * @param string $username 用户名
+     * @param string $nickname 昵称
+     * @param string $bio      个人简介
+     */
+    public function profile()
+    {
+        //检查
+        $check = Db::name('company')->where('id',$this->auth->id)->find();
+        if($check['status'] == 1){
+            $this->success('资料审核通过后需联系客服修改');
+        }
+
+        $field = [
+            'company_name',
+            'company_code',
+            'company_registerdate',
+            'company_address',
+            'company_image',
+
+            'truename',
+            'idcard',
+            'idcard_images',
+
+            'bank_name',
+            'bank_branchname',
+            'bank_account',
+            'bank_card',
+        ];
+
+        $data = request_post_hub($field);
+        $data['status'] = 0;
+
+        $update_rs = Db::name('company')->where('id',$this->auth->id)->update($data);
+
+        $this->success('资料更新完成');
+    }
+
+
+}

+ 102 - 0
application/company/lang/zh-cn.php

@@ -0,0 +1,102 @@
+<?php
+
+return [
+    'Keep login'                                     => '保持会话',
+    'Username'                                       => '用户名',
+    'User id'                                        => '会员ID',
+    'Nickname'                                       => '昵称',
+    'Password'                                       => '密码',
+    'Sign up'                                        => '注 册',
+    'Sign in'                                        => '登 录',
+    'Sign out'                                       => '退 出',
+    'Guest'                                          => '游客',
+    'Welcome'                                        => '%s,你好!',
+    'Add'                                            => '添加',
+    'Edit'                                           => '编辑',
+    'Delete'                                         => '删除',
+    'Move'                                           => '移动',
+    'Name'                                           => '名称',
+    'Status'                                         => '状态',
+    'Weigh'                                          => '权重',
+    'Operate'                                        => '操作',
+    'Warning'                                        => '温馨提示',
+    'Default'                                        => '默认',
+    'Article'                                        => '文章',
+    'Page'                                           => '单页',
+    'OK'                                             => '确定',
+    'Cancel'                                         => '取消',
+    'Loading'                                        => '加载中',
+    'More'                                           => '更多',
+    'Normal'                                         => '正常',
+    'Hidden'                                         => '隐藏',
+    'Submit'                                         => '提交',
+    'Reset'                                          => '重置',
+    'Execute'                                        => '执行',
+    'Close'                                          => '关闭',
+    'Search'                                         => '搜索',
+    'Refresh'                                        => '刷新',
+    'First'                                          => '首页',
+    'Previous'                                       => '上一页',
+    'Next'                                           => '下一页',
+    'Last'                                           => '末页',
+    'None'                                           => '无',
+    'Home'                                           => '主页',
+    'Online'                                         => '在线',
+    'Logout'                                         => '退出',
+    'Profile'                                        => '个人资料',
+    'Index'                                          => '首页',
+    'Hot'                                            => '热门',
+    'Recommend'                                      => '推荐',
+    'Dashboard'                                      => '控制台',
+    'Code'                                           => '编号',
+    'Message'                                        => '内容',
+    'Line'                                           => '行号',
+    'File'                                           => '文件',
+    'Menu'                                           => '菜单',
+    'Type'                                           => '类型',
+    'Title'                                          => '标题',
+    'Content'                                        => '内容',
+    'Append'                                         => '追加',
+    'Memo'                                           => '备注',
+    'Parent'                                         => '父级',
+    'Params'                                         => '参数',
+    'Permission'                                     => '权限',
+    'Advance search'                                 => '高级搜索',
+    'Check all'                                      => '选中全部',
+    'Expand all'                                     => '展开全部',
+    'Begin time'                                     => '开始时间',
+    'End time'                                       => '结束时间',
+    'Create time'                                    => '创建时间',
+    'Flag'                                           => '标志',
+    'Please login first'                             => '请登录后操作',
+    'Uploaded successful'                            => '上传成功',
+    'You can upload up to %d file%s'                 => '你最多还可以上传%d个文件',
+    'You can choose up to %d file%s'                 => '你最多还可以选择%d个文件',
+    'Chunk file write error'                         => '分片写入失败',
+    'Chunk file info error'                          => '分片文件错误',
+    'Chunk file merge error'                         => '分片合并错误',
+    'Chunk file disabled'                            => '未开启分片上传功能',
+    'Cancel upload'                                  => '取消上传',
+    'Upload canceled'                                => '上传已取消',
+    'No file upload or server upload limit exceeded' => '未上传文件或超出服务器上传限制',
+    'Uploaded file format is limited'                => '上传文件格式受限制',
+    'Uploaded file is not a valid image'             => '上传文件不是有效的图片文件',
+    'Are you sure you want to cancel this upload?'   => '确定取消上传?',
+    'Remove file'                                    => '移除文件',
+    'You can only upload a maximum of %s files'      => '你最多允许上传 %s 个文件',
+    'You can\'t upload files of this type'           => '不允许上传的文件类型',
+    'Server responded with %s code'                  => '服务端响应(Code:%s)',
+    'File is too big (%sMiB), Max filesize: %sMiB.'  => '当前上传(%sM),最大允许上传文件大小:%sM',
+    'Redirect now'                                   => '立即跳转',
+    'Operation completed'                            => '操作成功!',
+    'Operation failed'                               => '操作失败!',
+    'Unknown data format'                            => '未知的数据格式!',
+    'Network error'                                  => '网络错误!',
+    'Advanced search'                                => '高级搜索',
+    'Invalid parameters'                             => '未知参数',
+    'No results were found'                          => '记录未找到',
+    'Parameter %s can not be empty'                  => '参数%s不能为空',
+    'You have no permission'                         => '你没有权限访问',
+    'An unexpected error occurred'                   => '发生了一个意外错误,程序猿正在紧急处理中',
+    'This page will be re-directed in %s seconds'    => '页面将在 %s 秒后自动跳转',
+];

+ 3 - 0
application/company/lang/zh-cn/common.php

@@ -0,0 +1,3 @@
+<?php
+
+return [];

+ 39 - 0
application/company/lang/zh-cn/user.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+    'User center'                           => '会员中心',
+    'Register'                              => '注册',
+    'Login'                                 => '登录',
+    'Sign up successful'                    => '注册成功',
+    'Username can not be empty'             => '用户名不能为空',
+    'Username must be 3 to 30 characters'   => '用户名必须3-30个字符',
+    'Username must be 6 to 30 characters'   => '用户名必须6-30个字符',
+    'Password can not be empty'             => '密码不能为空',
+    'Password must be 6 to 30 characters'   => '密码必须6-30个字符',
+    'Mobile is incorrect'                   => '手机格式不正确',
+    'Username already exist'                => '用户名已经存在',
+    'Nickname already exist'                => '昵称已经存在',
+    'Email already exist'                   => '邮箱已经存在',
+    'Mobile already exist'                  => '手机号已经存在',
+    'Username is incorrect'                 => '用户名不正确',
+    'Email is incorrect'                    => '邮箱不正确',
+    'Account is locked'                     => '账户已经被锁定',
+    'Password is incorrect'                 => '密码不正确',
+    'Account is incorrect'                  => '账户不正确',
+    'Account not exist'                     => '账户不存在',
+    'Account can not be empty'              => '账户不能为空',
+    'Username or password is incorrect'     => '用户名或密码不正确',
+    'You are not logged in'                 => '你当前还未登录',
+    'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
+    'Profile'                               => '个人资料',
+    'Verify email'                          => '邮箱验证',
+    'Change password'                       => '修改密码',
+    'Captcha is incorrect'                  => '验证码不正确',
+    'Logged in successful'                  => '登录成功',
+    'Logout successful'                     => '退出成功',
+    'Operation failed'                      => '操作失败',
+    'Invalid parameters'                    => '参数不正确',
+    'Change password failure'               => '修改密码失败',
+    'Change password successful'            => '修改密码成功',
+    'Reset password successful'             => '重置密码成功',
+];

+ 53 - 0
application/company/library/ExceptionHandle.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace app\company\library;
+
+use Exception;
+use think\exception\Handle;
+use app\utils\LogUtil;
+
+/**
+ * 自定义API模块的错误显示
+ */
+class ExceptionHandle extends Handle
+{
+
+    public function render(Exception $e)
+    {
+        // 在生产环境下返回code信息
+        if (!\think\Config::get('api_exception')) {
+            $statuscode = $code = 500;
+            $msg = $e->getMessage();
+            // 验证异常
+            if ($e instanceof \think\exception\ValidateException) {
+                $code = 0;
+                $statuscode = 200;
+                $msg = $e->getError();
+            }
+            // Http异常
+            if ($e instanceof \think\exception\HttpException) {
+                $statuscode = $code = $e->getStatusCode();
+                $msg = $e->getMessage();
+            }
+
+            $result = ['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null];
+
+            if (defined('API_REQUEST_LOG_TYPE') && defined('API_REQUEST_LOG_TYPE') == 1){
+                LogUtil::error('result','Api-Middleware-Log','request_log',$result);
+                LogUtil::error('ExceptionMsg','Api-Middleware-Log','request_log',$e->getMessage());
+                LogUtil::error('Exception','Api-Middleware-Log','request_log',$e);
+            }else{
+                //记录app异常返回结果
+                if(defined('API_REQUEST_ID')) { //记录app正常返回结果
+                    db('api_request_log')->where('id',API_REQUEST_ID)->update(['result'=>json_encode($result)]);
+                }
+            }
+            $result['msg'] = '网络开小差了';
+            return json($result, $statuscode);
+        }
+
+        //其它此交由系统处理
+        return parent::render($e);
+    }
+
+}

+ 18 - 0
application/company/tags.php

@@ -0,0 +1,18 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+// 应用行为扩展定义文件
+return [
+    // 应用结束
+    'app_end'      => [
+        'app\\company\\behavior\\PcAdminLog',
+    ],
+];