Jelajahi Sumber

语音设置

licailing 5 tahun lalu
induk
melakukan
3f2e859626

+ 7 - 0
pom.xml

@@ -258,6 +258,13 @@
         </dependency>
         </dependency>
         <!-- 钉钉 -->
         <!-- 钉钉 -->
 
 
+
+        <dependency>
+            <groupId>javazoom</groupId>
+            <artifactId>jlayer</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+
     </dependencies>
     </dependencies>
 
 
 </project>
 </project>

+ 13 - 5
src/main/java/com/izouma/dingdong/domain/merchant/Voice.java → src/main/java/com/izouma/dingdong/domain/backstage/Voice.java

@@ -1,4 +1,4 @@
-package com.izouma.dingdong.domain.merchant;
+package com.izouma.dingdong.domain.backstage;
 
 
 import com.izouma.dingdong.domain.BaseEntity;
 import com.izouma.dingdong.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
@@ -7,7 +7,9 @@ import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Builder;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Where;
 
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Entity;
 
 
 @Builder
 @Builder
@@ -15,14 +17,20 @@ import javax.persistence.Entity;
 @Data
 @Data
 @AllArgsConstructor
 @AllArgsConstructor
 @NoArgsConstructor
 @NoArgsConstructor
+@Where(clause = "enabled = 1")
 @ApiModel(value = "语音配置")
 @ApiModel(value = "语音配置")
 public class Voice extends BaseEntity {
 public class Voice extends BaseEntity {
-    @ApiModelProperty(value = "用户ID", name = "userId")
-    private Long userId;
+/*    @ApiModelProperty(value = "用户ID", name = "userId")
+    private Long userId;*/
 
 
     @ApiModelProperty(value = "内容")
     @ApiModelProperty(value = "内容")
     private String content;
     private String content;
 
 
-    @ApiModelProperty(value = "是否开启")
-    private Boolean isOpen;
+    @Column(nullable = false)
+    private Boolean enabled = true;
+
+    private String url;
+
+/*    @ApiModelProperty(value = "是否开启")
+    private Boolean isOpen;*/
 }
 }

+ 12 - 3
src/main/java/com/izouma/dingdong/domain/merchant/AutomaticResponse.java

@@ -1,11 +1,12 @@
 package com.izouma.dingdong.domain.merchant;
 package com.izouma.dingdong.domain.merchant;
 
 
 import com.izouma.dingdong.domain.BaseEntity;
 import com.izouma.dingdong.domain.BaseEntity;
+import com.izouma.dingdong.domain.backstage.Voice;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
 import lombok.*;
 
 
-import javax.persistence.Entity;
+import javax.persistence.*;
 import java.io.Serializable;
 import java.io.Serializable;
 
 
 @EqualsAndHashCode(callSuper = true)
 @EqualsAndHashCode(callSuper = true)
@@ -14,7 +15,7 @@ import java.io.Serializable;
 @AllArgsConstructor
 @AllArgsConstructor
 @NoArgsConstructor
 @NoArgsConstructor
 @Builder
 @Builder
-@ApiModel(value = "自动回复设置")
+@ApiModel(value = "自动回复以及语音设置")
 public class AutomaticResponse extends BaseEntity implements Serializable {
 public class AutomaticResponse extends BaseEntity implements Serializable {
 
 
 //    @ApiModelProperty(value = "商户ID")
 //    @ApiModelProperty(value = "商户ID")
@@ -26,6 +27,14 @@ public class AutomaticResponse extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "好评内容")
     @ApiModelProperty(value = "好评内容")
     public String goodContent;
     public String goodContent;
 
 
-    @ApiModelProperty(value = "自动回复内容")
+    @ApiModelProperty(value = "差评内容")
     private String badContent;
     private String badContent;
+
+    @ApiModelProperty(value = "语音ID")
+    private Long voiceId;
+
+    @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.DETACH)
+    @JoinColumn(name = "voiceId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
+    private Voice voice;
+
 }
 }

+ 14 - 4
src/main/java/com/izouma/dingdong/domain/user/Address.java

