xuekang
2024-05-13 15a0280ae9e7db96fdf0744c722d214d2cb5a0e5
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package com.nuvole.four.service.impl;
 
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.nuvole.base.domain.SysUser;
import com.nuvole.four.contants.Contants;
import com.nuvole.four.domain.ChannelInfo;
import com.nuvole.four.domain.dto.ChannelInfoDto;
import com.nuvole.four.mapper.ChannelInfoMapper;
import com.nuvole.four.service.ChannelInfoService;
import com.nuvole.four.util.SystemUtil;
import com.nuvole.util.IdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * @Desc: 通道信息ServiceImpl
 * @Author: dqh
 * @Date: 2024-04-09
 **/
@Slf4j
@Service
public class ChannelInfoServiceImpl implements ChannelInfoService {
    @Autowired
    private ChannelInfoMapper channelInfoMapper;
    @Override
    public List<ChannelInfo> getList(Map map) {
        return null;
    }
 
    /**
     * 方法描述:查询通道列表
     **/
    @Override
    public List<ChannelInfo> getList(ChannelInfo channelInfo) {
        return channelInfoMapper.selectAll(channelInfo);
    }
 
    /**
     * 方法描述:分页查询通道列表
     **/
    @Override
    public List<ChannelInfoDto> getPageList(ChannelInfo channelInfo) {
        return channelInfoMapper.getPageList(channelInfo);
    }
 
    @Override
    public List<Map> getListOfMap(Map map) {
        return null;
    }
 
    @Override
    public List<Map> getListOfMap(ChannelInfo channelInfo) {
        return null;
    }
 
    @Override
    public Integer save(ChannelInfo channelInfo) {
        return null;
    }
 
    /**
     * 方法描述: 新增通道
     *
     * @date  2024-04-11 14:39
     **/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer saveChannelInfo(ChannelInfo channelInfo) {
        ChannelInfo codeExists = channelInfoMapper.checkChannelCode(channelInfo.getChannelCode());
        if(codeExists != null){
            throw new IllegalArgumentException("通道code重复");
        }
        /*
         * 解析extendJson的字符串字段转为json存储
         *
         **/
        if(StrUtil.isNotEmpty(channelInfo.getExtendJson())){
            Object object = JSON.parse(channelInfo.getExtendJson());
            if(object instanceof JSONArray){
                channelInfo.setExtendJson(channelInfo.getExtendJson());
            }
        }
        channelInfo.setId(IdGenerator.getId());
        channelInfo.setCreateTime(new Date());
        SysUser user = SystemUtil.getLoginUser(Contants.LOGIN_TYPE_PC);
        channelInfo.setCreateBy(user.getId());
        channelInfo.setStatus(0);
        return channelInfoMapper.insert(channelInfo);
    }
 
    /**
     * 方法描述: 修改通道
     *
     * @date  2024-04-11 14:38
     **/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer updateChannelInfo(ChannelInfo channelInfo) {
        ChannelInfo codeExists = channelInfoMapper.checkChannelCode(channelInfo.getChannelCode());
        if(codeExists != null && !codeExists.getId().equals(channelInfo.getId())){
            throw new IllegalArgumentException("通道code重复");
        }
        /*
         * 解析extendJson的字符串字段转为json存储
         *
         **/
        if(StrUtil.isNotEmpty(channelInfo.getExtendJson())){
            Object object = JSON.parse(channelInfo.getExtendJson());
            if(object instanceof JSONArray){
                channelInfo.setExtendJson(channelInfo.getExtendJson());
            }
        }
        channelInfo.setUpdateTime(new Date());
        SysUser user = SystemUtil.getLoginUser(Contants.LOGIN_TYPE_PC);
        channelInfo.setUpdateBy(user.getId());
        return channelInfoMapper.updateByPrimaryKeySelective(channelInfo);
    }
 
    /**
     * 方法描述:根据id查询通道详情
     *
     * @date  2024-04-11 14:40
     **/
    @Override
    public ChannelInfo getChannelInfo(Long id) {
        return channelInfoMapper.selectByPrimaryKey(id);
    }
/**
     * 方法描述:根据code查询通道
     *
     * @date  2024-04-11 14:40
     **/
    @Override
    public ChannelInfo getDetailByCode(String channelCode) {
        return channelInfoMapper.checkChannelCode(channelCode);
    }
 
    @Override
    public Integer update(ChannelInfo channelInfo) {
        return null;
    }
 
    @Override
    public Integer del(Long id) {
        return null;
    }
 
    @Override
    public ChannelInfo getById(Long id) {
        return null;
    }
 
}