健康报告保存接口

This commit is contained in:
limqhz
2021-03-08 15:17:40 +08:00
parent 8db822c548
commit 8cad890c1b
13 changed files with 121 additions and 58 deletions

View File

@@ -24,3 +24,4 @@ sv:
store:
image: imagetest/
video: videotest/
health: health-docstest/

View File

@@ -17,3 +17,4 @@ sv:
store:
image: image/
video: video/
health: health-docs/

View File

@@ -1,18 +1,12 @@
package com.sv.entity;
import java.io.Serializable;
import java.util.Date;
public class HealthDoc implements Serializable {
public class HealthDoc {
private Integer id;
private Integer memberId;
/**
* 用户昵称
*/
private String nickName;
private String docName;
private String docType;
@@ -21,6 +15,8 @@ public class HealthDoc implements Serializable {
private String docPath;
private Date date;
private Integer platformId;
private Date createdTime;
@@ -29,13 +25,14 @@ public class HealthDoc implements Serializable {
private Byte deleted;
public HealthDoc(Integer id, Integer memberId, String docName, String docType, String fileType, String docPath, Integer platformId, Date createdTime, Date modifiedTime, Byte deleted) {
public HealthDoc(Integer id, Integer memberId, String docName, String docType, String fileType, String docPath, Date date, Integer platformId, Date createdTime, Date modifiedTime, Byte deleted) {
this.id = id;
this.memberId = memberId;
this.docName = docName;
this.docType = docType;
this.fileType = fileType;
this.docPath = docPath;
this.date = date;
this.platformId = platformId;
this.createdTime = createdTime;
this.modifiedTime = modifiedTime;
@@ -62,14 +59,6 @@ public class HealthDoc implements Serializable {
this.memberId = memberId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getDocName() {
return docName;
}
@@ -102,6 +91,14 @@ public class HealthDoc implements Serializable {
this.docPath = docPath == null ? null : docPath.trim();
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Integer getPlatformId() {
return platformId;
}
@@ -133,4 +130,4 @@ public class HealthDoc implements Serializable {
public void setDeleted(Byte deleted) {
this.deleted = deleted;
}
}
}

View File

@@ -12,3 +12,4 @@ sv:
store:
image: imagetest/
video: videotest/
health: health-docstest/

View File

@@ -13,3 +13,4 @@ sv:
store:
image: image/
video: video/
health: health-docs/

View File

@@ -0,0 +1,15 @@
import http from '@/utils/http'
/**
* 上传健康报告
*/
export function save(param) {
return http.post('/member/health/save', param)
}
/**
* 删除健康报告
*/
export function remove(id) {
return http.post('/member/health/delete', { 'id': id })
}

View File

@@ -2,8 +2,32 @@
<div class="app-container app-edit">
<el-form class="small-space" :model="form" :rules="rules" ref="form" label-position="right" label-width="120px" style="width: 700px;">
<!-- 用户ID -->
<el-form-item label="用户ID" prop="memberId">
<el-input v-model="form.memberId" placeholder="请输入用户ID"></el-input>
<el-form-item label="文档名称" prop="docName">
<el-input v-model="form.docName" placeholder="请输入文档名称"></el-input>
</el-form-item>
<el-form-item label="文档类型" prop="docName">
<el-select v-model="form.docType" style="width: 120px" class="filter-item" clearable placeholder="文档类型">
<el-option v-for="item in options.docType"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="报告日期" prop="date">
<el-date-picker class="filter-item" v-model="form.date" type="date" placeholder="选择报告日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd"></el-date-picker>
</el-form-item>
<el-form-item label="健康报告" prop="avatar">
<el-upload
class="avatar-uploader"
action="/api/upload/uploadFile"
:show-file-list="true"
:limit="1"
:on-exceed="handleExceed"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
<el-button size="small" type="primary">选择文件</el-button>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="onSubmit" @click="handleSave">保存</el-button>
@@ -14,48 +38,47 @@
</template>
<script>
import { save } from '@/api//member/card'
import { save } from '@/api/member/health/doc'
export default {
data() {
return {
form: {
memberId: undefined,
cardType: '',
veneuType: '',
venueId: '',
startTime: '',
endTime: '',
status: 1,
platformId: ''
docName: '',
docType: '',
date: '',
docPath: ''
},
options: {
docType: [
{
value: 0,
label: '健康报告'
}
],
status: [
]
},
onSubmit: false,
// 表单验证规则
rules: {
// mobile: [
// { required: true, message: '请输入手机号码', trigger: 'blur' }
// ],
// username: [
// { required: true, message: '请输入姓名', trigger: 'blur' },
// { max: 15, message: '姓名长度不能超过15个字符', trigger: 'blur' }
// ],
// email: [
// { required: true, message: '请输入邮箱', trigger: 'blur' },
// { type: 'email', message: '您输入的邮箱格式不正确', trigger: 'blur' }
// ],
// password: [
// { required: true, message: '请输入密码', trigger: 'blur' },
// { min: 6, message: '密码长度不能少于6个字符', trigger: 'blur' }
// ]
docName: [
{ required: true, message: '请输入报告名称', trigger: 'blur' }
],
docType: [
{ required: true, message: '请输入报告类型', trigger: 'blur' }
],
date: [
{ required: true, message: '请选择报告日期', trigger: 'blur' }
]
}
}
},
created() {
alert(this.$route.query.id)
if (this.$route.query.id) {
this.form.memberId = this.$route.query.id
if (this.$route.query.memberId) {
this.form.memberId = this.$route.query.memberId
}
},
methods: {
@@ -63,6 +86,10 @@ export default {
* 保存用户会员卡
*/
handleSave() {
if (!this.form.docPath) {
alert('请选择文件上传')
return false
}
this.$refs.form.validate(valid => {
if (!valid) {
return false
@@ -75,7 +102,20 @@ export default {
})
})
},
handleExceed() {
alert('已存在健康报告!')
},
beforeAvatarUpload(file) {
// const isLt2M = file.size / 1024 / 1024 < 2
// if (!isLt2M) {
// this.$message.error('上传头像图片大小不能超过 2MB!')
// }
// return isLt2M
},
// 处理头像上传成功
handleAvatarSuccess(res) {
this.form.docPath = res.docPath
},
/**
* 取消
*/

View File

@@ -16,13 +16,6 @@
<!-- 列表数据 -->
<Pagination uri="/member/health/docs" :request-params="params" ref="pagination">
<!-- 用户ID -->
<el-table-column align="center" label="用户昵称">
<template scope="scope">
<span>{{scope.row.nickname}}</span>
</template>
</el-table-column>
<!-- 文档名称 -->
<el-table-column align="center" label="报告名称">
<template scope="scope">
@@ -54,7 +47,7 @@
</template>
<script>
import { remove } from '@/api//member/card'
import { remove } from '@/api/member/health/doc'
import waves from '@/directive/waves.js'// 水波纹指令
import Pagination from '@/components/Pagination'
import hasPermission from '@/utils/permission'
@@ -113,7 +106,7 @@ export default {
* 创建用户会员卡
*/
handleCreate() {
this.$router.push({ path: '/member/health/add' })
this.$router.push({ path: '/member/health/add', query: { memberId: this.params.search_eq_memberId }})
},
/**
* 删除用户会员卡

View File

@@ -47,4 +47,14 @@ public class UploadController extends OmsController {
return ResponseDTO.ok(videoUrl);
}
/**
* 上传健康报告到阿里云
* @return
*/
@RequestMapping(value = "/uploadFile")
public ResponseDTO uploadFile(@RequestParam("file") MultipartFile multipartFile) throws IOException {
String healthUrl = ossClientUtil.uploadHealth(multipartFile);
return ResponseDTO.ok().addAttribute("docPath",healthUrl);
}
}

View File

@@ -20,3 +20,4 @@ sv:
store:
image: imagetest/
video: videotest/
health: health-docstest/

View File

@@ -17,3 +17,4 @@ sv:
store:
image: image/
video: video/
health: health-docs/

View File

@@ -1,8 +1,6 @@
package com.sv.mapper;
import com.sv.entity.HealthDoc;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface HealthDocMapper {

View File

@@ -33,6 +33,10 @@ public class MemberHealthDocService extends MemberCardCommonService {
*/
@Transactional
public void save(HealthDoc healthDoc) {
String docPath = healthDoc.getDocPath();
String fileType = docPath.substring(docPath.lastIndexOf('.')+1).toUpperCase();
healthDoc.setFileType(fileType);
healthDoc.setPlatformId(1);
healthDocMapper.insert(healthDoc);
}