@@ -1,6 +1,7 @@
 package com.izouma.dingdong.domain.user;
 package com.izouma.dingdong.domain.user;
 
 
 import com.izouma.dingdong.domain.BaseEntity;
 import com.izouma.dingdong.domain.BaseEntity;
+import com.izouma.dingdong.enums.AddressTag;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
 import lombok.*;
@@ -18,18 +19,27 @@ import java.io.Serializable;
 //@JsonIgnoreProperties(value = {"hibernateLazyInitializer"})
 //@JsonIgnoreProperties(value = {"hibernateLazyInitializer"})
 @ApiModel(value = "Address", description = "收获地址记录")
 @ApiModel(value = "Address", description = "收获地址记录")
 public class Address extends BaseEntity implements Serializable {
 public class Address extends BaseEntity implements Serializable {
-    @ApiModelProperty("用户Id")
+    @ApiModelProperty(value = "用户Id", name = "userId")
     private Long userId;
     private Long userId;
 
 
-    @ApiModelProperty("收件人姓名")
+    @ApiModelProperty(value = "联系人", name = "name")
     private String name;
     private String name;
 
 
-    @ApiModelProperty("收件人电话")
+    @ApiModelProperty(value = "女士/先生", name = "sex")
+    private String sex;
+
+    @ApiModelProperty(value = "电话", name = "phone")
     private String phone;
     private String phone;
 
 
-    @ApiModelProperty("详细地址")
+    @ApiModelProperty(value = "详细地址", name = "addressName")
     private String addressName;
     private String addressName;
 
 
+    @ApiModelProperty(value = "门牌号", name = "number")
+    private String number;
+
+    @ApiModelProperty(value = "标签", name = "addressTag")
+    private AddressTag addressTag;
+
     @ApiModelProperty("是否选为默认地址")
     @ApiModelProperty("是否选为默认地址")
     private Boolean isDefault;
     private Boolean isDefault;
 
 

+ 39 - 0
src/main/java/com/izouma/dingdong/domain/user/Feedback.java

@@ -0,0 +1,39 @@
+package com.izouma.dingdong.domain.user;
+
+import com.izouma.dingdong.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Where;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+@Data
+@Entity
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@Where(clause = "enabled = 1")
+public class Feedback extends BaseEntity {
+    @ApiModelProperty(value = "用户Id", name = "userId")
+    private Long userId;
+
+    @ApiModelProperty(value = "内容", name = "content")
+    @Column(nullable = false)
+    private String content;
+
+    @ApiModelProperty(value = "图片", name = "img")
+    private String img;
+
+    @ApiModelProperty(value = "联系人", name = "name")
+    private String name;
+
+    @ApiModelProperty(value = "电话", name = "phone")
+    private String phone;
+
+    @Column(nullable = false)
+    private Boolean enabled = true;
+}

+ 5 - 1
src/main/java/com/izouma/dingdong/domain/user/MyCollection.java

@@ -1,6 +1,7 @@
 package com.izouma.dingdong.domain.user;
 package com.izouma.dingdong.domain.user;
 
 
 import com.izouma.dingdong.domain.BaseEntity;
 import com.izouma.dingdong.domain.BaseEntity;
+import com.izouma.dingdong.domain.merchant.Merchant;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
@@ -8,7 +9,7 @@ import lombok.Builder;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
 
 
-import javax.persistence.Entity;
+import javax.persistence.*;
 
 
 @Data
 @Data
 @Entity
 @Entity
@@ -23,4 +24,7 @@ public class MyCollection extends BaseEntity {
     @ApiModelProperty(value = "商户ID",name = "merchantId")
     @ApiModelProperty(value = "商户ID",name = "merchantId")
     private Long merchantId;
     private Long merchantId;
 
 
+    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
+    @JoinColumn(name = "merchantId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
+    private Merchant merchant;
 }
 }

+ 16 - 0
src/main/java/com/izouma/dingdong/enums/AddressTag.java

@@ -0,0 +1,16 @@
+package com.izouma.dingdong.enums;
+
+public enum AddressTag {
+    /**
+     * 家
+     */
+    HOME,
+    /**
+     * 公司
+     */
+    COMPANY,
+    /**
+     * 学校
+     */
+    SCHOOL
+}

+ 4 - 7
src/main/java/com/izouma/dingdong/repo/merchant/VoiceRepo.java → src/main/java/com/izouma/dingdong/repo/backstage/VoiceRepo.java

@@ -1,19 +1,16 @@
-package com.izouma.dingdong.repo.merchant;
+package com.izouma.dingdong.repo.backstage;
 
 
-import com.izouma.dingdong.domain.merchant.Voice;
+import com.izouma.dingdong.domain.backstage.Voice;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.jpa.repository.Query;
 
 
 import javax.transaction.Transactional;
 import javax.transaction.Transactional;
-import java.util.List;
 
 
 public interface VoiceRepo extends JpaRepository<Voice, Long>, JpaSpecificationExecutor<Voice> {
 public interface VoiceRepo extends JpaRepository<Voice, Long>, JpaSpecificationExecutor<Voice> {
-    @Query("update Voice t set t.isOpen = false where t.id <> ?1 and t.userId = ?2")
+    @Query("update Voice t set t.enabled = false where t.id = ?1")
     @Modifying
     @Modifying
     @Transactional
     @Transactional
-    void updateIsOpen(Long id, Long userId);
-
-    List<Voice> findAllByUserId(Long userId);
+    void deleteById(Long id);
 }
 }

+ 3 - 0
src/main/java/com/izouma/dingdong/service/OrderInfoService.java

@@ -324,6 +324,9 @@ public class OrderInfoService {
      */
      */
     public List<OrderInfo> my(Long userId) {
     public List<OrderInfo> my(Long userId) {
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
+        if (user.getIdentity()==null){
+            throw new BusinessException("身份错误");
+        }
         switch (user.getIdentity()) {
         switch (user.getIdentity()) {
             case USER:
             case USER:
                 return orderInfoRepo.findAllByUserId(userId);
                 return orderInfoRepo.findAllByUserId(userId);

+ 3 - 3
src/main/java/com/izouma/dingdong/service/merchant/VoiceService.java → src/main/java/com/izouma/dingdong/service/backstage/VoiceService.java

@@ -1,7 +1,7 @@
-package com.izouma.dingdong.service.merchant;
+package com.izouma.dingdong.service.backstage;
 
 
-import com.izouma.dingdong.domain.merchant.Voice;
-import com.izouma.dingdong.repo.merchant.VoiceRepo;
+import com.izouma.dingdong.domain.backstage.Voice;
+import com.izouma.dingdong.repo.backstage.VoiceRepo;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 

+ 1 - 0
src/main/java/com/izouma/dingdong/web/UserController.java

@@ -120,4 +120,5 @@ public class UserController extends BaseController {
         List<User> users = userRepo.findAllByIdentity(Identity.ADMIN);
         List<User> users = userRepo.findAllByIdentity(Identity.ADMIN);
         return new PageImpl<>(users, toPageRequest(pageQuery), pageQuery.getPage());
         return new PageImpl<>(users, toPageRequest(pageQuery), pageQuery.getPage());
     }
     }
+
 }
 }

+ 7 - 18
src/main/java/com/izouma/dingdong/web/merchant/VoiceController.java → src/main/java/com/izouma/dingdong/web/backstage/VoiceController.java

@@ -1,12 +1,11 @@
-package com.izouma.dingdong.web.merchant;
+package com.izouma.dingdong.web.backstage;
 
 
-import com.izouma.dingdong.utils.SecurityUtils;
 import com.izouma.dingdong.web.BaseController;
 import com.izouma.dingdong.web.BaseController;
-import com.izouma.dingdong.domain.merchant.Voice;
-import com.izouma.dingdong.service.merchant.VoiceService;
+import com.izouma.dingdong.domain.backstage.Voice;
+import com.izouma.dingdong.service.backstage.VoiceService;
 import com.izouma.dingdong.dto.PageQuery;
 import com.izouma.dingdong.dto.PageQuery;
 import com.izouma.dingdong.exception.BusinessException;
 import com.izouma.dingdong.exception.BusinessException;
-import com.izouma.dingdong.repo.merchant.VoiceRepo;
+import com.izouma.dingdong.repo.backstage.VoiceRepo;
 import com.izouma.dingdong.utils.ObjUtils;
 import com.izouma.dingdong.utils.ObjUtils;
 import com.izouma.dingdong.utils.excel.ExcelUtils;
 import com.izouma.dingdong.utils.excel.ExcelUtils;
 
 
@@ -32,21 +31,16 @@ public class VoiceController extends BaseController {
         if (record.getId() != null) {
         if (record.getId() != null) {
             Voice orig = voiceRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             Voice orig = voiceRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);
             ObjUtils.merge(orig, record);
-            record = voiceRepo.save(orig);
-        } else {
-            record = voiceRepo.save(record);
+            return voiceRepo.save(orig);
         }
         }
-        if (record.getIsOpen()) {
-            voiceRepo.updateIsOpen(record.getId(), record.getUserId());
-        }
-        return record;
+        return voiceRepo.save(record);
     }
     }
 
 
 
 
     //@PreAuthorize("hasRole('ADMIN')")
     //@PreAuthorize("hasRole('ADMIN')")
     @GetMapping("/all")
     @GetMapping("/all")
     public Page<Voice> all(PageQuery pageQuery) {
     public Page<Voice> all(PageQuery pageQuery) {
-        return voiceRepo.findAll(toSpecification(pageQuery, Voice.class), toPageRequest(pageQuery));
+        return voiceRepo.findAll(toSpecification(pageQuery,Voice.class), toPageRequest(pageQuery));
     }
     }
 
 
     @GetMapping("/get/{id}")
     @GetMapping("/get/{id}")
@@ -65,10 +59,5 @@ public class VoiceController extends BaseController {
         List<Voice> data = all(pageQuery).getContent();
         List<Voice> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
         ExcelUtils.export(response, data);
     }
     }
-
-    @GetMapping("/my")
-    public List<Voice> my() {
-        return voiceRepo.findAllByUserId(SecurityUtils.getAuthenticatedUser().getId());
-    }
 }
 }
 
 

