This commit is contained in:
zhang zhuo 2025-11-19 10:04:58 +08:00
parent 951a3d2124
commit e1abaa7ff2
40 changed files with 245 additions and 1242 deletions

View File

@ -20,6 +20,7 @@ use App\Request\Dept as dRequest;
use App\Request\Menu as mRequest;
use App\Request\Post as pRequest;
use App\Request\Role as rRequest;
use App\Request\GenTable as gtRequest;
use App\Utils\AppInfoHelper;
use App\Utils\CpuHelper;
use App\Utils\DiskInfoHelper;
@ -463,6 +464,24 @@ class System extends Base
return $this->success("表列表", gtModel::list($param));
}
#[GetMapping(path: "gen_table/info")]
#[Auth(auth: "gen_table:info")]
public function genTableInfo()
{
$id = $this->request->input("id");
return $this->success("详情", gtModel::info($id));
}
#[PostMapping(path: "gen_table/edit")]
#[Auth(auth: "gen_table:edit")]
public function genTableEdit()
{
$request = $this->container->get(gtRequest::class);
$request->scene('edit')->validateResolved();
$param = Param::only(['table_id', 'table_name', 'table_comment', 'controller_name', 'module_name', 'remark', 'gen_table_columns']);
return $this->toAjax(gtModel::editData($param));
}
#[DeleteMapping(path: "gen_table/del")]
#[Auth(auth: "gen_table:del")]
public function genTableDel()
@ -548,4 +567,15 @@ class System extends Base
$res = gtModel::genTable($rows);
return $res ? $this->success("操作成功") : $this->error("操作失败");
}
#[PostMapping(path: "gen_table/sync")]
#[Auth(auth: "gen_table:sync")]
public function genTableSync()
{
$table_id = $this->request->input("id");
if (!$table_id) {
return $this->error("同步失败");
}
return $this->toAjax(gtModel::syncTable($table_id));
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Author: cfn <cfn@leapy.cn>
*/
namespace App\Exception\Handler;
use Hyperf\ExceptionHandler\ExceptionHandler;
use Hyperf\HttpMessage\Stream\SwooleStream;
use Swow\Psr7\Message\ResponsePlusInterface;
use Throwable;
class ServiceExceptionHandler extends ExceptionHandler
{
public function handle(Throwable $throwable, ResponsePlusInterface $response)
{
if (!$response->hasHeader('content-type')) {
$response = $response->withAddedHeader('content-type', 'application/json; charset=utf-8');
}
return $response->withHeader('Server', 'leapy')
->withStatus(200)
->withBody(new SwooleStream(json_encode(['code' => 1, 'msg' => $throwable->getMessage()])));
}
public function isValid(Throwable $throwable): bool
{
return $throwable instanceof \App\Exception\ServiceException;
}
}

View File

@ -0,0 +1,13 @@
<?php
/**
* Author: cfn <cfn@leapy.cn>
*/
namespace App\Exception;
use RuntimeException;
class ServiceException extends RuntimeException
{
}

View File

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $bank_id
* @property string $bank_name
* @property string $fin_institution_code
* @property string $fin_institution_name
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Bank extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'bank';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['bank_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $brand_id
* @property int $org_id
* @property int $merchant_id
* @property string $code
* @property string $url
* @property string $image
* @property string $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Brand extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'brand';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['brand_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer'];
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $channel_id
* @property string $channel_name
* @property string $channel_flag
* @property string $config
* @property int $rank
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Channel extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'channel';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['channel_id' => 'integer', 'rank' => 'integer', 'status' => 'integer'];
}

View File

@ -1,40 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $rate_id
* @property int $account_type
* @property int $belong_id
* @property int $merchant_channel_id
* @property int $channel_id
* @property string $mode
* @property string $period
* @property string $card_type
* @property string $rate
* @property string $rate_2
* @property string $min_fee
* @property string $max_fee
* @property string $deleted_at
* @property string $create_time
* @property string $update_time
*/
class ChannelRate extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'channel_rate';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['rate_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'merchant_channel_id' => 'integer', 'channel_id' => 'integer'];
}

View File

@ -1,38 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $charge_id
* @property int $org_id
* @property int $merchant_id
* @property string $charge_name
* @property int $type
* @property string $bg_img
* @property string $description
* @property string $price
* @property int $day_num
* @property int $buy_time
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Charge extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'charge';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['charge_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'type' => 'integer', 'day_num' => 'integer', 'buy_time' => 'integer'];
}

View File

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $charge_item_id
* @property int $charge_id
* @property int $merchant_id
* @property string $item_name
* @property int $times
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class ChargeItem extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'charge_item';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['charge_item_id' => 'integer', 'charge_id' => 'integer', 'merchant_id' => 'integer', 'times' => 'integer'];
}

