zj
2024-06-03 81a29edf665881828e4ca1f0e444bfcbc6ab6f24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.nq.service.impl;
 
import java.util.List;
 
import com.nq.dao.StockMapper;
import com.nq.dao.StockPreMapper;
import com.nq.pojo.Stock;
import com.nq.pojo.StockPre;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nq.service.IStockPreService;
 
/**
 * 盘前交易Service业务层处理
 *
 * @author xt
 * @date 2024-03-18
 */
@Service
public class StockPreServiceImpl implements IStockPreService
{
    @Autowired
    private StockPreMapper stockPreMapper;
    @Autowired
    private StockMapper stockMapper;
 
    /**
     * 查询盘前交易
     *
     * @param id 盘前交易ID
     * @return 盘前交易
     */
    @Override
    public StockPre selectStockPreById(Long id)
    {
        return stockPreMapper.selectStockPreById(id);
    }
 
    /**
     * 查询盘前交易列表
     *
     * @param stockPre 盘前交易
     * @return 盘前交易
     */
    @Override
    public List<StockPre> selectStockPreList(StockPre stockPre)
    {
        return stockPreMapper.selectStockPreList(stockPre);
    }
 
    /**
     * 新增盘前交易
     *
     * @param stockPre 盘前交易
     * @return 结果
     */
    @Override
    public int insertStockPre(StockPre stockPre)
    {
        return stockPreMapper.insertStockPre(stockPre);
    }
 
    /**
     * 修改盘前交易
     *
     * @param stockPre 盘前交易
     * @return 结果
     */
    @Override
    public int updateStockPre(StockPre stockPre)
    {
        return stockPreMapper.updateStockPre(stockPre);
    }
 
    /**
     * 批量删除盘前交易
     *
     * @param ids 需要删除的盘前交易ID
     * @return 结果
     */
    @Override
    public int deleteStockPreByIds(Long[] ids)
    {
        return stockPreMapper.deleteStockPreByIds(ids);
    }
 
    /**
     * 删除盘前交易信息
     *
     * @param id 盘前交易ID
     * @return 结果
     */
    @Override
    public int deleteStockPreById(Long id)
    {
        StockPre dbStockPre = stockPreMapper.selectStockPreById(id);
        int result = stockPreMapper.deleteStockPreById(id);
        if (result>0){
            Stock dbStock = stockMapper.selectByStockCode(dbStockPre.getStockCode());
            dbStock.setEnablePre(0);
            stockMapper.updateByPrimaryKeySelective(dbStock);
        }
        return result;
    }
 
    @Override
    public int enableStockPre(StockPre stockPre) {
        Stock paramStock = new Stock();
        paramStock.setStockCode(stockPre.getStockCode());
        paramStock.setEnablePre(1);
        stockMapper.updateByCodeSelective(paramStock);
        return stockPreMapper.insertStockPre(stockPre);
    }
}