+ 1 - 1
src/main/resources/genjson/Voice.json

@@ -1 +1 @@
-{"tableName":"Voice","className":"Voice","remark":"语音配置","genTable":true,"genClass":true,"genList":false,"genForm":false,"genRouter":false,"javaPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/java/com/izouma/dingdong","viewPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/vue/src/views","routerPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/vue/src","resourcesPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"userId","modelName":"userId","remark":"用户ID","showInList":true,"showInForm":true,"formType":"number"},{"name":"content","modelName":"content","remark":"内容","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"isOpen","modelName":"isOpen","remark":"是否开启","showInList":true,"showInForm":true,"formType":"switch"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.dingdong","tablePackage":"com.izouma.dingdong.domain.merchant.Voice","genPackage":"merchant"}
+{"tableName":"Voice","className":"Voice","remark":"语音配置","genTable":true,"genClass":true,"genList":true,"genForm":true,"genRouter":true,"javaPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/java/com/izouma/dingdong","viewPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/vue/src/views","routerPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/vue/src","resourcesPath":"/Users/qiufangchao/Desktop/project/dingdong/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"content","modelName":"content","remark":"内容","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"url","modelName":"url","remark":"文件","showInList":true,"showInForm":true,"formType":"fileUpload"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.dingdong","tablePackage":"com.izouma.dingdong.domain.backstage.Voice","genPackage":"backstage"}

+ 16 - 0
src/main/vue/src/router.js

@@ -318,6 +318,22 @@ const router = new Router({
                     meta: {
                     meta: {
                        title: '投诉',
                        title: '投诉',
                     },
                     },
+               },
+                {
+                    path: '/voiceEdit',
+                    name: 'VoiceEdit',
+                    component: () => import(/* webpackChunkName: "voiceEdit" */ '@/views/VoiceEdit.vue'),
+                    meta: {
+                       title: '语音配置编辑',
+                    },
+                },
+                {
+                    path: '/voiceList',
+                    name: 'VoiceList',
+                    component: () => import(/* webpackChunkName: "voiceList" */ '@/views/VoiceList.vue'),
+                    meta: {
+                       title: '语音配置',
+                    },
                }
                }
                 /**INSERT_LOCATION**/,
                 /**INSERT_LOCATION**/,
                 {
                 {

+ 123 - 0
src/main/vue/src/views/VoiceEdit.vue

@@ -0,0 +1,123 @@
+<template>
+    <div class="edit-view">
+        <el-form :model="formData" :rules="rules" ref="form" label-width="52px" label-position="right" size="small"
+                 style="max-width: 500px;">
+            <el-form-item prop="content" label="内容">
+                <el-input v-model="formData.content"></el-input>
+            </el-form-item>
+            <el-form-item prop="url" label="文件">
+                <el-upload
+                        class="avatar-uploader"
+                        :action="uploadUrl"
+                        :limit="1"
+                        :show-file-list="true"
+                        :on-success="onSuccess"
+                        v-model="formData.url"
+                        :beforeUpload="beforeAvatarUpload">
+                    <el-button size="small" type="primary">点击上传</el-button>
+                </el-upload>
+                <!--<file-upload v-model="formData.url">
+                </file-upload>-->
+            </el-form-item>
+            <el-form-item>
+                <el-button @click="onSave" :loading="saving"
+                           type="primary">保存
+                </el-button>
+                <el-button @click="onDelete" :loading="saving"
+                           type="danger" v-if="formData.id">删除
+                </el-button>
+                <el-button @click="$router.go(-1)">取消</el-button>
+            </el-form-item>
+        </el-form>
+    </div>
+</template>
+<script>
+    import resolveUrl from 'resolve-url';
+
+    export default {
+        name: 'VoiceEdit',
+        created() {
+            if (this.$route.query.id) {
+                this.$http
+                    .get('voice/get/' + this.$route.query.id)
+                    .then(res => {
+                        this.formData = res;
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    });
+            }
+            this.uploadUrl = resolveUrl(this.$baseUrl, 'upload/file');
+        },
+        data() {
+            return {
+                saving: false,
+                formData: {},
+                rules: {},
+                uploadLoading: false,
+                uploadUrl: '',
+            }
+        },
+
+        methods: {
+            onSave() {
+                this.$refs.form.validate((valid) => {
+                    if (valid) {
+                        this.submit();
+                    } else {
+                        return false;
+                    }
+                });
+            },
+            submit() {
+                let data = {...this.formData};
+
+                this.saving = true;
+                this.$http
+                    .post('/voice/save', data, {body: 'json'})
+                    .then(res => {
+                        this.saving = false;
+                        this.$message.success('成功');
+                        this.$router.go(-1);
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.saving = false;
+                        this.$message.error(e.error);
+                    });
+            },
+            onDelete() {
+                this.$alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
+                    return this.$http.post(`/voice/del/${this.formData.id}`)
+                }).then(() => {
+                    this.$message.success('删除成功');
+                    this.$router.go(-1);
+                }).catch(e => {
+                    if (e !== 'cancel') {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    }
+                })
+            },
+            onSuccess(res, file) {
+                this.uploadLoading = false;
+                this.$message.success('上传成功');
+            },
+            beforeAvatarUpload(file) {
+                this.uploadLoading = true;
+                var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
+                const extension = testmsg === 'mp3'
+                if (!extension) {
+                    this.$message({
+                        message: "上传文件只能是mp3格式!",
+                        type: 'error'
+                    })
+                }
+                return extension;
+            }
+        }
+    }
+</script>
+<style lang="less" scoped>
+</style>

+ 172 - 0
src/main/vue/src/views/VoiceList.vue

@@ -0,0 +1,172 @@
+<template>
+    <div class="list-view">
+        <div class="filters-container">
+            <el-input placeholder="输入关键字" v-model="search" clearable
+                      class="filter-item"></el-input>
+            <el-button @click="getData" type="primary" icon="el-icon-search"
+                       class="filter-item">搜索
+            </el-button>
+            <el-button @click="addRow" type="primary" icon="el-icon-plus"
+                       class="filter-item">添加
+            </el-button>
+            <el-button @click="download" type="primary" icon="el-icon-download"
+                       :loading="downloading" class="filter-item">导出EXCEL
+            </el-button>
+        </div>
+        <el-table :data="tableData" row-key="id" ref="table"
+                  header-row-class-name="table-header-row"
+                  header-cell-class-name="table-header-cell"
+                  row-class-name="table-row" cell-class-name="table-cell"
+                  :height="tableHeight">
+            <el-table-column v-if="multipleMode" align="center" type="selection"
+                             width="50">
+            </el-table-column>
+            <el-table-column prop="id" label="ID" width="100">
+            </el-table-column>
+            <el-table-column prop="content" label="内容"
+            >
+            </el-table-column>
+            <el-table-column prop="url" label="文件"
+            >
+                <template slot-scope="{row}">
+                    <video controls v-if="row.url!=null">
+                        <source :src="row.url" type="audio/mpeg">
+                    </video>
+                </template>
+            </el-table-column>
+            <el-table-column
+                    label="操作"
+                    align="center"
+                    fixed="right"
+                    min-width="150">
+                <template slot-scope="{row}">
+                    <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+        <div class="pagination-wrapper">
+            <!-- <div class="multiple-mode-wrapper">
+                <el-button v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+                <el-button-group v-else>
+                    <el-button @click="operation1">批量操作1</el-button>
+                    <el-button @click="operation2">批量操作2</el-button>
+                    <el-button @click="toggleMultipleMode(false)">取消</el-button>
+                </el-button-group>
+            </div> -->
+            <el-pagination background @size-change="onSizeChange"
+                           @current-change="onCurrentChange" :current-page="page"
+                           :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize"
+                           layout="total, sizes, prev, pager, next, jumper"
+                           :total="totalElements">
+            </el-pagination>
+        </div>
+
+    </div>
+</template>
+<script>
+    import {mapState} from "vuex";
+    import pageableTable from "@/mixins/pageableTable";
+
+    export default {
+        name: 'VoiceList',
+        mixins: [pageableTable],
+        created() {
+            this.getData();
+        },
+        data() {
+            return {
+                multipleMode: false,
+                search: "",
+                url: "/voice/all",
+                downloading: false,
+            }
+        },
+        computed: {
+            selection() {
+                return this.$refs.table.selection.map(i => i.id);
+            }
+        },
+        methods: {
+            beforeGetData() {
+                if (this.search) {
+                    return {search: this.search};
+                }
+            },
+            toggleMultipleMode(multipleMode) {
+                this.multipleMode = multipleMode;
+                if (!multipleMode) {
+                    this.$refs.table.clearSelection();
+                }
+            },
+            addRow() {
+                this.$router.push({
+                    path: "/voiceEdit",
+                    query: {
+                        ...this.$route.query
+                    }
+                });
+            },
+            editRow(row) {
+                this.$router.push({
+                    path: "/voiceEdit",
+                    query: {
+                        id: row.id
+                    }
+                });
+            },
+            download() {
+                this.downloading = true;
+                this.$axios
+                    .get("/voice/excel", {
+                        responseType: "blob",
+                        params: {size: 10000}
+                    })
+                    .then(res => {
+                        console.log(res);
+                        this.downloading = false;
+                        const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+                        const link = document.createElement("a");
+                        link.href = downloadUrl;
+                        link.setAttribute(
+                            "download",
+                            res.headers["content-disposition"].split("filename=")[1]
+                        );
+                        document.body.appendChild(link);
+                        link.click();
+                        link.remove();
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.downloading = false;
+                        this.$message.error(e.error);
+                    });
+            },
+            operation1() {
+                this.$notify({
+                    title: '提示',
+                    message: this.selection
+                });
+            },
+            operation2() {
+                this.$message('操作2');
+            },
+            deleteRow(row) {
+                this.$alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
+                    return this.$http.post(`/voice/del/${row.id}`)
+                }).then(() => {
+                    this.$message.success('删除成功');
+                    this.getData();
+                }).catch(action => {
+                    if (action === 'cancel') {
+                        this.$message.info('删除取消');
+                    } else {
+                        this.$message.error('删除失败');
+                    }
+                })
+            },
+        }
+    }
+</script>
+<style lang="less" scoped>
+</style>

