package com.neusoft.smart.pos.gateway.controller;

import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.gateway.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/unionService/redis")
public class RedisController {

    @Autowired
    private RedisService redisService;

    @GetMapping("/load2Redis")
    public String load() throws InterruptedException {
        redisService.load2Redis();
        return "OK";
    }

    @GetMapping("/loadUserData2Redis")
    public ResponseData loadUserData2Redis() {
        redisService.loadUserData2Redis();
        return new ResponseData();
    }

    @GetMapping("/loadUserData2RedisByShop")
    public ResponseData loadUserData2RedisByShop(@RequestParam(required = false) Integer shopId, @RequestParam(required = false) Integer orgId) {
        redisService.loadUserData2Redis(shopId, orgId);
        return new ResponseData();
    }
}
