package com.aidex.web.controller.system;

import com.aidex.common.annotation.Log;
import com.aidex.common.constant.Constants;
import com.aidex.common.core.controller.BaseController;
import com.aidex.common.core.domain.R;
import com.aidex.common.core.redis.RedisCache;
import com.aidex.common.enums.BusinessType;
import com.alibaba.fastjson2.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

/**
 * 航线保存查询-Redis
 * @author ChenSir
 * @email 914769835
 * @date 2024-03-16
 */
@RestController
@RequestMapping("/system/sysRouter")
public class SysRouteController extends BaseController {

    @Autowired
    private RedisCache  redisCache;


    /**
     * 获取码头管理详细信息
     */
    @GetMapping
    public R<JSONArray> detail() {
        JSONArray data = new JSONArray();
        data = redisCache.getCacheObject(Constants.ROUTE_STORE_PREFIX);
        return R.data(data);
    }

    /**
     * 新增码头管理
     */
    @Log(title = "航线管理", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  JSONArray data) {
        redisCache.setCacheObject(Constants.ROUTE_STORE_PREFIX ,data);
        return R.status(redisCache.hasKey(Constants.ROUTE_STORE_PREFIX));
    }









}