+ 39 - 0
src/test/java/com/izouma/dingdong/VoiceTest.java

@@ -0,0 +1,39 @@
+package com.izouma.dingdong;
+
+import com.izouma.dingdong.exception.BusinessException;
+import javazoom.jl.decoder.JavaLayerException;
+import javazoom.jl.player.Player;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class VoiceTest {
+    @Test
+    public void test() throws IOException, JavaLayerException {
+        int voiceId = 2;
+        File file;
+
+        switch (voiceId) {
+            case 1:
+                file = new File("/Users/qiufangchao/Desktop/1.mp3");
+                break;
+            case 2:
+                file = new File("/Users/qiufangchao/Desktop/2.mp3");
+                break;
+            default:
+                throw new BusinessException("语音错误");
+        }
+
+
+        FileInputStream f = new FileInputStream(file);
+        Player player = new Player(f);
+        player.play();
+    }
+}

+ 8 - 0
src/test/java/com/izouma/dingdong/contorller/OrderInfoControllerTest.java

@@ -4,6 +4,7 @@ import com.izouma.dingdong.domain.backstage.Category;
 import com.izouma.dingdong.domain.merchant.Goods;
 import com.izouma.dingdong.domain.merchant.Goods;
 import com.izouma.dingdong.dto.MerchantDTO;
 import com.izouma.dingdong.dto.MerchantDTO;
 import com.izouma.dingdong.repo.merchant.MerchantRepo;
 import com.izouma.dingdong.repo.merchant.MerchantRepo;