View File

@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $coupon_id
* @property int $org_id
* @property int $merchant_id
* @property string $coupon_name
* @property string $bg_img
* @property string $description
* @property int $type
* @property int $discount
* @property string $full_money
* @property string $reduce_money
* @property int $total
* @property int $num
* @property string $began_date
* @property string $end_date
* @property int $status
* @property int $period
* @property int $get_day
* @property int $get_count
* @property int $get_type
* @property int $support_money
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Coupon extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'coupon';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['coupon_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'type' => 'integer', 'discount' => 'integer', 'total' => 'integer', 'num' => 'integer', 'status' => 'integer', 'period' => 'integer', 'get_day' => 'integer', 'get_count' => 'integer', 'get_type' => 'integer', 'support_money' => 'integer'];
}

View File

@ -1,27 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $coupon_id
* @property int $merchant_id
*/
class CouponMerchant extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'coupon_merchant';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['coupon_id' => 'integer', 'merchant_id' => 'integer'];
}

View File

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $device_id
* @property int $factory_id
* @property int $org_id
* @property int $merchant_id
* @property int $device_type
* @property string $code
* @property string $device_sn
* @property string $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Device extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'device';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['device_id' => 'integer', 'factory_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'device_type' => 'integer'];
}

View File

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $factory_id
* @property string $factory_name
* @property string $factory_flag
* @property string $config
* @property string $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Factory extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'factory';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['factory_id' => 'integer'];
}

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Model;
use App\Exception\ServiceException;
use App\Utils\Str;
use Hyperf\DbConnection\Db;
@ -95,4 +96,110 @@ class GenTable extends Model
Db::commit();
return true;
}
public static function editData(array $param): bool
{
Db::beginTransaction();
// 修改主表
$gen_table_columns = $param['gen_table_columns'];
unset($param['gen_table_columns']);
$res = self::edit($param);
if (!$res) {
Db::rollBack();
return false;
}
// 修改子表
$i = 1;
foreach ($gen_table_columns as $column) {
$column['rank'] = $i;
$res = GenTableColumn::edit($column);
$i++;
if (!$res) {
Db::rollBack();
return false;
}
}
Db::commit();
return true;
}
public static function info(int $id)
{
return self::query()
->with(["genTableColumns" => function ($query) {
$query->select(['column_id', 'table_id', 'column_name', 'column_comment', 'column_type', 'php_type',
'php_field', 'is_insert', 'is_edit', 'is_list', 'is_query', 'is_required', 'query_type', 'html_type'])->orderBy("rank");
}])
->where("table_id", $id)
->select(['table_id', 'table_name', 'table_comment', 'controller_name', 'module_name', 'remark', 'create_time', 'update_time'])
->orderByDesc('table_id')
->first()
->toArray();
}
public static function syncTable($table_id)
{
// 查询表信息
$info = self::getById($table_id);
if (empty($info)) {
return false;
}
Db::beginTransaction();
$table = Db::selectOne("SHOW TABLE STATUS WHERE Name = '{$info['table_name']}'");
if (empty($table)) {
Db::rollBack();
return false;
}
// 修改主表信息
$res = self::edit([
'table_id' => $table_id,
'table_name' => $table->Name,
'table_comment' => $table->Comment,
'controller_name' => Str::snakeToCamel(str_replace("pi_", "", $table->Name), true),
'module_name' => 'App\Controller\Admin'
]);
if (!$res) {
Db::rollBack();
return false;
}
// 删除字段
GenTableColumn::where("table_id", $table_id)->delete();
// 修改子表
$columns = Db::select("SHOW FULL COLUMNS FROM `{$table->Name}`");
$i = 1;
foreach ($columns as $column) {
$res = GenTableColumn::add([
'table_id' => $table_id,
'column_name' => $column->Field,
'column_comment' => $column->Comment,
'column_type' => $column->Type,
'php_type' => Str::typeMysqlToPhp($column->Type),
'php_field' => $column->Field,
'is_insert' => Str::isInsert($column->Field, $column->Extra),
'is_edit' => Str::isEdit($column->Field, $column->Extra),
'is_list' => Str::isList($column->Field, $column->Extra),
'is_query' => Str::isQuery($column->Field, $column->Extra),
'is_required' => 0,
'query_type' => str_contains($column->Field, "name") ? "like" : "eq",
'html_type' => Str::htmlType($column->Field),
'rank' => $i
]);
$i++;
if (!$res) {
Db::rollBack();
return false;
}
}
Db::commit();
return true;
}
public function genTableColumns()
{
return $this->hasMany(
GenTableColumn::class,
'table_id',
'table_id'
);
}
}

