rzg
2020-12-31 ab62b1a237dd6ae92c97ec6d6def79f8ae04372d
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
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import javax.annotation.Resource;
 
@RequestMapping("customPage")
@RestController
@Api
public class CustompageController{
    
    @Resource
    private CustompageService service;
    
    // private Custompage cust;
 
    //页面定制下添加导航或者子页面
    @PostMapping("/")
    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("/")
    public ServiceModel update(@RequestBody List<Custompage> list) {
        // List<Custompage> list = ActionUtil.getGson().fromJson(result, new TypeToken<ArrayList<Custompage>>(){}.getType() );
        ServiceModel model=service.update(list);        
        
        return model;
    }
    //页面定制修改主导航下子页面的顺序
    @PutMapping("order")
    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("/")
    public ServiceModel delete(@RequestBody Custompage cust) {
        ServiceModel model=service.delete(cust);
        
        return model;
    }
 
    @GetMapping("byCondition")
    public ServiceModel serchByCondition(@RequestBody Custompage cust){
        // cust=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result,Custompage.class);
        ServiceModel model=service.serchByCondition(cust);
        
        //System.out.println(result);
        return model;
    }
 
    //查询所有的菜单(页面定制可以看到的子菜单和子模块)
    @GetMapping("all")
    public ServiceModel searchAll(){
        ServiceModel model=service.searchAll();
        setCust(model);
        
        return model;
    }
 
    //根据主导航的名字查询所有的子页面
    @GetMapping("byInfo")
    public ServiceModel serchByInfo(@RequestBody Custompage cust){
        // cust=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result,Custompage.class);
        ServiceModel model=service.serchByInfo(cust);
        
        return model;
    }
    //将导航对象数组存入session
    @PostMapping("custom2Session")
    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()));
        }
    }
    
}