Commit c5867c98 by 石头

首页整合

1 parent e741f194
package com.dookay.cihai.core.theme.domain; package com.dookay.cihai.core.theme.domain;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -8,11 +9,12 @@ import java.util.Date; ...@@ -8,11 +9,12 @@ import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 专题 * 专题
* @author wangwei *
* @since 2017年12月06日 * @author wangwei
* @version V1.0 * @version V1.0
*/ * @since 2017年12月06日
*/
@Data @Data
@Table(name = "t_theme") @Table(name = "t_theme")
public class ThemeDomain implements Serializable { public class ThemeDomain implements Serializable {
...@@ -30,6 +32,9 @@ public class ThemeDomain implements Serializable { ...@@ -30,6 +32,9 @@ public class ThemeDomain implements Serializable {
*/ */
private String title; private String title;
private String subTitle;
/** /**
* *
*/ */
......
package com.dookay.cihai.core.theme.query; package com.dookay.cihai.core.theme.query;
import com.dookay.coral.common.core.persistence.Query; import com.dookay.coral.common.core.persistence.Query;
import lombok.Data;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import com.dookay.coral.common.core.persistence.criteria.QueryCriteria; 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;
...@@ -11,13 +12,19 @@ import com.dookay.cihai.core.theme.domain.ThemeDomain; ...@@ -11,13 +12,19 @@ import com.dookay.cihai.core.theme.domain.ThemeDomain;
* @since 2017年12月06日 * @since 2017年12月06日
* @version V1.0 * @version V1.0
*/ */
@Data
public class ThemeQuery extends Query { public class ThemeQuery extends Query {
private String keyword;
@Override @Override
public QueryCriteria toCriteria() { public QueryCriteria toCriteria() {
QueryCriteria queryCriteria = new QueryCriteria(ThemeDomain.class); QueryCriteria queryCriteria = new QueryCriteria(ThemeDomain.class);
Example.Criteria criteria = queryCriteria.createCriteria(); 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 写查询逻辑 //todo 写查询逻辑
return queryCriteria; return queryCriteria;
} }
......
package com.dookay.cihai.core.word.query; package com.dookay.cihai.core.word.query;
import com.dookay.coral.common.core.persistence.Query; import com.dookay.coral.common.core.persistence.Query;
import lombok.Data;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import com.dookay.coral.common.core.persistence.criteria.QueryCriteria; import com.dookay.coral.common.core.persistence.criteria.QueryCriteria;
import com.dookay.cihai.core.word.domain.WordDomain; import com.dookay.cihai.core.word.domain.WordDomain;
/** /**
* 词条 * 词条
* @author wangwei *
* @since 2017年12月06日 * @author wangwei
* @version V1.0 * @version V1.0
*/ * @since 2017年12月06日
*/
@Data
public class WordQuery extends Query { public class WordQuery extends Query {
private String keyword;
@Override @Override
public QueryCriteria toCriteria() { public QueryCriteria toCriteria() {
QueryCriteria queryCriteria = new QueryCriteria(WordDomain.class); QueryCriteria queryCriteria = new QueryCriteria(WordDomain.class);
Example.Criteria criteria = queryCriteria.createCriteria(); Example.Criteria criteria = queryCriteria.createCriteria();
if (valid(keyword)) {
}
//todo 写查询逻辑 //todo 写查询逻辑
return queryCriteria; return queryCriteria;
} }
......
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* NO BUG ENJOY LIFE *
* *
****************************************/
package com.dookay.cihai.wechat.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
* @author 石磊
* @date 2017/12/7
*/
@EnableWebSecurity
@Order
public class WechatSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
}
}
...@@ -14,12 +14,20 @@ ...@@ -14,12 +14,20 @@
package com.dookay.cihai.wechat.controller; package com.dookay.cihai.wechat.controller;
import com.dookay.cihai.core.aip.AipUtilBean;
import com.dookay.cihai.core.theme.domain.ThemeDomain;
import com.dookay.cihai.core.theme.query.ThemeQuery;
import com.dookay.cihai.core.theme.service.IThemeService;
import com.dookay.cihai.core.word.domain.WordDomain;
import com.dookay.cihai.core.word.query.WordQuery;
import com.dookay.cihai.core.word.service.IWordService; import com.dookay.cihai.core.word.service.IWordService;
import com.dookay.coral.common.web.controller.BaseController; import com.dookay.coral.common.web.controller.BaseController;
import com.dookay.coral.common.web.response.JsonResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
/** /**
...@@ -33,6 +41,12 @@ public class HomeController extends BaseController { ...@@ -33,6 +41,12 @@ public class HomeController extends BaseController {
@Autowired @Autowired
private IWordService wordService; private IWordService wordService;
@Autowired
private IThemeService themeService;
@Autowired
private AipUtilBean aipUtilBean;
/** /**
* @author 石磊 * @author 石磊
* @date 2017/12/6 * @date 2017/12/6
...@@ -49,10 +63,20 @@ public class HomeController extends BaseController { ...@@ -49,10 +63,20 @@ public class HomeController extends BaseController {
* @date 2017/12/6 * @date 2017/12/6
* @description 搜索 * @description 搜索
*/ */
@RequestMapping(value="/serach",method = RequestMethod.GET) @RequestMapping(value = "/home/search", method = RequestMethod.GET)
public ModelAndView search(String keyword) { @ResponseBody
public JsonResult search(String keyword) {
ModelAndView mv = new ModelAndView(""); System.out.println("进入搜索");
return mv; try {
String result = aipUtilBean.extractQueryKeyword(keyword);
ThemeQuery query = new ThemeQuery();
query.setKeyword(keyword);
ThemeDomain themeDomain = themeService.getFirst(query);
if (themeDomain == null) return errorResult("暂无检索结果");
System.out.println(themeDomain);
return successResult("success", "/theme/detail/" + themeDomain.getId());
} catch (Exception ex) {
return errorResult("暂无检索结果");
}
} }
} }
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* NO BUG ENJOY LIFE *
* *
****************************************/
package com.dookay.cihai.wechat.controller;
import com.dookay.cihai.core.theme.domain.ThemeDomain;
import com.dookay.cihai.core.theme.service.IThemeService;
import com.dookay.coral.common.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
/**
* @author 石磊
* @date 2017/12/6
*/
@Controller
@RequestMapping(value = "/theme")
public class ThemeController extends BaseController {
@Autowired
private IThemeService themeService;
/**
* @author 石磊
* @date 2017/12/6
* @description 详情
*/
@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
public ModelAndView detail(@PathVariable Long id) {
ThemeDomain themeDomain = themeService.get(id);
ModelAndView mv = new ModelAndView("portal/theme/detail");
mv.addObject("theme", themeDomain);
return mv;
}
}
...@@ -28,3 +28,7 @@ coral.wechat.WechatConfig.encodingAESKey=agkC7tsPUoOtbbUyxxcCLVJZVqVOCTeJgxUCXAx ...@@ -28,3 +28,7 @@ coral.wechat.WechatConfig.encodingAESKey=agkC7tsPUoOtbbUyxxcCLVJZVqVOCTeJgxUCXAx
# 是否加密 # 是否加密
coral.wechat.WechatConfig.messageEncrypt=false coral.wechat.WechatConfig.messageEncrypt=false
# 微信授权回调地址 # 微信授权回调地址
aip.app-id=10486245
aip.api-key=ws8qdxT51xm2qbWufxzRedI3
aip.secret-key=8b6g9ZyR69dFl6aqYdIOGa4IbOGgkdjh
\ No newline at end of file \ No newline at end of file
...@@ -30,3 +30,4 @@ coral.web.view.error.internal-error=500 ...@@ -30,3 +30,4 @@ coral.web.view.error.internal-error=500
coral.web.view.error.service=service coral.web.view.error.service=service
coral.web.view.error.other=other coral.web.view.error.other=other
...@@ -54,19 +54,3 @@ ...@@ -54,19 +54,3 @@
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="/wechat/jsConfig"></script> <script src="/wechat/jsConfig"></script>
<jsp:include page="/WEB-INF/jsp/include/footer.jsp"/> <jsp:include page="/WEB-INF/jsp/include/footer.jsp"/>
<script>
$(function () {
function touchstart(){
alert('d');
e.preventDefault();
}
$('#voice').click(function (e) {
e.preventDefault();
})
})
</script>
\ No newline at end of file \ No newline at end of file
...@@ -11,6 +11,16 @@ setTimeout(function () { ...@@ -11,6 +11,16 @@ 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: '正在录音...',
...@@ -19,20 +29,23 @@ $('.search-area-inner').on('click', function () { ...@@ -19,20 +29,23 @@ $('.search-area-inner').on('click', function () {
text: '完成', text: '完成',
onClick:function () { onClick:function () {
wx.stopRecord({ wx.stopRecord({
success: function (res) { success: function (res) {
var localId = res.localId; var localId = res.localId;
wx.translateVoice({ wx.translateVoice({
localId: localId, // 需要识别的音频的本地Id,由录音相关接口获得 localId: localId, // 需要识别的音频的本地Id,由录音相关接口获得
isShowProgressTips: 0, // 默认为1,显示进度提示
isShowProgressTips: 1, // 默认为1,显示进度提示
success: function (res) { success: function (res) {
alert(res.translateResult);
$.post("/home/search",{keyword:res.translateResult},function (data) {
alert(data.code);
if(data.code=="OK"){
myApp.view.main.router.load({ myApp.view.main.router.load({
url:'/home/search?keyword='+res.translateResult url:data.data
}); });
}else{
myApp.dialog.alert(data.message);
}
})
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!