package org.springblade.modules.app.web.admin;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wn.common.datamodel.ResultDTO;
import org.springblade.modules.app.common.dto.AppVersionDTO;
import org.springblade.modules.app.common.query.AppVersionQuery;
import org.springblade.modules.app.common.query.LatestAppVersionQuery;
import org.springblade.modules.app.manager.AppVersionManager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import com.wn.common.controller.BaseController;

/**
 * <p>
 * app版本管理表 前端控制器
 * </p>
 *
 * @author huyinuo
 * @since 2022-02-23
 */
@RestController
@RequestMapping("app/admin/app/version")
public class AdminAppVersionController extends BaseController {

    @Autowired
    private AppVersionManager appVersionManger;

    @GetMapping("/page")
    //@ApiOperation(value = "分页查询app版本列表")
    public ResponseEntity<ResultDTO<Page<AppVersionDTO>>> pageAppVersion(AppVersionQuery appVersionQuery) {
        return success(appVersionManger.pageAppVersion(appVersionQuery));
    }

    @GetMapping("/{id}")
    //@ApiOperation(value = "获取app版本详情")
    public ResponseEntity<ResultDTO<AppVersionDTO>> getAppVersion(@PathVariable Long id) {
        return success(appVersionManger.getAppVersion(id));
    }

    @PostMapping
    //@ApiOperation(value = "新增app版本信息")
    public ResponseEntity<ResultDTO<Long>> addAppVersion(@RequestBody AppVersionDTO appVersionDTO) {
        return success(appVersionManger.addAppVersion(appVersionDTO));
    }

    @PutMapping
    //@ApiOperation(value = "修改app版本信息")
    public ResponseEntity<ResultDTO<Boolean>> updateAppVersion(@RequestBody AppVersionDTO appVersionDTO) {
        return success(appVersionManger.updateAppVersion(appVersionDTO));
    }

    @GetMapping("/latest")
    //@ApiOperation(value = "查询最新app版本信息")
    public ResponseEntity<ResultDTO<AppVersionDTO>> latestAppVersion(LatestAppVersionQuery latestAppVersionQuery) {
        return success(appVersionManger.latestVersion(latestAppVersionQuery));
    }
}

