package com.ebts.web.controller.system;

import com.ebts.common.core.entity.Result;
import com.ebts.system.service.SequenceService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author 18209
 * @Date 2021/2/24 17:52
 * @Version 1.0
 */
@RestController
@RequestMapping("/seq")
public class SequenceController {

    @Resource
    private SequenceService sequenceService;

    @PreAuthorize("@ebts.hasPermi('sequence:curr')")
    @GetMapping("/curr/{tableName}")
    public Result<Long> currval(@PathVariable String tableName){
        return Result.ok(sequenceService.currVal(tableName));
    }

    @PreAuthorize("@ebts.hasPermi('sequence:next')")
    @GetMapping("/next/{tableName}")
    public Result<Long> nextval(@PathVariable String tableName){
        return Result.ok(sequenceService.nextVal(tableName));
    }

}
