UpgradeController.java 1.59 KB
package vion.controller.monitor;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.model.monitor.Upgrade;
import vion.service.monitor.IUpgradeService;

/**
 * 升级包管理
 */
@RestController
@RequestMapping("/api/upgrade")
@RequiredArgsConstructor
public class UpgradeController {

    private final IUpgradeService upgradeService;

    @GetMapping
    @SaCheckPermission(value = "upgrade:list", orRole = "admin")
    public Page<Upgrade> list(Upgrade upgrade) {
        return upgradeService.lambdaQuery(upgrade)
                .orderByDesc(Upgrade::getBuildTime)
                .page(Page.of(upgrade.getPageNum(), upgrade.getPageSize()));
    }

    @GetMapping("/{id}")
    @SaCheckPermission(value = "upgrade:query", orRole = "admin")
    public Upgrade get(@PathVariable Long id) {
        return upgradeService.getById(id);
    }

    @PostMapping
    @SaCheckPermission(value = "upgrade:save", orRole = "admin")
    public String save(Upgrade upgrade) {
        return upgradeService.saveAndFile(upgrade);
    }

    @PostMapping("/{id}")
    @SaCheckPermission(value = "upgrade:edit", orRole = "admin")
    public String update(@PathVariable Long id, Upgrade upgrade) {
        upgrade.setId(id);
        return upgradeService.update(upgrade);
    }

    @DeleteMapping("/{id}")
    @SaCheckPermission(value = "upgrade:remove", orRole = "admin")
    public String remove(@PathVariable Long id) {
        return upgradeService.remove(id);
    }
}