彭雪彬
2025-07-14 c1d20b425b10e8ba59f102dd1ab413055883eed0
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
package com.oying.modules.system.service.impl;
 
import com.oying.modules.system.domain.UserStore;
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.system.service.UserStoreService;
import com.oying.modules.system.domain.dto.UserStoreQueryCriteria;
import com.oying.modules.system.mapper.UserStoreMapper;
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 lixin
* @date 2025-06-16
**/
@Service
@RequiredArgsConstructor
public class UserStoreServiceImpl extends ServiceImpl<UserStoreMapper, UserStore> implements UserStoreService {
 
    private final UserStoreMapper userStoreMapper;
 
    @Override
    public PageResult<UserStore> queryAll(UserStoreQueryCriteria criteria, Page<Object> page){
        return PageUtil.toPage(userStoreMapper.findAll(criteria, page));
    }
 
    @Override
    public List<UserStore> queryAll(UserStoreQueryCriteria criteria){
        return userStoreMapper.findAll(criteria);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void create(UserStore resources) {
        userStoreMapper.insert(resources);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(UserStore resources) {
        UserStore userStore = getById(resources.getUserId());
        userStore.copy(resources);
        userStoreMapper.updateById(userStore);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteAll(List<Long> ids) {
        userStoreMapper.deleteBatchIds(ids);
    }
 
    @Override
    public void download(List<UserStore> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (UserStore userStore : all) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("角色类型", userStore.getRoleType());
            map.put("权限集(备用)", userStore.getPermissions());
            map.put("创建者", userStore.getCreateBy());
            map.put("创建时间", userStore.getCreateTime());
            map.put("更新者", userStore.getUpdateBy());
            map.put("更新时间", userStore.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}