Commit 0767928c by 侯昆

commit

1 parent 04701e41
package com.dookay.cihai.core;
import com.dookay.coral.common.core.CoralCommonCoreMarker;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -12,7 +11,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
CoralCommonCoreMarker.class,
CiHaiCoreApplication.class
})
@MapperScan(basePackageClasses = CiHaiCoreApplication.class)
public class CiHaiCoreApplication {
public static void main(String[] args) {
......
package com.dookay.cihai.core.word.domain;
import lombok.Data;
import java.io.Serializable;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;
/**
* 自定义词条
* @author wangwei
* @since 2017年12月07日
* @version V1.0
*/
@Data
@Table(name = "t_custom_dictionary")
public class CustomDictionaryDomain implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
private Long id;
/**
*
*/
private String word;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
}
package com.dookay.cihai.core.word.mapper;
import com.dookay.coral.common.core.persistence.Mapper;
import com.dookay.cihai.core.word.domain.CustomDictionaryDomain;
/**
* 自定义词条
* @author wangwei
* @since 2017年12月07日
* @version V1.0
*/
public interface CustomDictionaryMapper extends Mapper<CustomDictionaryDomain> {
}
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.CustomDictionaryDomain;
/**
* 自定义词条
* @author wangwei
* @since 2017年12月07日
* @version V1.0
*/
@Data
public class CustomDictionaryQuery extends Query {
private String word;
@Override
public QueryCriteria toCriteria() {
QueryCriteria queryCriteria = new QueryCriteria(CustomDictionaryDomain.class);
Example.Criteria criteria = queryCriteria.createCriteria();
if (valid(word)) {
criteria.andEqualTo("word");
}
//todo 写查询逻辑
return queryCriteria;
}
}
package com.dookay.cihai.core.word.service;
import com.dookay.coral.common.core.service.IBaseService;
import com.dookay.cihai.core.word.domain.CustomDictionaryDomain;
/**
* @author wangwei
* @since 2017年12月07日
* @version V1.0
*/
public interface ICustomDictionaryService extends IBaseService<CustomDictionaryDomain> {
}
package com.dookay.cihai.core.word.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dookay.coral.common.core.service.impl.BaseServiceImpl;
import com.dookay.cihai.core.word.mapper.CustomDictionaryMapper;
import com.dookay.cihai.core.word.domain.CustomDictionaryDomain;
import com.dookay.cihai.core.word.service.ICustomDictionaryService;
/**
* 自定义词条
* @author wangwei
* @since 2017年12月07日
* @version V1.0
*/
@SuppressWarnings("ALL")
@Service("customDictionaryService")
public class CustomDictionaryServiceImpl extends BaseServiceImpl<CustomDictionaryDomain> implements ICustomDictionaryService {
@Autowired
private CustomDictionaryMapper customDictionaryMapper;
}
......@@ -24,6 +24,9 @@
<property name="smallint" value="Boolean"/>
</javaTypeResolver>
<table tableName="t_custom_dictionary" domainObjectName="CustomDictionary"
packageName="com.dookay.cihai.core.word" desc="自定义字典" author="wangwei">
</table>
<table tableName="t_word" domainObjectName="Word"
packageName="com.dookay.cihai.core.word" desc="词条" author="wangwei">
</table>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.dookay.cihai.core.word.mapper.CustomDictionaryMapper" >
<!-- 公共查询语句 -->
<sql id="selectSql">
select
<trim suffixOverrides="," >
a.`id` as 'id',
a.`word` as 'word',
a.`create_time` as 'createTime',
a.`update_time` as 'updateTime',
</trim>
from
`t_custom_dictionary` as a
</sql>
</mapper>
\ No newline at end of file
......@@ -18,8 +18,11 @@ import com.dookay.cihai.core.aip.AipWordUtilBean;
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.CustomDictionaryDomain;
import com.dookay.cihai.core.word.domain.WordDomain;
import com.dookay.cihai.core.word.query.CustomDictionaryQuery;
import com.dookay.cihai.core.word.query.WordQuery;
import com.dookay.cihai.core.word.service.ICustomDictionaryService;
import com.dookay.cihai.core.word.service.IWordService;
import com.dookay.coral.common.web.controller.BaseController;
import com.dookay.coral.common.web.response.JsonResult;
......@@ -43,6 +46,8 @@ public class HomeController extends BaseController {
@Autowired
private IThemeService themeService;
@Autowired
private ICustomDictionaryService customDictionaryService;
@Autowired
private AipWordUtilBean aipWordUtilBean;
......@@ -70,7 +75,7 @@ public class HomeController extends BaseController {
try {
String result = aipWordUtilBean.extractQueryKeyword(keyword);
ThemeQuery query = new ThemeQuery();
query.setKeyword(keyword);
query.setKeyword(result);
ThemeDomain themeDomain = themeService.getFirst(query);
if (themeDomain == null) return errorResult("暂无检索结果");
System.out.println(themeDomain);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!