package cn.com.countrygarden.bi.main.controller.ck;

import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.model.ck.CkCleanerFileidRole;
import cn.com.countrygarden.bi.main.service.ck.CkCleanerFileidRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


/**
 * @Description:    字段配置角色表-业务逻辑层实现
 * @author  木木子
 * @email 944528607@qq.com
 * @date  2020/5/13  14:23
 */
@RestController("CkCleanerFileidRoleController")
@RequestMapping("/api/ckCleanerFileidRole")
public class CkCleanerFileidRoleController extends BaseController {
    @Autowired
    private CkCleanerFileidRoleService ckCleanerFileidRoleService;

    @GetMapping(value = "/tree", produces = "application/json;charset=utf-8")
    public Result tree(CkCleanerFileidRole ckCleanerFileidRole,
                       HttpServletRequest request){
        return   Response.response(ckCleanerFileidRoleService.tree(ckCleanerFileidRole));
    }

    @GetMapping(value = "/cktree", produces = "application/json;charset=utf-8")
    public Result cktree(CkCleanerFileidRole ckCleanerFileidRole,
                         @RequestParam(value = "role", required = false) String role,
                       HttpServletRequest request){
        return   Response.response(ckCleanerFileidRoleService.cktree(ckCleanerFileidRole,role));
    }

    @PostMapping(value = "/addOrEdit")
    public Result addOrEdit(@RequestParam(value = "data") String data,@RequestParam(value = "roleCode",required = true) String roleCode,HttpServletRequest request) {
        return   Response.response(ckCleanerFileidRoleService.addOrEdit(roleCode,data, getAccessToken(request)));
    }
    @GetMapping(value = "/checkedKeys")
    public Result checkedKeys(@RequestParam(value = "roleCode",required = false) String roleCode,HttpServletRequest request) {
        return   Response.response(ckCleanerFileidRoleService.checkedKeys(roleCode, getAccessToken(request)));
    }


}