+import com.izouma.dingdong.service.OrderInfoService;
 import com.izouma.dingdong.web.AuthenticationController;
 import com.izouma.dingdong.web.AuthenticationController;
 import com.izouma.dingdong.web.backstage.CategoryController;
 import com.izouma.dingdong.web.backstage.CategoryController;
 import com.izouma.dingdong.web.merchant.GoodsController;
 import com.izouma.dingdong.web.merchant.GoodsController;
@@ -33,6 +34,8 @@ public class OrderInfoControllerTest {
     @Autowired
     @Autowired
     private MerchantRepo merchantRepo;
     private MerchantRepo merchantRepo;
 
 
+    @Autowired
+    private OrderInfoService service;
 
 
     //商家注册
     //商家注册
     @Test
     @Test
@@ -87,4 +90,9 @@ public class OrderInfoControllerTest {
     public void goodsPass() {
     public void goodsPass() {
         goodsController.audit(319L, true, null);
         goodsController.audit(319L, true, null);
     }
     }
+
+    @Test
+    public void testMy(){
+        System.out.println(service.my(162L));
+    }
 }
 }

+ 7 - 9
src/test/java/com/izouma/dingdong/contorller/VoiceControllerTest.java

@@ -1,8 +1,8 @@
 package com.izouma.dingdong.contorller;
 package com.izouma.dingdong.contorller;
 
 
