Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
石磊
/
cihai
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c72ee280
authored
Dec 07, 2017
by
石头
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
首页整合
1 parent
5d4f5306
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
40 deletions
serverside/cihai-core/src/main/java/com/dookay/cihai/core/theme/query/ThemeQuery.java
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/CihaiJspApplication.java
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/HomeController.java
serverside/cihai-wechat/src/main/webapp/WEB-INF/jsp/portal/home/index.jsp
serverside/cihai-wechat/src/main/webapp/static/js/index.js
serverside/cihai-core/src/main/java/com/dookay/cihai/core/theme/query/ThemeQuery.java
View file @
c72ee28
...
@@ -7,26 +7,27 @@ import com.dookay.coral.common.core.persistence.criteria.QueryCriteria;
...
@@ -7,26 +7,27 @@ import com.dookay.coral.common.core.persistence.criteria.QueryCriteria;
import
com.dookay.cihai.core.theme.domain.ThemeDomain
;
import
com.dookay.cihai.core.theme.domain.ThemeDomain
;
/**
/**
* 专题
* 专题
* @author wangwei
*
* @since 2017年12月06日
* @author wangwei
* @version V1.0
* @version V1.0
*/
* @since 2017年12月06日
*/
@Data
@Data
public
class
ThemeQuery
extends
Query
{
public
class
ThemeQuery
extends
Query
{
private
String
keyword
;
private
String
keyword
;
@Override
public
QueryCriteria
toCriteria
()
{
QueryCriteria
queryCriteria
=
new
QueryCriteria
(
ThemeDomain
.
class
);
Example
.
Criteria
criteria
=
queryCriteria
.
createCriteria
();
if
(
valid
(
keyword
))
{
String
str
=
keyword
+
"%"
;
criteria
.
andCondition
(
String
.
format
(
"(title like '%s' or FIND_IN_SET('%s',sub_title))"
,
str
,
keyword
));
}
//todo 写查询逻辑
return
queryCriteria
;
}
@Override
public
QueryCriteria
toCriteria
()
{
QueryCriteria
queryCriteria
=
new
QueryCriteria
(
ThemeDomain
.
class
);
Example
.
Criteria
criteria
=
queryCriteria
.
createCriteria
();
if
(
valid
(
keyword
))
{
String
str
=
"%"
+
keyword
+
"%"
;
criteria
.
andCondition
(
String
.
format
(
"(title like '%s' or sub_title like '%s')"
,
str
,
str
));
}
//todo 写查询逻辑
return
queryCriteria
;
}
}
}
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/CihaiJspApplication.java
View file @
c72ee28
package
com
.
dookay
.
cihai
.
wechat
;
package
com
.
dookay
.
cihai
.
wechat
;
import
com.dookay.cihai.core.Ci
h
aiCoreApplication
;
import
com.dookay.cihai.core.Ci
H
aiCoreApplication
;
import
com.dookay.coral.common.core.CoralCommonCoreMarker
;
import
com.dookay.coral.common.core.CoralCommonCoreMarker
;
import
com.dookay.coral.common.web.CoralCommonWebMarker
;
import
com.dookay.coral.common.web.CoralCommonWebMarker
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
...
@@ -22,14 +22,14 @@ import org.springframework.cache.annotation.EnableCaching;
...
@@ -22,14 +22,14 @@ import org.springframework.cache.annotation.EnableCaching;
scanBasePackageClasses
=
{
scanBasePackageClasses
=
{
CoralCommonCoreMarker
.
class
,
CoralCommonCoreMarker
.
class
,
CoralCommonWebMarker
.
class
,
CoralCommonWebMarker
.
class
,
Ci
h
aiCoreApplication
.
class
,
Ci
H
aiCoreApplication
.
class
,
CihaiJspApplication
.
class
,
CihaiJspApplication
.
class
,
})
})
@MapperScan
(
basePackageClasses
=
Ci
h
aiCoreApplication
.
class
)
@MapperScan
(
basePackageClasses
=
Ci
H
aiCoreApplication
.
class
)
@ServletComponentScan
(
basePackageClasses
=
{
@ServletComponentScan
(
basePackageClasses
=
{
CoralCommonWebMarker
.
class
,
CoralCommonWebMarker
.
class
,
CihaiJspApplication
.
class
,
CihaiJspApplication
.
class
,
Ci
h
aiCoreApplication
.
class
Ci
H
aiCoreApplication
.
class
})
})
@EnableCaching
@EnableCaching
public
class
CihaiJspApplication
extends
SpringBootServletInitializer
{
public
class
CihaiJspApplication
extends
SpringBootServletInitializer
{
...
...
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/HomeController.java
View file @
c72ee28
...
@@ -66,17 +66,18 @@ public class HomeController extends BaseController {
...
@@ -66,17 +66,18 @@ public class HomeController extends BaseController {
@RequestMapping
(
value
=
"/home/search"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/home/search"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
@ResponseBody
public
JsonResult
search
(
String
keyword
)
{
public
JsonResult
search
(
String
keyword
)
{
System
.
out
.
println
(
"进入搜索"
);
try
{
try
{
System
.
out
.
println
(
"keyword="
+
keyword
);
String
result
=
aipUtilBean
.
extractQueryKeyword
(
keyword
);
String
result
=
aipUtilBean
.
extractQueryKeyword
(
keyword
);
System
.
out
.
println
(
"搜索result"
+
result
);
ThemeQuery
query
=
new
ThemeQuery
();
ThemeQuery
query
=
new
ThemeQuery
();
query
.
setKeyword
(
keyword
);
query
.
setKeyword
(
result
);
ThemeDomain
themeDomain
=
themeService
.
getFirst
(
query
);
ThemeDomain
themeDomain
=
themeService
.
getFirst
(
query
);
if
(
themeDomain
==
null
)
return
errorResult
(
"暂无检索结果"
);
if
(
themeDomain
==
null
)
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
)
);
System
.
out
.
println
(
themeDomain
);
System
.
out
.
println
(
themeDomain
);
return
successResult
(
"success"
,
"/theme/detail/"
+
themeDomain
.
getId
());
return
successResult
(
"success"
,
"/theme/detail/"
+
themeDomain
.
getId
());
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
return
errorResult
(
"暂无检索结果"
);
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
)
);
}
}
}
}
}
}
serverside/cihai-wechat/src/main/webapp/WEB-INF/jsp/portal/home/index.jsp
View file @
c72ee28
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
<img src="${ctx}/static/images/logo-zhiyun.png">
<img src="${ctx}/static/images/logo-zhiyun.png">
</div>
</div>
<form class="search-area-inner">
<form class="search-area-inner">
<input class="form-control" type="text" placeholder="1,786,069 个语词">
<input class="form-control
j_search_input
" type="text" placeholder="1,786,069 个语词">
<a class="search-area-voice" type="button">
<a class="search-area-voice" type="button">
<span class="icon icon-microphone"></span>
<span class="icon icon-microphone"></span>
</a>
</a>
...
...
serverside/cihai-wechat/src/main/webapp/static/js/index.js
View file @
c72ee28
...
@@ -11,16 +11,6 @@ setTimeout(function () {
...
@@ -11,16 +11,6 @@ setTimeout(function () {
$loading
.
remove
();
$loading
.
remove
();
},
300
);
},
300
);
$
(
'.search-area-inner'
).
on
(
'click'
,
function
()
{
$
(
'.search-area-inner'
).
on
(
'click'
,
function
()
{
jQuery
.
get
(
"/home/search"
,{
keyword
:
"什么是十九大"
},
function
(
data
)
{
if
(
data
.
code
==
"OK"
){
myApp
.
view
.
main
.
router
.
load
({
url
:
data
.
data
});
}
else
{
myApp
.
dialog
.
alert
(
data
.
message
);
}
})
wx
.
startRecord
();
wx
.
startRecord
();
myApp
.
dialog
.
create
({
myApp
.
dialog
.
create
({
title
:
'正在录音...'
,
title
:
'正在录音...'
,
...
@@ -30,20 +20,22 @@ $('.search-area-inner').on('click', function () {
...
@@ -30,20 +20,22 @@ $('.search-area-inner').on('click', function () {
onClick
:
function
()
{
onClick
:
function
()
{
wx
.
stopRecord
({
wx
.
stopRecord
({
success
:
function
(
res
)
{
success
:
function
(
res
)
{
myApp
.
dialog
.
preloader
();
var
localId
=
res
.
localId
;
var
localId
=
res
.
localId
;
wx
.
translateVoice
({
wx
.
translateVoice
({
localId
:
localId
,
// 需要识别的音频的本地Id,由录音相关接口获得
localId
:
localId
,
// 需要识别的音频的本地Id,由录音相关接口获得
isShowProgressTips
:
0
,
// 默认为1,显示进度提示
isShowProgressTips
:
0
,
// 默认为1,显示进度提示
success
:
function
(
res
)
{
success
:
function
(
res
)
{
alert
(
res
.
translateResult
);
jQuery
.
get
(
"/home/search"
,{
keyword
:
res
.
translateResult
},
function
(
data
)
{
$
.
post
(
"/home/search"
,{
keyword
:
res
.
translateResult
},
function
(
data
)
{
myApp
.
dialog
.
close
();
alert
(
data
.
code
);
if
(
data
.
code
==
"OK"
){
if
(
data
.
code
==
"OK"
){
myApp
.
view
.
main
.
router
.
load
({
myApp
.
view
.
main
.
router
.
load
({
url
:
data
.
data
url
:
data
.
data
});
});
}
else
{
}
else
{
myApp
.
dialog
.
alert
(
data
.
message
);
myApp
.
dialog
.
alert
(
data
.
message
);
$
(
'.j_search_input'
).
val
(
res
.
translateResult
);
}
}
})
})
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment