Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
c0038dd2
Commit
c0038dd2
authored
Aug 22, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pc
parent
e06683b1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
417 additions
and
897 deletions
+417
-897
Search.php
application/controllers/Search.php
+11
-5
NameConst.php
application/library/Our/NameConst.php
+1
-1
SearchService.php
application/models/Business/Search/SearchService.php
+13
-742
ShopkeeperService.php
application/models/Business/Store/ShopkeeperService.php
+1
-1
ElasticsTool.php
application/models/Elastics/ElasticsTool.php
+355
-0
ElasticsTool.php
application/models/Elasticsearch/ElasticsTool.php
+0
-148
createIndex.php
public/test/Search/createIndex.php
+18
-0
insertRow.php
public/test/Search/insertRow.php
+18
-0
No files found.
application/controllers/Search.php
View file @
c0038dd2
<?php
class
S
hare
Controller
extends
\Our\Controller_AbstractIndex
{
class
S
earch
Controller
extends
\Our\Controller_AbstractIndex
{
public
$memberId
;
public
function
createIndexAction
()
{
$shareService
=
\Business\User\ShareServiceModel
::
getInstance
();
$saveData
=
$shareService
->
getSaveData
(
$this
->
req
[
'data'
]);
$shareService
->
saveDataToSession
(
$saveData
);
$res
=
$shareService
->
excuteCommand
(
$this
->
key
);
$serchService
=
\Business\Search\SearchServiceModel
::
getInstance
();
$res
=
$serchService
->
createShopKeeperOrders
();
$this
->
success
(
$res
);
}
public
function
insertRowAction
()
{
$serchService
=
\Business\Search\SearchServiceModel
::
getInstance
();
$res
=
$serchService
->
insertRows
();
$this
->
success
(
$res
);
}
}
application/library/Our/NameConst.php
View file @
c0038dd2
...
...
@@ -152,7 +152,7 @@ class NameConst {
const
rightBracket
=
']'
;
const
elasticName
=
'elastic.master'
;
const
s
earchDbName
=
'qmcs
'
;
const
s
hopkeeper
=
'shopkeeper
'
;
}
?>
\ No newline at end of file
application/models/Business/Search/SearchService.php
View file @
c0038dd2
This diff is collapsed.
Click to expand it.
application/models/Business/Store/ShopkeeperService.php
View file @
c0038dd2
...
...
@@ -57,7 +57,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$storeTodayStats
=
$storeStatisticsDayDao
->
getById
(
$storeId
);
$data
[
'storeId'
]
=
$store
[
'store_id'
];
$data
[
'storeName'
]
=
$store
[
'store_name'
];
$data
[
'storeLab
le
'
]
=
$store
[
'store_label'
];
$data
[
'storeLab
el
'
]
=
$store
[
'store_label'
];
$data
[
'goodsCount'
]
=
isset
(
$storeStats
[
'goodsCount'
])
?
$storeStats
[
'goodsCount'
]
:
ApiConst
::
zero
;
$data
[
'orderCount'
]
=
isset
(
$storeStats
[
'orderCount'
])
?
$storeStats
[
'orderCount'
]
:
ApiConst
::
zero
;
$data
[
'orderTotal'
]
=
isset
(
$storeStats
[
'orderTotal'
])
?
$storeStats
[
'orderTotal'
]
:
ApiConst
::
zero
;
...
...
application/models/Elastics/ElasticsTool.php
0 → 100644
View file @
c0038dd2
This diff is collapsed.
Click to expand it.
application/models/Elasticsearch/ElasticsTool.php
deleted
100644 → 0
View file @
e06683b1
<?php
namespace
Elasticsearch
;
use
Elasticsearch\ClientBuilder
;
use
Error\CodeConfigModel
;
use
Error\ErrorModel
;
use
Our\NameConst
;
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/17
* Time: 15:11
*/
class
ElasticsTool
{
protected
$dbName
;
protected
$tbName
;
protected
$client
;
protected
function
__construct
(
$dbName
,
$tbName
)
{
$elasticConfig
=
\Our\Common
::
getConfig
(
NameConst
::
elasticName
);
$configArray
=
array
(
'host'
=>
$elasticConfig
->
host
,
'port'
=>
$elasticConfig
->
port
,
'scheme'
=>
$elasticConfig
->
scheme
);
try
{
$this
->
dbName
=
$dbName
;
$this
->
tbName
=
$tbName
;
$this
->
client
=
ClientBuilder
::
create
()
->
setHosts
(
$configArray
)
->
build
();
}
catch
(
\Exception
$e
){
ErrorModel
::
throwException
(
CodeConfigModel
::
elasticsError
);
}
}
protected
function
initParams
(){
return
[
'index'
=>
$this
->
dbName
,
'type'
=>
$this
->
tbName
];
}
/*
* 陈传文
* 创建索引在设置mapping之前要创建索引
*
*
*
* */
public
function
createIndex
(){
try
{
$indexParams
=
[
'index'
=>
$this
->
dbName
,
];
$r
=
$this
->
client
->
indices
()
->
create
(
$indexParams
);
return
$r
;
}
catch
(
\Exception
$e
){
ErrorModel
::
throwException
(
CodeConfigModel
::
elasticsError
);
}
}
// public function create_index()
// {
// $indexParams['index'] = 'my_index';
// $indexParams['type'] = 'my_index';
// $indexParams['body']['settings']['number_of_shards'] = 2;
// $indexParams['body']['settings']['number_of_replicas'] = 0;
// $this->client->create($indexParams);
// }
public
function
add_document
()
{
$params
=
array
();
$params
[
'body'
]
=
array
(
'testField'
=>
'dfdsfdsf'
);
$params
[
'index'
]
=
'my_index'
;
$params
[
'type'
]
=
'my_index'
;
$params
[
'id'
]
=
'w1231313'
;
$ret
=
$this
->
client
->
index
(
$params
);
}
public
function
delete_index
()
{
$deleteParams
[
'index'
]
=
'my_index'
;
$this
->
client
->
indices
()
->
delete
(
$deleteParams
);
}
public
function
deleteDocumentById
(
$docId
)
{
$deleteParams
=
array
();
$deleteParams
[
'index'
]
=
$this
->
dbName
;
$deleteParams
[
'type'
]
=
$this
->
tbName
;
$deleteParams
[
'id'
]
=
$docId
;
$retDelete
=
$this
->
client
->
delete
(
$deleteParams
);
return
$retDelete
;
}
public
function
update_document
()
{
$updateParams
=
array
();
$updateParams
[
'index'
]
=
'my_index'
;
$updateParams
[
'type'
]
=
'my_index'
;
$updateParams
[
'id'
]
=
'my_id'
;
$updateParams
[
'body'
][
'doc'
][
'asas'
]
=
'111111'
;
$response
=
$this
->
client
->
update
(
$updateParams
);
}
public
function
search
()
{
$searchParams
[
'index'
]
=
'my_index'
;
$searchParams
[
'type'
]
=
'my_index'
;
$searchParams
[
'from'
]
=
0
;
$searchParams
[
'size'
]
=
100
;
$searchParams
[
'sort'
]
=
array
(
'_score'
=>
array
(
'order'
=>
'desc'
)
);
// $searchParams['body']['query']['match']['testField'] = 'abc';
$retDoc
=
$this
->
client
->
search
(
$searchParams
);
print_r
(
$retDoc
);
}
public
function
get_document
()
{
$getParams
=
array
();
$getParams
[
'index'
]
=
'my_index'
;
$getParams
[
'type'
]
=
'my_index'
;
$getParams
[
'id'
]
=
'AU4Kn-knWOmOrmyOj2qg'
;
$retDoc
=
$this
->
client
->
get
(
$getParams
);
print_r
(
$retDoc
);
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private
static
$_instance
=
null
;
/**
* 单例模式获取类实例
*
*/
public
static
function
getInstance
(
$type
,
$index
=
NameConst
::
searchDbName
)
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
(
$index
,
$type
);
}
return
self
::
$_instance
;
}
}
\ No newline at end of file
public/test/Search/createIndex.php
0 → 100644
View file @
c0038dd2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>
简单的html5 File测试 for pic2base64
</title>
<style>
</style>
</head>
<body>
<form
action=
"/search/createIndex"
method=
"post"
>
用户登录状态key:
<input
name=
"data[key]"
value=
"52da049f7e2fbf0e10da32dfe909850e"
/><br
/>
<p
id=
"img_area"
></p>
<input
type=
"submit"
value=
"提交"
>
</form>
</body>
</html>
\ No newline at end of file
public/test/Search/insertRow.php
0 → 100644
View file @
c0038dd2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>
简单的html5 File测试 for pic2base64
</title>
<style>
</style>
</head>
<body>
<form
action=
"/search/insertRow"
method=
"post"
>
用户登录状态key:
<input
name=
"data[key]"
value=
"52da049f7e2fbf0e10da32dfe909850e"
/><br
/>
<p
id=
"img_area"
></p>
<input
type=
"submit"
value=
"提交"
>
</form>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment