kimi42345
2020-03-22 d0451fdd55195901e65e5c4b3b64028a86f9e669
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
package com.highdatas.mdm.controller;
 
 
import com.highdatas.mdm.entity.MenuMapping;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.IMaintainDetailService;
import com.highdatas.mdm.service.IMaintainService;
import com.highdatas.mdm.service.IMenuMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kimi
 * @since 2019-12-16
 */
@RestController
@RequestMapping("/menuMapping")
public class MenuMappingController {
 
    @Autowired
    IMenuMappingService menuMappingService;
 
    @Autowired
    IMaintainService maintainService;
 
    @Autowired
    IMaintainDetailService maintainDetailService;
 
    @RequestMapping(value = "/get/{id}",  method = RequestMethod.GET)
    public Result<MenuMapping> get(@PathVariable String id, HttpServletRequest request) {
        return menuMappingService.getMapping(request.getSession(),id);
    }
 
 
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result<Object> insert(@RequestParam String data, HttpServletRequest request) {
        HttpSession session = request.getSession();
        MenuMapping inserted = menuMappingService.create(data, session);
        if (inserted != null) {
            return  Result.success(inserted);
        } else {
            return Result.error(CodeMsg.INSERT_ERROR);
        }
 
    }
 
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result<Object> update(@RequestParam String data) throws Exception {
        boolean updated =menuMappingService.update(data);
        if (updated) {
            return  Result.success("更新成功", null);
        } else {
            return Result.error(CodeMsg.UPDATE_ERROR);
        }
    }
 
    @RequestMapping(value = "/delete/{menuid}", method = RequestMethod.GET)
    public Result<Object> delete(@PathVariable String menuid) throws Exception {
        boolean deleted = menuMappingService.deleteById(menuid);
        if (deleted) {
            return  Result.success("删除成功", null);
        } else {
            return Result.error(CodeMsg.DELETE_ERROR);
        }
    }
 
}