Commit c72ee280 by 石头

首页整合

1 parent 5d4f5306
......@@ -7,11 +7,12 @@ import com.dookay.coral.common.core.persistence.criteria.QueryCriteria;
import com.dookay.cihai.core.theme.domain.ThemeDomain;
/**
* 专题
* @author wangwei
* @since 2017年12月06日
* @version V1.0
*/
* 专题
*
* @author wangwei
* @version V1.0
* @since 2017年12月06日
*/
@Data
public class ThemeQuery extends Query {
......@@ -22,8 +23,8 @@ public class ThemeQuery extends Query {
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));
String str = keyword + "%";
criteria.andCondition(String.format("(title like '%s' or FIND_IN_SET('%s',sub_title))", str, keyword));
}
//todo 写查询逻辑
return queryCriteria;
......
package com.dookay.cihai.wechat;
import com.dookay.cihai.core.CihaiCoreApplication;
import com.dookay.cihai.core.CiHaiCoreApplication;
import com.dookay.coral.common.core.CoralCommonCoreMarker;
import com.dookay.coral.common.web.CoralCommonWebMarker;
import org.mybatis.spring.annotation.MapperScan;
......@@ -22,14 +22,14 @@ import org.springframework.cache.annotation.EnableCaching;
scanBasePackageClasses = {
CoralCommonCoreMarker.class,
CoralCommonWebMarker.class,
CihaiCoreApplication.class,
CiHaiCoreApplication.class,
CihaiJspApplication.class,
})
@MapperScan(basePackageClasses = CihaiCoreApplication.class)
@MapperScan(basePackageClasses = CiHaiCoreApplication.class)
@ServletComponentScan(basePackageClasses = {
CoralCommonWebMarker.class,
CihaiJspApplication.class,
CihaiCoreApplication.class
CiHaiCoreApplication.class
})
@EnableCaching
public class CihaiJspApplication extends SpringBootServletInitializer {
......
......@@ -66,17 +66,18 @@ public class HomeController extends BaseController {
@RequestMapping(value = "/home/search", method = RequestMethod.GET)
@ResponseBody
public JsonResult search(String keyword) {
System.out.println("进入搜索");
try {
System.out.println("keyword="+keyword);
String result = aipUtilBean.extractQueryKeyword(keyword);
System.out.println("搜索result"+result);
ThemeQuery query = new ThemeQuery();
query.setKeyword(keyword);
query.setKeyword(result);
ThemeDomain themeDomain = themeService.getFirst(query);
if (themeDomain == null) return errorResult("暂无检索结果");
if (themeDomain == null) return errorResult(String.format("暂无\"%s\"检索结果",keyword));
System.out.println(themeDomain);
return successResult("success", "/theme/detail/" + themeDomain.getId());
} catch (Exception ex) {
return errorResult("暂无检索结果");
return errorResult(String.format("暂无\"%s\"检索结果",keyword));
}
}
}
......@@ -38,7 +38,7 @@
<img src="${ctx}/static/images/logo-zhiyun.png">
</div>
<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">
<span class="icon icon-microphone"></span>
</a>
......
......@@ -11,16 +11,6 @@ setTimeout(function () {
$loading.remove();
},300);
$('.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();
myApp.dialog.create({
title: '正在录音...',
......@@ -30,20 +20,22 @@ $('.search-area-inner').on('click', function () {
onClick:function () {
wx.stopRecord({
success: function (res) {
myApp.dialog.preloader();
var localId = res.localId;
wx.translateVoice({
localId: localId, // 需要识别的音频的本地Id,由录音相关接口获得
isShowProgressTips: 0, // 默认为1,显示进度提示
success: function (res) {
alert(res.translateResult);
$.post("/home/search",{keyword:res.translateResult},function (data) {
alert(data.code);
jQuery.get("/home/search",{keyword:res.translateResult},function (data) {
myApp.dialog.close();
if(data.code=="OK"){
myApp.view.main.router.load({
url:data.data
});
}else{
myApp.dialog.alert(data.message);
$('.j_search_input').val(res.translateResult);
}
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!