bingbo
2023-11-24 ace7066780453a7a70dbaa3700de9a761f38ca87
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
package com.thhy.screen.config;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.utils.StringUtils;
import com.thhy.screen.modules.biz.audio.entity.AudioGroup;
import com.thhy.screen.modules.biz.bigscreen.mapper.BigScreenMapper;
import com.thhy.screen.utils.AudioUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
 
import java.util.List;
 
@Configuration
public class StartListener implements ApplicationRunner {
 
    @Autowired
    private BigScreenMapper screenMapper;
 
    @Override
    public void run(ApplicationArguments args) throws Exception {
        String result = AudioUtils.getGroups();
        if(StringUtils.isEmpty(result)){
            return;
        }
        JSONObject groupJSON = JSON.parseObject(result);
        List<AudioGroup> groupList = JSON.parseArray(groupJSON.getString("Groups"),AudioGroup.class);
        for(AudioGroup ag : groupList){
            screenMapper.insertAudioGroup(ag);
        }
    }
}