leomon
2025-05-14 3387f6754a07694dda1307849a3ab6fe8a24d7c5
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
package com.oying.modules.message.service.impl;
 
import com.oying.modules.message.domain.MessageBuyer;
import com.oying.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oying.modules.message.service.MessageBuyerService;
import com.oying.modules.message.domain.dto.MessageBuyerQueryCriteria;
import com.oying.modules.message.mapper.MessageBuyerMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.oying.utils.PageUtil;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import com.oying.utils.PageResult;
 
/**
* @description 服务实现
* @author 李萌
* @date 2025-05-14
**/
@Service
@RequiredArgsConstructor
public class MessageBuyerServiceImpl extends ServiceImpl<MessageBuyerMapper, MessageBuyer> implements MessageBuyerService {
 
    private final MessageBuyerMapper messageBuyerMapper;
 
    @Override
    public PageResult<MessageBuyer> queryAll(MessageBuyerQueryCriteria criteria, Page<Object> page){
        return PageUtil.toPage(messageBuyerMapper.findAll(criteria, page));
    }
 
    @Override
    public List<MessageBuyer> queryAll(MessageBuyerQueryCriteria criteria){
        return messageBuyerMapper.findAll(criteria);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void create(MessageBuyer resources) {
        messageBuyerMapper.insert(resources);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(MessageBuyer resources) {
        MessageBuyer messageBuyer = getById(resources.getBuyerMessageId());
        messageBuyer.copy(resources);
        messageBuyerMapper.updateById(messageBuyer);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteAll(List<Long> ids) {
        messageBuyerMapper.deleteBatchIds(ids);
    }
 
    @Override
    public void download(List<MessageBuyer> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (MessageBuyer messageBuyer : all) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("买家ID", messageBuyer.getBuyerId());
            map.put("外键,关联 `message_info` 表", messageBuyer.getMessageId());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}