个股描述功能实现
1 个股描述功能实现说明
1)原型示意
2)接口说明
功能描述:个股主营业务查询接口
服务路径:/api/quot/stock/describe
服务方法:GET
请求参数:code #股票编码
响应参数:
{
“code”: 1,
“data”: {
“code”: “000002”, //股票编码
“trade”: "房地产 ", //行业,也就是行业板块名称
“business”: “房地产开发和物业服务”,//公司主营业务
“name”: “万科A” //公司名称
}
代码实现
1. 表现层
/**
* 个股描述功能实现
* @param code
* @return
*/
@ApiOperation(value = "个股描述功能实现", notes = "个股描述功能实现", httpMethod = "GET")
@GetMapping("stock/describe")
public R<StockDescribeDomain> getStockDescribe(@RequestParam(name = "code" , required = true) String code){
return service.getStockDescribe(code);
}
2. 服务层
R<StockDescribeDomain> getStockDescribe(@Param("code") String code);
/**
* 个股描述功能实现
* @param code
* @return
*/
@Override
public R<StockDescribeDomain> getStockDescribe(String code) {
// 从数据库中获取数据
StockDescribeDomain data = stockBusinessMapper.getStockDescribe(code);
return R.ok(data);
}
3. Dao层
StockDescribeDomain getStockDescribe(@Param("code") String code);
<select id="getStockDescribe" resultType="com.jixu.stock.pojo.domain.StockDescribeDomain">
select stock_code as code, stock_name as name, block_name as trade, business as business
from stock_business
where stock_code = #{code}
</select>