fg电池监控平台的达梦数据库版本
whycxzp
2024-11-11 0f5f5e435cbc4c60ffad2bb84cfe8cc57ea32ddc
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.mapper.PageParamUserMapper;
import com.whyc.pojo.PageParamUser;
import com.whyc.pojo.UserInf;
import com.whyc.util.ActionUtil;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
@Service
public class PageParamUserService {
 
    @Resource
    private PageParamUserMapper mapper;
 
 
    public Map<Integer, List<PageParamUser>> getAllList(int type) {
        Long userId = ActionUtil.getUser().getUId();
        QueryWrapper<PageParamUser> wrapper = Wrappers.query();
        wrapper.eq("type",type).eq("user_id",userId);
        List<PageParamUser> pageParamList = mapper.selectList(wrapper);
        return pageParamList.stream().collect(Collectors.groupingBy(PageParamUser::getShow));
    }
 
    public List<PageParamUser> getList(int type) {
        Long userId = ActionUtil.getUser().getUId();
        QueryWrapper<PageParamUser> wrapper = Wrappers.query();
        wrapper.eq("type",type).eq("user_id",userId).eq("'show'",1);
        return mapper.selectList(wrapper);
    }
 
    public void updateList(List<PageParamUser> pageParamUserList, int operationFlag) {
        int userId = ActionUtil.getUser().getUId().intValue();
        pageParamUserList.stream().forEach(pageParamUser -> {
            pageParamUser.setUserId(userId);
            //pageParamUser.setLableEnUs(PageParamUserDTO.getLableEnUs(pageParamUser.getKey()));
        });
        mapper.updateList(pageParamUserList, operationFlag);
    }
 
    public void addList(List<PageParamUser> pageParamUserList) {
        Long userId = ActionUtil.getUser().getUId();
        pageParamUserList.stream().forEach(pageParamUser -> {
            pageParamUser.setUserId(userId.intValue());
            //pageParamUser.setLableEnUs(PageParamUserDTO.getLableEnUs(pageParamUser.getKey()));
        });
        mapper.insertBatchSomeColumn(pageParamUserList);
    }
 
    public void updateParamList(List<PageParamUser> pageParamUserList) {
        UserInf user = ActionUtil.getUser();
        if(pageParamUserList.get(0).getId() != null){ //更新
            mapper.updateListII(pageParamUserList);
        }else { //新增
            pageParamUserList.stream().forEach(pageParamUser -> {
                //pageParamUser.setLableEnUs(PageParamUserDTO.getLableEnUs(pageParamUser.getKey()));
                pageParamUser.setUserId(user.getUId().intValue());
            });
            mapper.insertBatchSomeColumn(pageParamUserList);
        }
    }
}