#
luxiaotao1123
2024-03-21 35ddd0428b9824fceb33d59811bf2c0022dd309e
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
package com.zy.asrs.wcs.core.map.service;
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.map.controller.param.MapDataParam;
import com.zy.asrs.wcs.core.map.controller.param.MapQueryParam;
import com.zy.asrs.wcs.system.entity.Dict;
import com.zy.asrs.wcs.system.entity.User;
import com.zy.asrs.wcs.system.service.DictService;
import com.zy.asrs.wcs.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
/**
 * Created by vincent on 3/15/2024
 */
@Service
public class MapService {
 
    @Autowired
    private UserService userService;
    @Autowired
    private DictService dictService;
 
    public MapDataParam getMapData(MapQueryParam param, Long userId) {
 
        String dictFlag = "map-" + param.getFloor();
        Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, dictFlag));
        if (Cools.isEmpty(dict)) {
            return null;
        } 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) {
        User user = userService.getById(userId);
        user.setMemo(JSON.toJSONString(param));
        if (!userService.updateById(user)) {
            throw new CoolException("服务器内部错误");
        }
    }
 
}