股票Code联想推荐
1 股票Code联想推荐功能介绍
1) 原型效果
输入框输入股票编码后,显示关联的股票信息;
2)接口定义说明
接口说明:
功能描述:根据输入的个股代码,进行模糊查询,返回证券代码和证券名称
服务路径:/quot/stock/search
服务方法:GET
请求参数:searchStr (只接受代码模糊查询,不支持文字查询)
响应数据格式:
{
"code": 1,
"data": [
{
"code": "600000",//股票编码
"name": "浦发银行" //股票名称
},
{
"code": "600004",
"name": "白云机场"
}
]
}
代码实现
1. 表现层
/**
* 股票Code联想推荐功能
* @param searchStr
* @return
*/
@ApiOperation(value = "股票Code联想推荐功能", notes = "股票Code联想推荐功能", httpMethod = "GET")
@GetMapping("/stock/search")
public R<List<CodeSearchDomain>> codeSearch(@RequestParam(name = "searchStr" , required = false ,defaultValue = "0") String searchStr){
return service.stockCodeSearch(searchStr);
}
2. 服务层
R<List<CodeSearchDomain>> stockCodeSearch(@Param("searchStr") String searchStr);
/**
* 股票Code联想推荐功能
* @param searchStr
* @return
*/
@Override
public R<List<CodeSearchDomain>> stockCodeSearch(String searchStr) {
// 获取所有股票信息
List<CodeSearchDomain> businessMsg = stockBusinessMapper.getMsg(searchStr);
return R.ok(businessMsg);
}
3. Dao层
List<CodeSearchDomain> getMsg(@Param("searchStr") String searchStr);
<select id="getMsg" resultType="com.jixu.stock.pojo.domain.CodeSearchDomain">
select stock_code as code ,
stock_name as name
from stock_business
where stock_code like concat('%', #{searchStr}, '%')
</select>