Skip to content

Commit 9d56d75

Browse files
committed
fixed
1 parent 029a49a commit 9d56d75

File tree

18 files changed

+72
-160
lines changed

18 files changed

+72
-160
lines changed

admin-business/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 后台开发,提供管理系统基础功能(首页,登录,退出登
44
keys: admin-business,phpzlc/admin-business,admin,后台
55
type: 业务组件
66
language:
7-
version: v2.0
7+
version: v3.0
88
status: newest
99
sort: 0
1010
links:

admin/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 后台内核,为后台业务提供底层策略,写法支持.(导航
44
keys: admin,phpzlc/admin,后台
55
type: 功能组件
66
language:
7-
version: v2.0
7+
version: v3.0
88
status: newest
99
sort: 0
1010
links:

admin/index.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ $this->adminStrategy
431431
/**
432432
* @var Connection $conn
433433
*/
434-
$conn = $this->getDoctrine()->getConnection();
434+
$conn = ActionLoad::$globalDoctrine->getConnection();
435435
$conn->beginTransaction();
436436

437437
try {
@@ -569,7 +569,7 @@ $this->adminStrategy
569569
'feedDayDaily' => $request->get('id')
570570
];
571571

572-
$daily = $this->getDoctrine()->getRepository('App:FeedDayDaily')->find($request->get('id'));
572+
$daily = ActionLoad::$globalDoctrine->getRepository('App:FeedDayDaily')->find($request->get('id'));
573573

574574
// 通过ex判断是否是导出数据, 如若ex的值为1,则导出数据,如若不是,则显示页面
575575
if($request->get('ex') != 1){
@@ -582,7 +582,7 @@ $this->adminStrategy
582582
$head = [];
583583

584584
// 获取需要导出的数据
585-
$list = $this->getDoctrine()->getRepository('App:FeedDayDailyInfo')->findAll($rules);
585+
$list = ActionLoad::$globalDoctrine->getRepository('App:FeedDayDailyInfo')->findAll($rules);
586586

587587
$data = [];
588588

area-business/index.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keys: area-business,area,地址,省市区
88
省市区组件,内置完整的省市区数据及接口
99

1010
## 源码地址
11-
[phpzlc/area-business](https://github.com/phpzlc/area-business)
11+
[phpzlc/area-business](https://github.com/phpzlc/area-business) (未适配PHPZLC 3 陆续会升级 需要或参与开发技术群内告知)
1212

1313
## 安装
1414

auth-business/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 提供登录,修改密码等基础功能
44
keys: auth,auth-business,phpzlc/auth-business,登录,授权
55
type: 业务组件
66
language:
7-
version: v2.0
7+
version: v3.0
88
status: newest
99
sort: 0
1010
links:

auth-business/index.markdown

+4-9
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class AuthTag
208208
//根据不同的操作平台,进行不同的Session标记设置
209209
switch (PlatformClass::getPlatform()){
210210
case $container->get('parameter_bag')->get('platform_admin'):
211-
$container->get('session')->set(PlatformClass::getPlatform() . $container->get('parameter_bag')->get('login_tag_session_name'), $userAuth->getId());
211+
$container->get('request_stack')->getCurrentRequest()->getSession()->set(PlatformClass::getPlatform() . $container->get('parameter_bag')->get('login_tag_session_name'), $userAuth->getId());
212212
break;
213213
default:
214214
throw new \Exception('来源溢出');
@@ -229,17 +229,12 @@ class AuthTag
229229
public static function get(ContainerInterface $container)
230230
{
231231
$userAuth = null;
232-
233-
/**
234-
* @var ManagerRegistry $doctrine
235-
*/
236-
$doctrine = $container->get('doctrine');
237232

238233
// 根据不同的操作平台,进行对应平台的Session标记获取
239234
switch (PlatformClass::getPlatform()){
240235
case $container->get('parameter_bag')->get('platform_admin'):
241-
$user_auth_id = $container->get('session')->get(PlatformClass::getPlatform() . $container->get('parameter_bag')->get('login_tag_session_name'));
242-
$userAuth = $doctrine->getRepository('App:UserAuth')->find($user_auth_id);
236+
$user_auth_id = $container->get('request_stack')->getCurrentRequest()->getSession()->get(PlatformClass::getPlatform() . $container->get('parameter_bag')->get('login_tag_session_name'));
237+
$userAuth = ActionLoad::$globalDoctrine->getRepository('App:UserAuth')->find($user_auth_id);
243238
break;
244239
default:
245240
throw new \Exception('来源溢出');
@@ -260,7 +255,7 @@ class AuthTag
260255
{
261256
switch (PlatformClass::getPlatform()){
262257
case $container->get('parameter_bag')->get('platform_admin'):
263-
$container->get('session')->remove(PlatformClass::getPlatform() . $container->get('parameter_bag')->get('login_tag_session_name'));
258+
$container->get('request_stack')->getCurrentRequest()->getSession()->get('session')->remove(PlatformClass::getPlatform() . $container->get('parameter_bag')->get('login_tag_session_name'));
264259
break;
265260
default:
266261
throw new \Exception('来源溢出');

captcha-business/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 提供生成图形验证码接口,文档。
44
keys: captcha,captcha-business,phpzlc/captcha-business,图形验证码
55
type: 业务组件
66
language:
7-
version: v2.0
7+
version: v3.0
88
status: newest
99
sort: 0
1010
links:

captcha-business/index.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ captcha:
3636
# 验证码生成
3737
captcha_generate:
3838
path: /generate
39-
controller: App\Controller\Captcha\CaptchaController:generate
39+
controller: App\Controller\Captcha\CaptchaController::generate
4040
```
4141
4242
_如果使用,可以生成查看API文档。[文档知识](/document-bundle/index.markdown)_

document-bundle/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 用于编写接口文档,通过命令生成,在线的,可测试,可
44
keys: symfony,phpzlc,php,document,api,文档
55
type: 功能组件
66
language:
7-
version: v2.0
7+
version: v3.0
88
status: newest
99
sort: 0
1010
links:

phpzlc/db/edit.markdown

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ keys: symfony,phpzlc,orm,表,插入,更新,删除
2727
use Symfony\Component\HttpFoundation\Request;
2828
use Symfony\Component\HttpFoundation\Response;
2929
use Symfony\Component\Validator\Validator\ValidatorInterface;
30+
use PHPZlc\PHPZlc\Bundle\Safety\ActionLoad;
3031
```
3132

3233
2. Business 写法依赖
@@ -50,7 +51,7 @@ keys: symfony,phpzlc,orm,表,插入,更新,删除
5051

5152
public function createUser(ValidatorInterface $validator, Request $request)
5253
{
53-
$manager = $this->getDoctrine()->getManager();
54+
$manager = ActionLoad::$globalDoctrine->getManager();
5455

5556
$user = new User();
5657
$user->setName($request->get('name'));
@@ -98,9 +99,9 @@ keys: symfony,phpzlc,orm,表,插入,更新,删除
9899

99100
public function updateUser(ValidatorInterface $validator, Request $request)
100101
{
101-
$manager = $this->getDoctrine()->getManager();
102+
$manager = ActionLoad::$globalDoctrine->getManager();
102103

103-
$user = $this->getDoctrine()->getRepository('App:User')->find($request->get('id'));
104+
$user = ActionLoad::$globalDoctrine->getRepository('App:User')->find($request->get('id'));
104105

105106
$user->setName($request->get('name'));
106107

@@ -138,9 +139,9 @@ keys: symfony,phpzlc,orm,表,插入,更新,删除
138139
```php
139140
public function removeUser(Request $request)
140141
{
141-
$manager = $this->getDoctrine()->getManager();
142+
$manager = ActionLoad::$globalDoctrine->getManager();
142143

143-
$user = $this->getDoctrine()->getRepository('App:User')->find($request->get('id'));
144+
$user = ActionLoad::$globalDoctrine->getRepository('App:User')->find($request->get('id'));
144145

145146
$manager->remove($user);
146147
$manager->flush();

phpzlc/db/entity.markdown

+35-120
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,36 @@ private ?string $name = null;
103103
#[ORM\Column(name:"content", type:"text", nullable:true, options:["comment" => "长文本"])]
104104
private ?string $content = null;
105105

106+
//外键-多对一
107+
#[ORM\ManyToOne(targetEntity:"App\Entity\UserAuth")]
108+
#[ORM\JoinColumn(name:"user_auth_id", referencedColumnName:"id")]
109+
private ?UserAuth $userAuth = null;
110+
111+
//外键-一对一
112+
#[ORM\OneToOne(targetEntity:"App\Entity\UserAuth")]
113+
#[ORM\JoinColumn(name:"user_auth_id", referencedColumnName:"id")]
114+
private ?UserAuth $userAuth = null;
115+
106116
#[ORM\Column(name:"sort_value", type: "integer", options: ["comment" => "排序值"])]
107117
private int $sortValue = 0;
108118

109119
#[ORM\Column(name:"status", type: "smallint", options: ["comment" => "状态"])]
110120
private int $status = 0;
111121

122+
#[ORM\Column(name: "amount", type: "decimal", precision: 10, scale:2, nullable: true, options: ["comment" => "价格"])]
123+
private ?string $amount = null;
124+
125+
#[ORM\Column(name: "amount", type: "decimal", precision: 10, scale:2, nullable: true, options: ["comment" => "价格"])]
126+
private ?string $amount = null;
127+
112128
//_存储格式为:123,123,123_
113129
#[ORM\Column(name: "tags", type: "simple_array", nullable: true, options: ["comment" => "标记集合"])]
114130
private ?array $tags = [];
115131

132+
//储存格式为对象序列化之后的结果,检索能力较差
133+
#[ORM\Column(name: "files", type: "array", nullable: true, options: ["comment" => "文件集"])]
134+
private ?array $files = [];
135+
116136
#[ORM\Column(name:"is_del", type: "smallint", options: ["comment" => "是否删除", "default" => 0])]
117137
private int $isDel = 0;
118138

@@ -132,126 +152,17 @@ private ?\DateTime $time = null;
132152
#[ORM\Column(name: "create_at", type: "datetime", options:["comment" => "创建时间"])]
133153
private ?\DateTime $createAt = null;
134154
```
135-
136-
6. smallint
137-
138-
```php
139-
140-
const STATUS_COMPLETE = 1;
141-
142-
const STATUS_CANCEL = 2;
143-
144-
const STATUS_REFUND = 3;
145-
146-
const STATUS_PAYMENT = 4;
147-
148-
public static function getStatusArray()
149-
{
150-
return [
151-
self::STATUS_COMPLETE => '已完成',
152-
self::STATUS_CANCEL => '已取消',
153-
self::STATUS_REFUND => '已退款',
154-
self::STATUS_PAYMENT => '已支付'
155-
];
156-
}
157-
158-
/**
159-
* @var integer
160-
*
161-
* @ORM\Column(name="status", type="smallint", options={"comment":"订单状态"})
162-
*/
163-
private $status;
164-
```
165-
166-
_简单选项在表的头部定义成常量,并且设置读取全部的静态方法。_
167-
168-
7. simple_array(简单数组)
169-
170-
```php
171-
/**
172-
* @var array
173-
*
174-
* @ORM\Column(name="tags", type="simple_array", options={"comment":"标签"})
175-
*/
176-
private $tags;
177-
```
178-
179-
_存储格式为:123,123,123_
180-
181-
8. array
182-
183-
```php
184-
/**
185-
* @var array
186-
*
187-
* @ORM\Column(name="files", type="array", options={"comment":"文件集合"})
188-
*/
189-
private $files;
190-
```
191-
192-
_储存格式为对象序列化之后的结果,检索能力较差_
193-
194-
9. double
195-
196-
```php
197-
/**
198-
* @var string
199-
*
200-
* @ORM\Column(name="lon", type="decimal", precision=10, scale=6, options={"comment":"经度"})
201-
*/
202-
private $lon;
203-
204-
/**
205-
* @var string
206-
*
207-
* @ORM\Column(name="lat", type="decimal", precision=10, scale=6, options={"comment":"纬度"})
208-
*/
209-
private $lat;
210-
211-
/**
212-
* @var string
213-
*
214-
* @ORM\Column(name="amount", type="decimal", precision=10, scale=2, nullable=true, options={"comment":"价格"})
215-
*/
216-
private $amount;
217-
```
218-
219-
10. 外键
220-
221-
**多对一**
222-
```php
223-
/**
224-
* @var User
225-
*
226-
* @ORM\ManyToOne(targetEntity="App\Entity\User")
227-
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
228-
*/
229-
private $user;
230-
```
231-
232-
**一对一**
233-
```php
234-
/**
235-
* @var User
236-
*
237-
* @ORM\OneToOne(targetEntity="App\Entity\User")
238-
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
239-
*/
240-
private $user;
241-
```
242155

243156
## 新特性-表外字段
244157

245158
_这是PHPZlc独有的特性,可以将子查询Sql定义为字段,使其可以具有编程性,实现了Sql集中管理,提高了使用效率。_
246159

247160
_该字段在数据库中不对应具体的实际字段,所以称为**表外字段**。在实际使用中,除了不能进行写相关的操作,其他部分和表内其他字段基本无差别。_
248161

249-
```php
250-
/**
251-
* @OuterColumn(name="site_domains", type="simple_array", sql="(SELECT GROUP_CONCAT(sd.site_domain) FROM site_domain sd WHERE sd.site_id = sql_pre.id), options={"comment":"站点域名"}")
252-
*/
253-
public $siteDomains;
254-
```
162+
```php
163+
#[OuterColumn(name: "role_string", type: "string", sql: "(IF(sql_pre.is_super = 1,'超级管理员', (select GROUP_CONCAT(r.name) from role r where id in (select role_id from user_auth_role uar where uar.user_auth_id = sql_pre.user_auth_id))))", options: ["comment" => "是否超级管理员"])]
164+
private ?string $roleString = null;
165+
```
255166

256167
1. 语法注解
257168

@@ -267,10 +178,10 @@ private ?\DateTime $createAt = null;
267178

268179
2. 高级用法
269180

270-
**支持`@AddRule`注释,利用规则注释可以为其成功执行提供必要的保证**
181+
**支持`#[AddRule()]` attribute,利用规则注释可以为其成功执行提供必要保证**
271182

272183
```php
273-
@AddRule(name="id", value="1")
184+
#[AddRule(name:"id", value: 1)]
274185
```
275186

276187
_具体更多的知识,可以通过学习[高级查询-规则章节](/phpzlc/repository/rule/index.markdown)来了解。_
@@ -280,18 +191,22 @@ private ?\DateTime $createAt = null;
280191
正常情况下,子查询的sql是固定不变的。但是有些情况下,子查询的Sql需要传入变量才可以正常的工作。这时候我们可以通过Sql重写解决。
281192

282193
```php
283-
/**
284-
* @OuterColumn(name="distance", type="string", sql="repository内重写", options={"comment":"距离"})
285-
*/
286-
public $distance;
194+
#[OuterColumn(name: "distance", type: "string", sql: "repository内重写", options: ["comment" => "距离"])]
195+
private ?string $distance = null;
287196
```
288197

289198
_具体更多的知识,可以通过学习[规则-高级用法](/phpzlc/repository/rule/advanced-usage.markdown#定义新规则重写规则)来了解。_
290199

291200
## 表加索引
292201

293202
```php
294-
@ORM\Table(name="sms_record", options={"comment"="短信动态码"}, indexes={@ORM\Index(name="phone", columns={"phone"})})
203+
use use Doctrine\ORM\Mapping\Index;
204+
205+
#[ORM\Table(
206+
name: "admin",
207+
indexes: [new Index(name: 'name', columns: ['name'])],
208+
options:["comment" => "管理员表"],
209+
)]
295210
```
296211

297212

0 commit comments

Comments
 (0)