|
|
@@ -0,0 +1,140 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package com.store.goods.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.store.goods.entity.AppVersion;
|
|
|
+import com.store.goods.service.IAppVersionService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.store.goods.entity.App;
|
|
|
+import com.store.goods.vo.AppVO;
|
|
|
+import com.store.goods.service.IAppService;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * app应用表 控制器
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2021-12-13
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/app")
|
|
|
+@Api(value = "app应用管理", tags = "app应用表接口")
|
|
|
+public class AppController extends BladeController {
|
|
|
+
|
|
|
+ private final IAppService appService;
|
|
|
+
|
|
|
+ private final IAppVersionService appVersionService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ */
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "查看app应用", notes = "传入app")
|
|
|
+ public R<App> detail(App app) {
|
|
|
+ App detail = appService.getOne(Condition.getQueryWrapper(app));
|
|
|
+ //获取全部的版本记录
|
|
|
+ List<AppVersion> list = appVersionService.list(new LambdaQueryWrapper<AppVersion>().eq(AppVersion::getAppid, detail.getId()).orderByDesc(AppVersion::getVersionCode));
|
|
|
+ detail.setAppVersionList(list);
|
|
|
+ return R.data(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页 app应用表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "app应用列表", notes = "传入app")
|
|
|
+ public R<IPage<App>> list(App app, Query query) {
|
|
|
+ try {
|
|
|
+ Page<App> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
+ IPage<App> pageList = appService.page(page, new LambdaQueryWrapper<App>().orderByDesc(App::getCreateTime));
|
|
|
+ pageList.getRecords().forEach(it -> {
|
|
|
+ //获取最新的版本信息
|
|
|
+ it.setAppVersion(appService.getLatestVersionById(it.getId(), null));
|
|
|
+ });
|
|
|
+ return R.data(pageList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询更新历史记录
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/versionHistory", method = RequestMethod.GET)
|
|
|
+ public R versionHistory(App app, Query query)
|
|
|
+ {
|
|
|
+ Page<AppVersion> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
+ IPage<AppVersion> pageList = appVersionService.page(page, new LambdaQueryWrapper<AppVersion>().eq(AppVersion::getAppid, app.getId()).orderByDesc(AppVersion::getVersionCode));
|
|
|
+ return R.data(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增 app应用表
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "新增app应用", notes = "传入app")
|
|
|
+ public R save(@Valid @RequestBody App app) {
|
|
|
+ return R.status(appService.save(app));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改 app应用表
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "修改", notes = "传入app")
|
|
|
+ public R update(@Valid @RequestBody App app) {
|
|
|
+ return R.status(appService.updateById(app));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除 app应用表
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "删除", notes = "传入ids")
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+ return R.status(appService.removeByIds(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|