package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.github.pagehelper.PageInfo;
|
import com.whyc.dto.Response;
|
import com.whyc.factory.TableInitFactory;
|
import com.whyc.mapper.PageParam2Mapper;
|
import com.whyc.mapper.PageParamMapper;
|
import com.whyc.pojo.PageParam;
|
import com.whyc.pojo.PageParam2;
|
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;
|
@Resource
|
private PageParam2Mapper param2Mapper;
|
|
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);
|
}
|
|
//在线监测-查询拓扑图状态的显示/查询控制信息
|
public Response findByCategoryId(int categoryId) {
|
boolean res=mapper.exist();
|
List<PageParam> listparam= TableInitFactory.getPageParamInit();
|
if(!res) { //表不存在,新建表,同时初始化参数
|
mapper.createTable();
|
mapper.init(listparam);
|
}else {
|
int count=mapper.getCount();
|
if(count==0){
|
boolean inited = mapper.init(listparam);
|
}
|
}
|
|
List list=mapper.findByCategoryId(categoryId);
|
PageInfo pageInfo=new PageInfo(list);
|
return new Response().set(1,pageInfo);
|
}
|
|
public Response update(int id,int status){
|
//如果id为40(账号登录失败限制次数),status的取值范围必须为1~10
|
if(id == 40 && (status < 1 || status >10)){
|
return new Response().set(1,false,"账号登录失败限制次数不在1~10范围内,修改失败");
|
}
|
int flag = mapper.update(id,status);
|
return new Response().set(1,flag>0?true:false);
|
}
|
|
|
public Response updateParamById(PageParam param){
|
if (mapper.updateById(param)>0){
|
return new Response().set(1,true,"更新成功");
|
}else {
|
return new Response().set(1, false,"更新失败");
|
}
|
}
|
|
public Response getListByCategoryId(int categoryId){
|
QueryWrapper<PageParam2> queryWrapper = new QueryWrapper();
|
queryWrapper.eq("categoryId",categoryId);
|
List<PageParam2> param2List = param2Mapper.selectList(queryWrapper);
|
if (param2List.size()==1){
|
return new Response().set(1,param2List.get(0));
|
}else {
|
return new Response().set(1,param2List);
|
}
|
}
|
|
public Response updateAudiCap(PageParam2 pageParam2){
|
int flag = param2Mapper.updateById(pageParam2);
|
return new Response().set(1,flag>0?true:false,"更新成功");
|
}
|
|
}
|