View File

@ -30,7 +30,7 @@ class GenTableColumn extends Model
*/
protected ?string $table = 'gen_table_column';
protected string $primaryKey = 'column_id ';
protected string $primaryKey = 'column_id';
/**
* The attributes that are mass assignable.

View File

@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $mcc_id
* @property string $mcc_code
* @property string $parent_code
* @property string $mcc_name
* @property string $ls_code
* @property string $ls_name
* @property string $lkl_industry_code
* @property string $lkl_industry_name
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Mcc extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'mcc';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['mcc_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $merchant_id
* @property int $org_id
* @property int $pid
* @property string $merchant_code
* @property string $merchant_name
* @property string $contact_name
* @property string $contact_mobile
* @property string $email
* @property string $service_mobile
* @property string $province_code
* @property string $city_code
* @property string $area_code
* @property string $address
* @property int $mode
* @property int $merchant_type
* @property string $mcc_code
* @property int $status
* @property string $door_pic
* @property string $indoor_pic
* @property string $desk_pic
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Merchant extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['merchant_id' => 'integer', 'org_id' => 'integer', 'pid' => 'integer', 'mode' => 'integer', 'merchant_type' => 'integer', 'status' => 'integer'];
}

View File

@ -1,45 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $change_id
* @property int $org_id
* @property int $merchant_id
* @property int $channel_id
* @property int $income_id
* @property string $change_no
* @property string $change_type
* @property int $status
* @property string $reject_msg
* @property string $settle_period
* @property string $base
* @property string $legal
* @property string $attach
* @property string $rates
* @property string $license
* @property string $account
* @property string $contract_id
* @property string $deleted_at
* @property string $create_time
* @property string $update_time
*/
class MerchantChange extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_change';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['change_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'channel_id' => 'integer', 'income_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $merchant_channel_id
* @property int $org_id
* @property int $merchant_id
* @property int $channel_id
* @property string $channel_merchant_no
* @property string $config
* @property int $earnings_flag
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class MerchantChannel extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_channel';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['merchant_channel_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'channel_id' => 'integer', 'earnings_flag' => 'integer', 'status' => 'integer'];
}

View File

@ -1,46 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $income_id
* @property int $org_id
* @property int $merchant_id
* @property int $channel_id
* @property string $income_no
* @property int $status
* @property string $reject_msg
* @property string $settle_period
* @property string $base
* @property string $legal
* @property string $attach
* @property string $rates
* @property string $license
* @property string $account
* @property string $ec_no
* @property string $ec_apply_id
* @property string $ec_url
* @property string $ic_apply_id
* @property string $deleted_at
* @property string $create_time
* @property string $update_time
*/
class MerchantIncome extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_income';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['income_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'channel_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,38 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $legal_id
* @property int $merchant_id
* @property int $credential_type
* @property string $legal_name
* @property string $id_card_no
* @property string $id_card_front_pic
* @property string $id_card_back_pic
* @property string $id_card_hand_pic
* @property string $id_card_start
* @property string $id_card_end
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class MerchantLegal extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_legal';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['legal_id' => 'integer', 'merchant_id' => 'integer', 'credential_type' => 'integer'];
}

View File

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $license_id
* @property int $merchant_id
* @property string $license_name
* @property string $license_no
* @property string $license_address
* @property string $license_start
* @property string $license_end
* @property string $license_pic
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class MerchantLicense extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_license';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['license_id' => 'integer', 'merchant_id' => 'integer'];
}

View File

