package com.blueland.render.rest;

import com.blueland.bo.DictEntity;
import com.blueland.bo.Org;
import com.blueland.bo.TucStaffEntity;
import com.blueland.result.R;
import com.blueland.service.SysRedisService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @auther xcy
 * @create 2022-06-15 11:05
 */
@RestController
@RequestMapping("/api/redis")
@ApiOperation("redis数据操作控制器")
public class RedisCacheController {

    @Autowired
    SysRedisService sysRedisService;

    @ApiOperation("初始化字典数据")
    @GetMapping("/initDict")
    public R initDict() {
        sysRedisService.initDict();
        return R.ok();
    }

    @ApiOperation("刷新字典数据")
    @GetMapping("/flushDict")
    public R flushDict() {
        sysRedisService.flushDict();
        return R.ok();
    }

    @ApiOperation("根据字典code,父级code获取数据，区分租户")
    @GetMapping("/getDictListByCode")
    public R<List<DictEntity>> getDictListByCode() {
        return R.ok(sysRedisService.getDictList());
    }

    @ApiOperation("根据redis key获取字典数据")
    @GetMapping("/getDictByRedisKey/{key}")
    public R<DictEntity> getDictByRedisKey(@PathVariable("key") String key) {
        return R.ok(sysRedisService.getDictByRedisKey(key));
    }

    @ApiOperation("初始化角色数据")
    @GetMapping("/initRole")
    public R initRole() {
        sysRedisService.initRole();
        return R.ok();
    }

    @ApiOperation("刷新角色数据")
    @GetMapping("/flushRole")
    public R flushRole() {
        sysRedisService.flushRole();
        return R.ok();
    }

    @ApiOperation("初始化菜单数据")
    @GetMapping("/initMenu")
    public R initMenu() {
        sysRedisService.initMenu();
        return R.ok();
    }

    @ApiOperation("刷新菜单数据")
    @GetMapping("/flushMenu")
    public R flushMenu() {
        sysRedisService.flushMenu();
        return R.ok();
    }

    @ApiOperation("初始化菜单id数据")
    @GetMapping("/initMenuId")
    public R initMenuId() {
        sysRedisService.initMenuId();
        return R.ok();
    }

    @ApiOperation("刷新菜单id数据")
    @GetMapping("/flushMenuId")
    public R flushMenuId() {
        sysRedisService.flushMenuId();
        return R.ok();
    }

    @ApiOperation("初始化员工数据")
    @GetMapping("/initStaff")
    public R initStaff() {
        sysRedisService.initStaff();
        return R.ok();
    }

    @ApiOperation("刷新员工数据")
    @GetMapping("/flushStaff")
    public R flushStaff() {
        sysRedisService.flushStaff();
        return R.ok();
    }

    @ApiOperation("获取员工集合，区分租户")
    @GetMapping("/getStaffList")
    public R<List<TucStaffEntity>> getStaffList() {
        return R.ok(sysRedisService.getStaffList());
    }

    @ApiOperation("初始化部门数据")
    @GetMapping("/initDept")
    public R initDept() {
        sysRedisService.initDept();
        return R.ok();
    }

    @ApiOperation("刷新部门数据")
    @GetMapping("/flushDept")
    public R flushDept() {
        sysRedisService.flushDept();
        return R.ok();
    }

    @ApiOperation("查询部门集合")
    @GetMapping("/getOrgList")
    public R<List<Org>> getOrgList() {
        return R.ok(sysRedisService.getOrgList());
    }

}
