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);
|
}
|
}
|
}
|