Browse Source

Merge branch 'dev'

xiongzhu 3 years ago
parent
commit
4dc2a3f694

+ 5 - 0
src/main/java/com/izouma/nineth/domain/AppVersion.java

@@ -6,8 +6,13 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.persistence.Entity;
+import javax.persistence.Index;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
 
 @Data
+@Table(indexes = {@Index(columnList = "version,platform,channel")},
+        uniqueConstraints = @UniqueConstraint(columnNames = {"version", "platform", "channel"}))
 @Entity
 @AllArgsConstructor
 @NoArgsConstructor

+ 2 - 2
src/main/java/com/izouma/nineth/repo/AppVersionRepo.java

@@ -15,11 +15,11 @@ public interface AppVersionRepo extends JpaRepository<AppVersion, Long>, JpaSpec
     @Transactional
     void softDelete(Long id);
 
-    Optional<AppVersion> findByPlatformAndVersionAndDelFalse(String platform, String version);
+    Optional<AppVersion> findByPlatformAndVersionAndChannelAndDelFalse(String platform, String version, String channel);
 
     Optional<AppVersion> findFirstByPlatformAndReviewFalseAndDelFalseOrderByVersionNumDesc(String platform);
 
     @Query(value = "select * from app_version a where a.platform = ?1 and a.channel = ?2 and a.review = false and a.del = false " +
-            "order by a.version_num desc",nativeQuery = true)
+            "order by a.version_num desc", nativeQuery = true)
     Optional<AppVersion> findLatest(String platform, String channel);
 }

+ 6 - 5
src/main/java/com/izouma/nineth/web/AppVersionController.java

@@ -68,7 +68,7 @@ public class AppVersionController extends BaseController {
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/del/{id}")
     public void del(@PathVariable Long id) {
-        appVersionRepo.softDelete(id);
+        appVersionRepo.deleteById(id);
     }
 
     @GetMapping("/excel")
@@ -80,17 +80,18 @@ public class AppVersionController extends BaseController {
 
     @GetMapping("/checkIosReview")
     public AppVersion checkIosReview(@RequestParam String version) {
-        return appVersionRepo.findByPlatformAndVersionAndDelFalse("iOS", version).orElseThrow(new BusinessException("版本不存在"));
+        return appVersionRepo.findByPlatformAndVersionAndChannelAndDelFalse("iOS", version, "default").orElseThrow(new BusinessException("版本不存在"));
     }
 
     @GetMapping("/checkAndroidReview")
     public AppVersion checkAndroidReview(@RequestParam String version) {
-        return appVersionRepo.findByPlatformAndVersionAndDelFalse("Android", version).orElseThrow(new BusinessException("版本不存在"));
+        return appVersionRepo.findByPlatformAndVersionAndChannelAndDelFalse("Android", version, "default").orElseThrow(new BusinessException("版本不存在"));
     }
 
     @GetMapping("/getVersion")
-    public AppVersion checkReview(@RequestParam String platform, @RequestParam String version) {
-        return appVersionRepo.findByPlatformAndVersionAndDelFalse(platform, version).orElseThrow(new BusinessException("版本不存在"));
+    public AppVersion checkReview(@RequestParam String platform, @RequestParam String version,
+                                  @RequestParam(defaultValue = "default") String channel) {
+        return appVersionRepo.findByPlatformAndVersionAndChannelAndDelFalse(platform, version, channel).orElseThrow(new BusinessException("版本不存在"));
     }
 
     @GetMapping("/checkUpdate")

+ 11 - 3
src/main/vue/src/views/AppVersionEdit.vue

@@ -32,7 +32,9 @@
                         <el-switch v-model="formData.review"></el-switch>
                     </el-form-item>
                     <el-form-item prop="channel" label="channel">
-                        <el-input v-model="formData.channel"></el-input>
+                        <el-select v-model="formData.channel" placeholder="">
+                            <el-option v-for="item in channels" :key="item" :label="item" :value="item"></el-option>
+                        </el-select>
                     </el-form-item>
                     <el-form-item prop="downloadUrl" label="downloadUrl">
                         <el-input v-model="formData.downloadUrl"></el-input>
@@ -69,9 +71,15 @@ export default {
         return {
             saving: false,
             formData: {
-                review: false
+                review: false,
+                channel: 'default'
+            },
+            rules: {
+                version: { required: true },
+                platform: { required: true },
+                channel: { required: true }
             },
-            rules: {}
+            channels: ['default', 'huawei', 'oppo', 'vivo', 'xiaomi', 'qq']
         };
     },
     methods: {

+ 29 - 8
src/main/vue/src/views/AppVersionList.vue

@@ -21,10 +21,13 @@
             </el-button>
         </page-title>
         <div class="filters-container">
-            <el-radio-group v-model="platform" size="small" class="filter-item">
-                <el-radio-button label="iOS"></el-radio-button>
-                <el-radio-button label="Android"></el-radio-button>
-            </el-radio-group>
+            <el-select v-model="platform" size="small" class="filter-item">
+                <el-option label="iOS" value="iOS">iOS</el-option>
+                <el-option label="Android" value="Android">Android</el-option>
+            </el-select>
+            <el-select v-model="channel" size="small" class="filter-item">
+                <el-option v-for="item in channels" :key="item" :label="item" :value="item"></el-option>
+            </el-select>
             <el-input
                 placeholder="搜索..."
                 v-model="search"
@@ -101,7 +104,9 @@ export default {
             search: '',
             url: '/appVersion/all',
             downloading: false,
-            platform: 'iOS'
+            platform: 'iOS',
+            channels: ['default', 'huawei', 'oppo', 'vivo', 'xiaomi', 'qq'],
+            channel: 'default'
         };
     },
     computed: {
@@ -110,8 +115,16 @@ export default {
         }
     },
     methods: {
+        beforeCreated() {
+            if (this.$route.query.platform) {
+                this.platform = this.$route.query.platform;
+            }
+            if (this.$route.query.channel) {
+                this.channel = this.$route.query.channel;
+            }
+        },
         beforeGetData() {
-            return { search: this.search, query: { del: false, platform: this.platform } };
+            return { search: this.search, query: { del: false, platform: this.platform, channel: this.channel } };
         },
         toggleMultipleMode(multipleMode) {
             this.multipleMode = multipleMode;
@@ -187,9 +200,17 @@ export default {
     watch: {
         platform() {
             this.getData();
+            this.$router
+                .replace({ ...this.$route, query: { ...this.$route.query, platform: this.platform } })
+                .catch(() => {});
+        },
+        channel() {
+            this.getData();
+            this.$router
+                .replace({ ...this.$route, query: { ...this.$route.query, channel: this.channel } })
+                .catch(() => {});
         }
     }
 };
 </script>
-<style lang="less" scoped>
-</style>
+<style lang="less" scoped></style>