package com.hssx.pcbms.controller;


import com.hssx.pcbms.entity.Permission;
import com.hssx.pcbms.entity.User;
import com.hssx.pcbms.service.PermissionService;
import com.hssx.pcbms.util.HttpRespMsg;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 吴涛涛
 * @since 2019-10-24
 */
@Controller
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    /**
     * 权限添加
     * 参数：permissionName 权限名称（填对应英文）如 下载：dowload
     *       describe:权限的描述
     * @return
     */
    @ApiOperation(value = "权限添加", notes = "权限添加方法")
    @RequestMapping("/add")
    @ResponseBody
    public HttpRespMsg add(Permission permission) {
        HttpRespMsg msg = permissionService.add(permission);
        return msg;
    }

    /**
     * 权限添加
     * 参数：id :权限对应的id
     * @return
     */
    @ApiOperation(value = "权限删除", notes = "权限删除方法")
    @RequestMapping("/del")
    @ResponseBody
    public HttpRespMsg del(Permission permission) {
        HttpRespMsg msg = permissionService.del(permission);
        return msg;
    }

    /**
     * 权限列表
     * @return
     */
    @ApiOperation(value = "权限列表", notes = "权限列表方法")
    @RequestMapping("/list")
    @ResponseBody
    public HttpRespMsg list() {
        HttpRespMsg msg = new HttpRespMsg();
        msg.data =  permissionService.list();
        return msg;
    }
}