@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $roll_id
* @property int $org_id
* @property int $merchant_id
* @property int $mode
* @property string $data1
* @property string $data2
* @property string $data3
* @property string $data4
* @property string $data5
* @property string $deleted_at
* @property string $create_time
* @property string $update_time
*/
class MerchantRoll extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_roll';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['roll_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'mode' => 'integer'];
}

View File

@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $settle_id
* @property int $merchant_id
* @property int $settle_type
* @property string $holder
* @property string $bank_card_no
* @property string $mobile
* @property string $province_code
* @property string $city_code
* @property string $fin_institution_code
* @property string $opening_bank_code
* @property int $credential_type
* @property string $id_card_name
* @property string $id_card_no
* @property string $bank_card_front_pic
* @property string $bank_card_back_pic
* @property string $non_leg_idcard_front_pic
* @property string $non_leg_idcard_back_pic
* @property string $non_leg_start
* @property string $non_leg_end
* @property string $opening_permit_pic
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class MerchantSettle extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_settle';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['settle_id' => 'integer', 'merchant_id' => 'integer', 'settle_type' => 'integer', 'credential_type' => 'integer'];
}

View File

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $term_id
* @property int $org_id
* @property int $merchant_id
* @property int $channel_id
* @property int $merchant_channel_id
* @property string $term_no
* @property string $config
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class MerchantTerm extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'merchant_term';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['term_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'channel_id' => 'integer', 'merchant_channel_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,38 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $org_id
* @property int $pid
* @property string $org_name
* @property string $org_code
* @property int $org_type
* @property string $contact_name
* @property string $contact_mobile
* @property string $id_card_front_pic
* @property string $id_card_back_pic
* @property string $license_pic
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Org extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'org';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['org_id' => 'integer', 'pid' => 'integer', 'org_type' => 'integer'];
}

View File

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $region_id
* @property string $area_code
* @property string $parent_code
* @property string $area_name
* @property string $lkl_code
* @property string $ls_code
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Region extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'region';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['region_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $bank_id
* @property string $province_code
* @property string $city_code
* @property string $fin_institution_code
* @property string $branch_name
* @property string $unionpay_code
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class SubBank extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'sub_bank';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['bank_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,54 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $trade_id
* @property int $org_id
* @property int $merchant_id
* @property string $trade_no
* @property int $ori_trade_id
* @property string $subject
* @property string $appid
* @property string $openid
* @property string $ip
* @property int $timeout
* @property string $amount
* @property int $channel_id
* @property int $merchant_channel_id
* @property int $pay_status
* @property string $out_transaction_id
* @property string $mer_transaction_id
* @property string $transaction_id
* @property int $trade_type
* @property string $auth_code
* @property string $platform
* @property string $period
* @property string $card_type
* @property int $source
* @property string $succ_time
* @property string $fail_time
* @property string $fail_msg
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Trade extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'trade';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['trade_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'ori_trade_id' => 'integer', 'timeout' => 'integer', 'channel_id' => 'integer', 'merchant_channel_id' => 'integer', 'pay_status' => 'integer', 'trade_type' => 'integer', 'source' => 'integer'];
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $fee_id
* @property int $trade_id
* @property int $account_type
* @property int $belong_id
* @property string $rate
* @property int $fee
* @property string $deleted_at
* @property string $create_time
* @property string $update_time
*/
class TradeFee extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'trade_fee';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['fee_id' => 'integer', 'trade_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'fee' => 'integer'];
}

View File

@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $out_trade_id
* @property int $org_id
* @property int $merchant_id
* @property int $trade_id
* @property int $origin
* @property string $out_trade_no
* @property string $notify_url
* @property int $notify_flag
* @property int $notify_num
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class TradeOut extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'trade_out';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['out_trade_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'trade_id' => 'integer', 'origin' => 'integer', 'notify_flag' => 'integer', 'notify_num' => 'integer'];
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $summary_day_id
* @property int $account_type
* @property int $belong_id
* @property string $total_money
* @property string $wechat_money
* @property string $alipay_money
* @property string $unionpay_money
* @property string $balace_money
* @property string $create_date
*/
class TradeSummaryDay extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'trade_summary_day';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['summary_day_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer'];
}

View File

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $user_id
* @property int $invite_id
* @property string $nickname
* @property string $platform
* @property string $openid
* @property string $avatar
* @property int $sex
* @property string $birthday
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class User extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'user';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['user_id' => 'integer', 'invite_id' => 'integer', 'sex' => 'integer'];
}

View File

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $uesr_charge_id
* @property int $user_id
* @property int $merchant_id
* @property int $charge_id
* @property string $charge_no
* @property string $money
* @property int $status
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class UserCharge extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'user_charge';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['uesr_charge_id' => 'integer', 'user_id' => 'integer', 'merchant_id' => 'integer', 'charge_id' => 'integer', 'status' => 'integer'];
}

View File

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $user_charge_item_id
* @property int $org_id
* @property int $merchant_id
* @property int $user_id
* @property int $charge_id
* @property int $uesr_charge_id
* @property int $charge_item_id
* @property int $times
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class UserChargeItem extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'user_charge_item';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['user_charge_item_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'user_id' => 'integer', 'charge_id' => 'integer', 'uesr_charge_id' => 'integer', 'charge_item_id' => 'integer', 'times' => 'integer'];
}

View File

@ -1,38 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $user_coupon_id
* @property int $org_id
* @property int $merchant_id
* @property int $user_id
* @property int $coupon_id
* @property string $coupon_num
* @property int $use_status
* @property string $use_time
* @property int $use_merchant_id
* @property int $get_type
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class UserCoupon extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'user_coupon';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['user_coupon_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer', 'user_id' => 'integer', 'coupon_id' => 'integer', 'use_status' => 'integer', 'use_merchant_id' => 'integer', 'get_type' => 'integer'];
}