-import com.izouma.dingdong.domain.merchant.Voice;
-import com.izouma.dingdong.repo.merchant.VoiceRepo;
-import com.izouma.dingdong.web.merchant.VoiceController;
+import com.izouma.dingdong.domain.backstage.Voice;
+import com.izouma.dingdong.repo.backstage.VoiceRepo;
+import com.izouma.dingdong.web.backstage.VoiceController;
 import org.junit.Test;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,19 +18,17 @@ public class VoiceControllerTest {
     @Autowired
     @Autowired
     private VoiceRepo voiceRepo;
     private VoiceRepo voiceRepo;
 
 
-    @Test
+   @Test
     public void test(){
     public void test(){
         Voice build = Voice.builder()
         Voice build = Voice.builder()
-                .userId(656L)
-                .content("订单来啦!注意查收")
-                .isOpen(true)
+                .url("https://idingdong.oss-cn-hangzhou.aliyuncs.com/audio/2020-05-28-13-53-28DJxEOyUA.mp3")
                 .build();
                 .build();
         build.setId(667L);
         build.setId(667L);
         System.out.println(voiceController.save(build));
         System.out.println(voiceController.save(build));
     }
     }
 
 
-    @Test
+/*    @Test
     public void testMy(){
     public void testMy(){
         System.out.println(voiceRepo.findAllByUserId(656L));
         System.out.println(voiceRepo.findAllByUserId(656L));
-    }
+    }*/
 }
 }