| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.StockMapper; |
| | | import com.nq.pojo.Stock; |
| | | import com.nq.pojo.StockSubscribe; |
| | | import com.nq.service.IStockSubscribeService; |
| | | import com.nq.dao.StockSubscribeMapper; |
| | |
| | | implements IStockSubscribeService { |
| | | @Autowired |
| | | StockSubscribeMapper stockSubscribeMapper; |
| | | @Autowired |
| | | StockMapper stockMapper; |
| | | |
| | | /** |
| | | * @Description: 用户新股列表 |
| | |
| | | public ServerResponse add(StockSubscribe model, HttpServletRequest request) { |
| | | //判断是否已经存在 |
| | | log.info("model:{}", model); |
| | | Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, model.getCode())); |
| | | if(null == stock){ |
| | | return ServerResponse.createByErrorMsg("股票代码不存在!"); |
| | | } |
| | | List<StockSubscribe> stockSubscribeList = this.stockSubscribeMapper.selectList(new QueryWrapper<StockSubscribe>().eq("code", model.getCode())); |
| | | if (stockSubscribeList != null && stockSubscribeList.size() > 0) { |
| | | return ServerResponse.createByErrorMsg("新股已经存在,不要重复添加"); |
| | | } |
| | | // String sinaStock = SinaStockApi.getInStockDetail(model.getCode()); |
| | | // String[] arrayOfString = sinaStock.split(","); |
| | | // if (arrayOfString.length < 10) |
| | | // return ServerResponse.createByErrorMsg("数据源无该新股"); |
| | | //添加新股 |
| | | int resultCount = this.stockSubscribeMapper.insert(model); |
| | | if (resultCount > 0) { |