Commit c5867c98 by 石头

首页整合

1 parent e741f194
package com.dookay.cihai.core.theme.domain;
import lombok.Data;
import java.io.Serializable;
import javax.persistence.Id;
import javax.persistence.Table;
......@@ -8,11 +9,12 @@ import java.util.Date;
import java.util.List;
/**
* 专题
* @author wangwei
* @since 2017年12月06日
* @version V1.0
*/
* 专题
*
* @author wangwei
* @version V1.0
* @since 2017年12月06日
*/
@Data
@Table(name = "t_theme")
public class ThemeDomain implements Serializable {
......@@ -30,6 +32,9 @@ public class ThemeDomain implements Serializable {
*/
private String title;
private String subTitle;
/**
*
*/
......
package com.dookay.cihai.core.theme.query;
import com.dookay.coral.common.core.persistence.Query;
import lombok.Data;
import tk.mybatis.mapper.entity.Example;
import com.dookay.coral.common.core.persistence.criteria.QueryCriteria;
import com.dookay.cihai.core.theme.domain.ThemeDomain;
......@@ -11,13 +12,19 @@ import com.dookay.cihai.core.theme.domain.ThemeDomain;
* @since 2017年12月06日
* @version V1.0
*/
@Data
public class ThemeQuery extends Query {
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 sub_title like '%s')", str, str));
}
//todo 写查询逻辑
return queryCriteria;
}
......
package com.dookay.cihai.core.word.query;
import com.dookay.coral.common.core.persistence.Query;
import lombok.Data;
import tk.mybatis.mapper.entity.Example;
import com.dookay.coral.common.core.persistence.criteria.QueryCriteria;
import com.dookay.cihai.core.word.domain.WordDomain;
/**
* 词条
* @author wangwei
* @since 2017年12月06日
* @version V1.0
*/
* 词条
*
* @author wangwei
* @version V1.0
* @since 2017年12月06日
*/
@Data
public class WordQuery extends Query {
private String keyword;
@Override
public QueryCriteria toCriteria() {
QueryCriteria queryCriteria = new QueryCriteria(WordDomain.class);
Example.Criteria criteria = queryCriteria.createCriteria();
if (valid(keyword)) {
}
//todo 写查询逻辑
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 @@
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.coral.common.web.controller.BaseController;
import com.dookay.coral.common.web.response.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
/**
......@@ -33,6 +41,12 @@ public class HomeController extends BaseController {
@Autowired
private IWordService wordService;
@Autowired
private IThemeService themeService;
@Autowired
private AipUtilBean aipUtilBean;
/**
* @author 石磊
* @date 2017/12/6
......@@ -49,10 +63,20 @@ public class HomeController extends BaseController {
* @date 2017/12/6
* @description 搜索
*/
@RequestMapping(value="/serach",method = RequestMethod.GET)
public ModelAndView search(String keyword) {
ModelAndView mv = new ModelAndView("");
return mv;
@RequestMapping(value = "/home/search", method = RequestMethod.GET)
@ResponseBody
public JsonResult search(String keyword) {
System.out.println("进入搜索");
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
# 是否加密
coral.wechat.WechatConfig.messageEncrypt=false
# 微信授权回调地址
aip.app-id=10486245
aip.api-key=ws8qdxT51xm2qbWufxzRedI3
aip.secret-key=8b6g9ZyR69dFl6aqYdIOGa4IbOGgkdjh
\ No newline at end of file
......@@ -30,3 +30,4 @@ coral.web.view.error.internal-error=500
coral.web.view.error.service=service
coral.web.view.error.other=other
......@@ -54,19 +54,3 @@
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="/wechat/jsConfig"></script>
<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
......@@ -11,6 +11,16 @@ 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: '正在录音...',
......@@ -19,20 +29,23 @@ $('.search-area-inner').on('click', function () {
text: '完成',
onClick:function () {
wx.stopRecord({
success: function (res) {
var localId = res.localId;
wx.translateVoice({
localId: localId, // 需要识别的音频的本地Id,由录音相关接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
isShowProgressTips: 0, // 默认为1,显示进度提示
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({
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!