View File

@ -1,31 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $register_id
* @property int $org_id
* @property int $merchant_id
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class UserRegister extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'user_register';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['register_id' => 'integer', 'org_id' => 'integer', 'merchant_id' => 'integer'];
}

View File

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $wallet_id
* @property int $account_type
* @property int $belong_id
* @property int $type
* @property string $amount
* @property string $deleted_at
* @property string $create_time
* @property string $update_time
*/
class Wallet extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'wallet';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['wallet_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'type' => 'integer'];
}

64
app/Request/GenTable.php Normal file
View File

@ -0,0 +1,64 @@
<?php
namespace App\Request;
use Hyperf\Validation\Request\FormRequest;
class GenTable extends FormRequest
{
protected array $scenes = [
'edit' => ['table_id', 'table_name', 'controller_name', 'module_name', 'gen_table_columns',
'gen_table_columns.*.column_id', 'gen_table_columns.*.table_id', 'gen_table_columns.*.column_name',
'gen_table_columns.*.column_type', 'gen_table_columns.*.php_type', 'gen_table_columns.*.php_field',
'gen_table_columns.*.is_insert', 'gen_table_columns.*.is_edit', 'gen_table_columns.*.is_list',
'gen_table_columns.*.is_query', 'gen_table_columns.*.is_required', 'gen_table_columns.*.query_type',
'gen_table_columns.*.html_type', 'gen_table_columns.*.column_comment'],
];
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'table_id' => 'required',
'table_name' => 'required',
'controller_name' => 'required',
'module_name' => 'required',
'gen_table_columns' => 'required',
'gen_table_columns.*.column_id' => 'required',
'gen_table_columns.*.table_id' => 'required',
'gen_table_columns.*.column_name' => 'required',
'gen_table_columns.*.column_comment' => 'required',
'gen_table_columns.*.column_type' => 'required',
'gen_table_columns.*.php_type' => 'required',
'gen_table_columns.*.php_field' => 'required',
'gen_table_columns.*.is_insert' => 'required',
'gen_table_columns.*.is_edit' => 'required',
'gen_table_columns.*.is_list' => 'required',
'gen_table_columns.*.is_query' => 'required',
'gen_table_columns.*.is_required' => 'required',
'gen_table_columns.*.query_type' => 'required',
'gen_table_columns.*.html_type' => 'required'
];
}
public function messages(): array
{
return [
'table_id.required' => '表ID必传',
'table_name.required' => '表名称必填!',
'controller_name.required' => '控制器名称必填!',
'module_name.required' => '模块名称必填!',
'gen_table_columns.required' => '表字段必填!'
];
}
}

View File

@ -121,7 +121,7 @@ class Str
case str_contains($field, "_date"):
return "date";
default:
return "input";
return "text";
}
}
}