| | |
| | | private DictService dictService; |
| | | |
| | | public MapDataParam getMapData(MapQueryParam param, Long userId) { |
| | | |
| | | String mapKey = getMapKey(param.getFloor()); |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey)); |
| | | if (Cools.isEmpty(dict)) { |
| | |
| | | } else { |
| | | return JSON.parseObject(dict.getValue(), MapDataParam.class) ; |
| | | } |
| | | |
| | | |
| | | // User user = userService.getById(userId); |
| | | // if (Cools.isEmpty(user.getMemo())) { |
| | | // return new MapDataParam(); |
| | | // } |
| | | // return JSON.parseObject(user.getMemo(), MapDataParam.class); |
| | | } |
| | | |
| | | public void saveMapData(MapDataParam param, Long userId) { |
| | | |
| | | String mapKey = getMapKey(param.getFloor()); |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey)); |
| | | if (Cools.isEmpty(dict)) { |
| | |
| | | dict.setFlag(mapKey); |
| | | dict.setType(DictType.JSON.flag); |
| | | dict.setValue(JSON.toJSONString(param.getItemList())); |
| | | dict.setCreateBy(userId); |
| | | dict.setUpdateBy(userId); |
| | | if (!dictService.save(dict)) { |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | } else { |
| | | dict.setValue(JSON.toJSONString(param.getItemList())); |
| | | dict.setUpdateTime(new Date()); |
| | | dict.setUpdateBy(userId); |
| | | if (!dictService.updateById(dict)) { |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | } |
| | | |
| | | // |
| | | // User user = userService.getById(userId); |
| | | // user.setMemo(JSON.toJSONString(param)); |
| | | // if (!userService.updateById(user)) { |
| | | // throw new CoolException("服务器内部错误"); |
| | | // } |
| | | } |
| | | |
| | | |
| | | private String getMapKey(Integer floor) { |
| | | if (null != floor) { |