KKSU
2024-04-07 49fe390d3e59b22a20cd520da3c520c2ee670ebb
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
package cc.mrbird.febs.dapp.service.impl;
 
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.DataDicEnum;
import cc.mrbird.febs.dapp.entity.DappCoinPrice;
import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
import cc.mrbird.febs.dapp.entity.PlatformBanner;
import cc.mrbird.febs.dapp.mapper.DappCoinPriceMapper;
import cc.mrbird.febs.dapp.mapper.DappHdRecordMapper;
import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.dapp.mapper.PlatformBannerMapper;
import cc.mrbird.febs.dapp.service.AsyncCjService;
import cc.mrbird.febs.dapp.service.IAdminBannerService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
 
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional
public class AdminBannerServiceImpl extends ServiceImpl<PlatformBannerMapper, PlatformBanner> implements IAdminBannerService {
 
    private final PlatformBannerMapper platformBannerMapper;
    private final DappCoinPriceMapper dappCoinPriceMapper;
    private final DappHdRecordMapper dappHdRecordMapper;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final AsyncCjService asyncCjService;
 
    @Override
    public IPage<PlatformBanner> findPlatformBannerInPage(PlatformBanner platformBannerEntity,
                                                          QueryRequest request) {
        Page<PlatformBanner> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<PlatformBanner> platformBannerEntitys = platformBannerMapper.findPlatformBannerInPage(page, platformBannerEntity);
        return platformBannerEntitys;
    }
 
    @Override
    public PlatformBanner selectPlatformBannerById(long id) {
        PlatformBanner platformBannerEntity = platformBannerMapper.selectById(id);
        return platformBannerEntity;
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public FebsResponse platformBannerConfirm(@Valid PlatformBanner platformBannerEntity) {
        platformBannerMapper.updateById(platformBannerEntity);
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public FebsResponse platformBannerDelete(@NotNull(message = "{required}") Long id) {
        platformBannerMapper.deleteById(id);
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void platformBannerAdd(@Valid PlatformBanner platformBannerEntity) {
        PlatformBanner platformBannerEntityAdd = new PlatformBanner();
        platformBannerEntityAdd.setImageUrl(platformBannerEntity.getImageUrl());
        platformBannerEntityAdd.setIsInside(platformBannerEntity.getIsInside());
        platformBannerEntityAdd.setIsJump(platformBannerEntity.getIsJump());
        platformBannerEntityAdd.setIsTop(platformBannerEntity.getIsTop());
        platformBannerEntityAdd.setJumpUrl(platformBannerEntity.getJumpUrl());
        platformBannerEntityAdd.setName(platformBannerEntity.getName());
        platformBannerEntityAdd.setShowPort(platformBannerEntity.getShowPort());
        platformBannerEntityAdd.setSort(platformBannerEntity.getSort());
        platformBannerMapper.insert(platformBannerEntityAdd);
 
    }
 
    @Override
    public IPage<DappCoinPrice> findCoinPriceInPage(DappCoinPrice dappCoinPrice, QueryRequest request) {
        Page<DappCoinPrice> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<DappCoinPrice> platformBannerEntitys = dappHdRecordMapper.findCoinPriceInPage(page, dappCoinPrice);
        return platformBannerEntitys;
    }
 
    @Override
    public FebsResponse coinPriceAdd(String price) {
        BigDecimal bigDecimal = new BigDecimal(price).setScale(8, BigDecimal.ROUND_DOWN);
        DappCoinPrice dappCoinPrice = new DappCoinPrice();
        dappCoinPrice.setPrice(bigDecimal);
        dappCoinPriceMapper.insert(dappCoinPrice);
        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDicEnum.GFA_PRICE.getValue(),
                DataDicEnum.GFA_PRICE.getValue()
        );
 
        dataDictionaryCustom.setValue(bigDecimal.toString());
        dataDictionaryCustomMapper.updateById(dataDictionaryCustom);
 
        asyncCjService.redisCacheUpdate(DataDicEnum.GFA_PRICE.getValue(),bigDecimal.toString(),0);
        return new FebsResponse().success();
    }
}