whyczh
2021-12-10 1ab06fa644b400182dde1621c60f904c4711f2b6
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.mapper.PageParamMapper;
import com.whyc.pojo.PageParam;
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 PageParamService {
 
    @Resource
    private PageParamMapper mapper;
 
    public Map<Integer, List<PageParam>> getAllList(int categoryId) {
        QueryWrapper<PageParam> wrapper = Wrappers.query();
        wrapper.eq("categoryId",categoryId);
        List<PageParam> pageParamList = mapper.selectList(wrapper);
        return pageParamList.stream().collect(Collectors.groupingBy(PageParam::getStatus));
    }
 
    public List<PageParam> getList(int categoryId) {
        QueryWrapper<PageParam> wrapper = Wrappers.query();
        wrapper.eq("categoryId",categoryId).eq("status",1);
        return mapper.selectList(wrapper);
    }
 
    public void updateList(List<PageParam> pageParamList, int operationFlag) {
        //添加
        mapper.updateList(pageParamList,operationFlag);
    }
 
    public void addList(List<PageParam> pageParamList) {
        mapper.insertBatchSomeColumn(pageParamList);
    }
}