package com.fjhx.apk.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.apk.service.ApkVersionService;
import com.fjhx.entity.apk.ApkVersion;
import com.fjhx.params.apk.ApkVersionVo;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-10-19
 */
@RestController
@RequestMapping("/apkVersion")
public class ApkVersionController {

    @Autowired
    private ApkVersionService apkVersionService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, String> condition) {
        Page<ApkVersion> result = apkVersionService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody ApkVersionVo apkVersionVo) {
        apkVersionService.add(apkVersionVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ApkVersionVo apkVersionVo) {
        apkVersionService.edit(apkVersionVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ApkVersionVo apkVersionVo) {
        apkVersionService.delete(apkVersionVo);
        return R.success();
    }

    /**
     * 获取最新版本
     */
    @PostMapping("/getNewestVersion")
    public R getNewestVersion(@RequestBody ApkVersionVo apkVersionVo) {
        ApkVersion result = apkVersionService.getNewestVersion(apkVersionVo);
        return R.success(result);
    }

}

