diff --git a/app/common/dao/enter/EnterCompanyDao.php b/app/common/dao/enter/EnterCompanyDao.php new file mode 100644 index 00000000..dd518453 --- /dev/null +++ b/app/common/dao/enter/EnterCompanyDao.php @@ -0,0 +1,40 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\enter; + +use think\Collection; +use think\db\BaseQuery; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; +use think\facade\Db; +use app\common\dao\BaseDao; +use app\common\model\enter\EnterCompany; +use app\common\model\BaseModel; +use think\Model; + +class EnterCompanyDao extends BaseDao +{ + + /** + * @return BaseModel + * @author xaboy + * @day 2020-03-30 + */ + protected function getModel(): string + { + return EnterCompany::class; + } + +} diff --git a/app/common/model/enter/EnterCompany.php b/app/common/model/enter/EnterCompany.php new file mode 100644 index 00000000..c5c57b50 --- /dev/null +++ b/app/common/model/enter/EnterCompany.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\enter; + + +use app\common\model\BaseModel; + +class EnterCompany extends BaseModel +{ + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tablePk(): string + { + return 'id'; + } + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tableName(): string + { + return 'market_company'; + } + + +} diff --git a/app/common/repositories/enter/EnterCompanyRepository.php b/app/common/repositories/enter/EnterCompanyRepository.php new file mode 100644 index 00000000..4a93745b --- /dev/null +++ b/app/common/repositories/enter/EnterCompanyRepository.php @@ -0,0 +1,15 @@ +dao = $dao; + } +} \ No newline at end of file diff --git a/app/controller/api/enter/EnterCompany.php b/app/controller/api/enter/EnterCompany.php new file mode 100644 index 00000000..dbac1e7c --- /dev/null +++ b/app/controller/api/enter/EnterCompany.php @@ -0,0 +1,71 @@ + +// +---------------------------------------------------------------------- + + +namespace app\controller\api\enter; + +use crmeb\basic\BaseController; +use app\common\repositories\enter\EnterCompanyRepository; +use think\App; +use think\facade\Db; +use app\common\model\user\User; + +use function GuzzleHttp\json_decode; + +class EnterCompany extends BaseController +{ + protected $repository; + + public function __construct(App $app, EnterCompanyRepository $repository) + { + parent::__construct($app); + $this->repository = $repository; + } + + /** + * + * @param EnterCompanyRepository $repository + * @return mixed + * @author xaboy + * @day 2020/5/28 + */ + public function add() + { + $data = $this->request->params(['company', ['company_image', []],['master_idcar_positive', []],['master_idcar_negative', []], 'master', 'supervisor','director']); + $data['create_time'] = time(); + $data['shop_user_id'] = $this->request->uid(); + $res = Db::connect('dev')->name('market_company')->insert($data); + return app('json')->success('添加成功'); + } + + public function list($page=1,$limit=10) + { + $where = ['shop_user_id' => $this->request->uid()]; + $list = Db::connect('dev')->name('market_company')->where($where)->page($page,$limit)->order('id desc')->field('id,shop_user_id,company,company_image,master,master_idcar_positive,master_idcar_negative,supervisor,director,create_time') + ->withAttr('supervisor',function($value,$data){ + return json_decode($value,true); + }) + ->withAttr('director',function($value,$data){ + return json_decode($value,true); + }) + ->withAttr('create_time',function($value,$data){ + return date('Y-m-d H:i:s',$value); + }) + ->withAttr('shop_user',function($value,$data){ + return User::where('uid',$data['shop_user_id'])->field('nickname,phone')->find(); + }) + ->select(); + return app('json')->success($list); + } + + +} diff --git a/config/database.php b/config/database.php index 85e3be31..b4248f09 100644 --- a/config/database.php +++ b/config/database.php @@ -68,24 +68,63 @@ return [ 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, ], 'nongke' => [ - // 数据库类型 - 'type' => Env::get('databasenk.type', 'mysql'), - // 服务器地址 - 'hostname' => Env::get('databasenk.hostname', '127.0.0.1'), - // 数据库名 - 'database' => Env::get('databasenk.database', ''), - // 用户名 - 'username' => Env::get('databasenk.username', 'root'), - // 密码 - 'password' => Env::get('databasenk.password', ''), - // 端口 - 'hostport' => Env::get('databasenk.hostport', '3306'), - // 数据库连接参数 - 'params' => [], - // 数据库编码默认采用utf8 - 'charset' => Env::get('databasenk.charset', 'utf8'), - // 数据库表前缀 - 'prefix' => Env::get('databasenk.prefix', ''), + // 数据库类型 + 'type' => Env::get('databasenk.type', 'mysql'), + // 服务器地址 + 'hostname' => Env::get('databasenk.hostname', '127.0.0.1'), + // 数据库名 + 'database' => Env::get('databasenk.database', ''), + // 用户名 + 'username' => Env::get('databasenk.username', 'root'), + // 密码 + 'password' => Env::get('databasenk.password', ''), + // 端口 + 'hostport' => Env::get('databasenk.hostport', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => Env::get('databasenk.charset', 'utf8'), + // 数据库表前缀 + 'prefix' => Env::get('databasenk.prefix', ''), + ], + 'dev' => [ + // 数据库类型 + 'type' => env('database3.type', 'mysql'), + // 服务器地址 + 'hostname' => env('database3.hostname', '127.0.0.1'), + // 数据库名 + 'database' => env('database3.database', ''), + // 用户名 + 'username' => env('database3.username', 'root'), + // 密码 + 'password' => env('database3.password', ''), + // 端口 + 'hostport' => env('database3.hostport', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => env('database3.charset', 'utf8'), + // 数据库表前缀 + 'prefix' => env('database3.prefix', ''), + + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 是否需要断线重连 + 'break_reconnect' => true, + // 监听SQL + 'trigger_sql' => env('app_debug', true), + // 开启字段缓存 + 'fields_cache' => false, + // 字段缓存路径 + 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, ], // 更多的数据库配置信息 ], diff --git a/route/api.php b/route/api.php index 4ab40ea3..8b0a9906 100644 --- a/route/api.php +++ b/route/api.php @@ -333,6 +333,12 @@ Route::group('api/', function () { Route::get('order/:id', 'Community/getSpuByOrder'); })->prefix('api.community.'); + + //录入公司信息 + Route::post('entercompany', 'api.enter.EnterCompany/add'); + // 获取已录入公司 + Route::get('enter/list', 'api.enter.EnterCompany/list'); + })->middleware(UserTokenMiddleware::class, true); //非强制登录 @@ -575,6 +581,9 @@ Route::group('api/', function () { Route::get('ajcaptcha', 'api.Auth/ajcaptcha'); Route::post('ajcheck', 'api.Auth/ajcheck'); + + + })->middleware(AllowOriginMiddleware::class)->middleware(InstallMiddleware::class) ->middleware(CheckSiteOpenMiddleware::class); @@ -590,3 +599,4 @@ Route::group('/open-location', function () { Route::miss('View/h5'); })->middleware(InstallMiddleware::class) ->middleware(CheckSiteOpenMiddleware::class); +