package com.buy507.mall.controller;

import com.buy507.mall.common.api.CommonPage;
import com.buy507.mall.common.api.CommonResult;
import com.buy507.mall.model.TmsPermission;
import com.buy507.mall.model.TmsRolelist;
import com.buy507.mall.service.TmsRolelistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "TmsRolelistController", description = "系统角色列表")
@RequestMapping("/TmsRolelist")
public class TmsRolelistController {
    @Autowired
    private TmsRolelistService Service;

    @ApiOperation("分页查询角色列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<TmsRolelist>> list(
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {

        List<TmsRolelist> list = Service.list(pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(list));
    }


    @ApiOperation("角色权限查询")
    @RequestMapping(value = "/user/PermissionList", method = RequestMethod.GET)
    public CommonResult<List<TmsPermission>> bankAccountList(
            @RequestParam(value = "Id", required = true) Long Id) {
        List<TmsPermission> list = Service.PermissionList(Id);
        return CommonResult.success(list);
    }
}
