admin
2021-11-19 7511509c68bd2892aad48a0612d497387660214d
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
53
54
55
56
57
58
59
60
61
package com.yeshi.location.app.controller.admin;
 
import com.yeshi.location.app.entity.SystemEnum;
import com.yeshi.location.app.service.inter.AdminUserService;
import com.yeshi.location.app.utils.SystemInfoUtil;
import com.yeshi.location.app.vo.SystemVO;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yeshi.utils.JsonUtil;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
 
@Controller
@RequestMapping("/admin/api/system")
public class SystemController {
 
    @Resource
    private AdminUserService adminUserService;
 
    @ResponseBody
    @RequestMapping("systemList")
    public String systemList(HttpSession session) {
        List<SystemVO> systemVOList = new ArrayList<>();
        SystemVO selected = null;
        for (SystemEnum system : SystemEnum.values()) {
            SystemVO systemVO = new SystemVO(system.getName(), system.name(), system == SystemInfoUtil.getAdminSelectedSystem(session));
            if (systemVO.isSelected()) {
                selected = systemVO;
            }
            systemVOList.add(systemVO);
        }
 
        if (selected == null) {
            systemVOList.get(0).setSelected(true);
            SystemInfoUtil.saveAdminSelectedSystem(session, SystemEnum.valueOf(systemVOList.get(0).getKey()));
        }
 
 
        JSONObject data = new JSONObject();
        data.put("count", systemVOList.size());
        data.put("list", systemVOList);
        return JsonUtil.loadTrueResult(data);
    }
 
    @ResponseBody
    @RequestMapping("selectSystem")
    public String selectSystem(String key, HttpSession session) {
        if (SystemEnum.valueOf(key) == null) {
            return JsonUtil.loadFalseResult("选择失败,系统不存在");
        }
        SystemInfoUtil.saveAdminSelectedSystem(session, SystemEnum.valueOf(key));
        return JsonUtil.loadTrueResult("");
    }
 
 
}