package com.heketai.website.web;


import com.heketai.website.common.result.BaseResult;
import com.heketai.website.service.ISysRoleMenuService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 角色菜单关联表 前端控制器
 * </p>
 *
 * @author xjl
 * @since 2019-11-13
 */
@RestController
@RequestMapping("/sysRoleMenu")
public class SysRoleMenuController {

    @Autowired
    private ISysRoleMenuService roleMenuService;

    @Autowired
    private RedisTemplate redisTemplate;
    private String fKey = "4BAF93F9-FE61-8F5E7435-501C2D5011C2";

    @RequestMapping("/distributionMenu")
    @ApiOperation(value = "给角色分配菜单", notes = "给角色分配菜单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色id", required = true, paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "menuIds", value = "菜单ids", required = true, paramType = "query")
    })
    public BaseResult distributionMenu(@RequestParam Integer roleId, @RequestParam String menuIds) {
        roleMenuService.distributionMenu(roleId, menuIds);
        redisTemplate.delete(fKey);
        return BaseResult.success();
    }

}
