审查视图

src/main/java/com/tianbo/warehouse/controller/RoleController.java 1.6 KB
1 2 3
package com.tianbo.warehouse.controller;

import com.github.pagehelper.PageInfo;
朱兆平 authored
4
import com.tianbo.warehouse.annotation.LogAnnotation;
5 6
import com.tianbo.warehouse.controller.response.ResultJson;
import com.tianbo.warehouse.model.ROLE;
朱兆平 authored
7
import com.tianbo.warehouse.model.RolePermission;
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
import com.tianbo.warehouse.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController()
public class RoleController {

    @Autowired
    RoleService roleService;

    @GetMapping("/role/list")
    public PageInfo<ROLE> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
                                        int pageNum,
                               @RequestParam(value = "pageSize",required = false,defaultValue = "5")
                                        int pageSize){
        return roleService.findAll(pageNum,pageSize);
    }
朱兆平 authored
26
    @LogAnnotation(moduleName = "角色管理",operate = "角色添加")
27 28 29
    @PostMapping("/role/add")
    public ResultJson add(@RequestBody ROLE role){
        int i =roleService.insertSelective(role);
朱兆平 authored
30
        return i==1 ? new ResultJson("200","添加权限成功") :new ResultJson("500","insert faild");
31 32 33

    }
朱兆平 authored
34 35 36 37 38 39 40 41 42 43
    /**
     * 设置角色的权限
     * @return
     */
    @LogAnnotation(moduleName = "角色管理",operate = "权限设置")
    @PutMapping("/role/permSet")
    public ResultJson permissionSet(@RequestBody RolePermission rolePermission){
        int i = roleService.setRolePermissoin(rolePermission);
        return i==1 ? new ResultJson("200","设置权限成功") :new ResultJson("500","设置权限失败");
    }
44
}