whycrzg
2021-02-03 f628be11a131a262855908b7815c3027d6bafb4c
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.fgkj.controller;
 
import com.fgkj.util.*;
 
import com.fgkj.dto.Custompage;
import com.fgkj.dto.ServiceModel;
import com.fgkj.services.CustompageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import javax.annotation.Resource;
 
@RequestMapping("customPage")
@RestController
@Api(tags = "customPage接口")
public class CustompageController{
    
    @Resource
    private CustompageService service;
    
    // private Custompage cust;
 
    //页面定制下添加导航或者子页面
    @PostMapping("/")
    @ApiOperation(notes = "",value="页面定制下添加导航或者子页面")
    public ServiceModel add(@RequestBody Custompage cust) {
        // cust=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result,Custompage.class);
        ServiceModel model=service.add(cust);
        
        return model;
    }
 
    //页面定制可以看到的子菜单和子模块
    @PutMapping("/")
    @ApiOperation(notes = "[{ \"num\": 78, \"subflag\": 0, \"subenable\": 0 }]",value="页面定制可以看到的子菜单和子模块")
    public ServiceModel update(@RequestBody List<Custompage> list) {
 
        ServiceModel model = service.update(list);
        return model;
    }
 
 
    //页面定制修改主导航下子页面的顺序
    @PutMapping("order")
    @ApiOperation(notes = "[{ \"num\": 78, \"page_order\": 0 }]",value="页面定制修改主导航下子页面的顺序")
    public ServiceModel updateOrder(@RequestBody List<Custompage> list) {
        // List<Custompage> list = ActionUtil.getGson().fromJson(result, new TypeToken<ArrayList<Custompage>>(){}.getType() );
        ServiceModel model=service.updateOrder(list);        
        
        
        return model;
    }
 
    @DeleteMapping("/")
    @ApiOperation(notes = "未完成功能",value="删除")
    public ServiceModel delete() {
//        Custompage cust = new Custompage();
//        ServiceModel model = service.delete(cust);
 
        return  new ServiceModel();
    }
 
    @PostMapping("byCondition")
    @ApiOperation(notes = "",value="页面查询子模块/子菜单")
    public ServiceModel serchByCondition(@RequestParam String navigate,@RequestParam Integer subjudge) {
        Custompage cust = new Custompage();
        cust.setNavigate(navigate);
        cust.setSubjudge(subjudge);
        ServiceModel model = service.serchByCondition(cust);
 
        return model;
    }
 
    //查询所有的菜单(页面定制可以看到的子菜单和子模块)
    @GetMapping("all")
    @ApiOperation(notes = "",value="查询所有的菜单(页面定制可以看到的子菜单和子模块)")
    public ServiceModel searchAll(){
        ServiceModel model=service.searchAll();
        setCust(model);
        
        return model;
    }
 
    //根据主导航的名字查询所有的子页面
    @PostMapping("byInfo")
    @ApiOperation(notes = "",value="主导航的名字查询所有的子页")
    public ServiceModel serchByInfo(@RequestParam String navigate){
        // "navigate": "Monitor_data"
        Custompage cust = new Custompage();
        cust.setNavigate(navigate);
        ServiceModel model=service.serchByInfo(cust);
        
        return model;
    }
 
 
    //将导航对象数组存入session
    @PostMapping("custom2Session")
    @ApiOperation(notes = "参数:{ \"code\": 0, \"msg\": \"\", \"data\": {} } 返回值类型void",value="将导航对象数组存入session")
    public static void setCust(ServiceModel obj) {
        if (obj != null) {
            ServiceModel model = (ServiceModel) obj;
            ActionUtil.getSession().setAttribute("custompages", model.getData());
            ActionUtil.getSession().setAttribute("custompages_json", ActionUtil.tojson(model.getData()));
        }
    }
    
}