Authored by qinchao

Merge branch 'test6.8.3' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.3

package com.yohoufo.dal.product;
import com.yohoufo.dal.product.model.SearchWord;
import org.apache.ibatis.annotations.Param;
import java.util.List;
... ... @@ -8,5 +9,5 @@ import java.util.List;
* Created by li.ma on 2018/9/27.
*/
public interface SearchWordMapper {
List<SearchWord> selectAll();
List<SearchWord> selectAll(@Param("clientType")Integer clientType, @Param("wordType")Integer wordType);
}
... ...
... ... @@ -10,6 +10,14 @@
</resultMap>
<select id="selectAll" resultMap="BaseResultMap">
select id, search_word, order_by, create_time, update_time from hot_search_word order by order_by DESC
select id, search_word, order_by, create_time, update_time from hot_search_word
where 1 = 1
<if test="clientType != null">
AND (client_type = #{clientType, jdbcType=INTEGER} or client_type = 2)
</if>
<if test="wordType != null">
AND word_type = #{wordType, jdbcType=INTEGER}
</if>
order by order_by DESC LIMIT 20
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
... ... @@ -23,6 +24,10 @@ public class HotSearchWordController {
private final Logger LOG = LoggerFactory.getLogger(HotSearchWordController.class);
private final Integer CLIENT_TYPE_APP = 0; // APP端
private final Integer WORD_TYPE_HOT = 0; // 热搜词
@Autowired
private HotSearchWordService hotSearchWordService;
... ... @@ -31,9 +36,19 @@ public class HotSearchWordController {
@IgnoreSession
@RequestMapping(params = "method=ufo.product.searchWord")
@Cachable(expire = 180)
public ApiResponse querySearchWord() {
LOG.info("in method=ufo.product.searchWord");
List<SearchWordResp> resp = hotSearchWordService.querySearchWord();
public ApiResponse querySearchWord(@RequestParam(value = "client_type", required = false) Integer clientType,
@RequestParam(value = "word_type", required = false) Integer wordType) {
LOG.info("in method=ufo.product.searchWord clientType is {}, wordType is {}", clientType, wordType);
if (null == clientType) {
clientType = CLIENT_TYPE_APP;
}
if (null == wordType) {
wordType = WORD_TYPE_HOT;
}
List<SearchWordResp> resp = hotSearchWordService.querySearchWord(clientType, wordType);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("热搜词列表").build();
}
}
... ...
... ... @@ -17,8 +17,8 @@ public class HotSearchWordService {
@Autowired
private SearchWordMapper searchWordMapper;
public List<SearchWordResp> querySearchWord() {
List<SearchWord> searchWords = searchWordMapper.selectAll();
public List<SearchWordResp> querySearchWord(Integer clientType, Integer wordType) {
List<SearchWord> searchWords = searchWordMapper.selectAll(clientType, wordType);
List<SearchWordResp> result = new ArrayList<>();
... ...