提交 5600dcd6 编写于 作者: 玉米子禾's avatar 玉米子禾

修复518

上级 2bf422dd
package cn.minuyh.cinematicket.controller.system;
import cn.minuyh.cinematicket.config.properties.FileUploadProperties;
import cn.minuyh.cinematicket.util.ImageURL;
import cn.minuyh.cinematicket.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -112,6 +113,7 @@ public class FileController {
System.out.println("写入文件成功!!返回");
Map<String, String> resultMap = new HashMap<>();
resultMap.put("fileName", newFileName);
resultMap.put("URL", ImageURL.fileName2URL(newFileName));
return Result.success(resultMap);
} else {
return Result.fail("文件格式不正确");
......
......@@ -8,6 +8,7 @@ import java.util.Objects;
@Entity
@Table(name = "table_movie", schema = "bs_cinema_online")
public class TableMovieEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String title;
private String subtitle;
......@@ -26,6 +27,7 @@ public class TableMovieEntity {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int getId() {
return id;
}
......
......@@ -4,6 +4,7 @@ import cn.minuyh.cinematicket.dao.repository.MovieRepository;
import cn.minuyh.cinematicket.entity.TableMovieEntity;
import cn.minuyh.cinematicket.enums.ResultEnum;
import cn.minuyh.cinematicket.util.Result;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,6 +13,9 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.Date;
/**
* 类说明
*
......@@ -29,6 +33,8 @@ public class MovieService {
public Result add(TableMovieEntity movie) {
movie.setCreateTime(new Timestamp(new Date().getTime()));
movie.setBoxOffice(0d);
val entity = movieRepository.saveAndFlush(movie);
if (entity.getId() != 0) {
return Result.success(entity);
......
package cn.minuyh.cinematicket.util;
/**
* 类说明
*
* @创建人 y17mm
* @创建时间 2022/5/18 20:09
**/
public class ImageURL {
static String h = "http://localhost:9090/file/img/";
public static String fileName2URL(String fileName){
return h + fileName;
}
public static String URL2fileName(String URL){
return URL.replace(h,"");
}
}
......@@ -5,7 +5,7 @@ spring:
multipart:
enabled: true
# 最大支持的文件大小
max-file-size: 2MB
max-file-size: 20MB
# 最大支持的请求大小
max-request-size: 10MB
datasource:
......
......@@ -355,6 +355,9 @@ export default {
this.showToast(response.msg);
}
});
},
refresh(){
location.reload();
}
},
mounted() {
......
......@@ -421,6 +421,7 @@ export default {
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
this.isHaveKey = false;
this.getPage(this.list.number + 1);
// 取消选择
this.selectId = undefined;
......
......@@ -797,6 +797,7 @@ export default {
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
this.isHaveKey = false;
this.getPage(this.list.number + 1);
// 取消选择
this.selectId = undefined;
......
......@@ -111,6 +111,7 @@ export default {
}
this.$parent.setUserInfo(id, nick, avatar, role);
console.log("设置完成");
this.$parent.refresh();
});
},
// 从服务器获取联系信息
......
......@@ -160,7 +160,7 @@
</div>
<input type="file" @change="updata()" id="fileUp" style="width: 0;height: 0;">
<!-- 模态框(Modal) -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
......@@ -176,6 +176,15 @@
</h4>
</div>
<div class="modal-body">
<div class="form-group">
<img style="height: 200px;width: 140px" :src="addData.poster" :alt="addData.title"
class="img-thumbnail">
<label class="btn-default btn" @click="uploadImg('add')" for="addPoster">上传图片</label>
<input v-model="addData.poster" type="text" class="form-control" id="addPoster"
placeholder="图片地址">
</div>
<div class="form-group">
<label for="addTitle">电影名</label>
<input v-model="addData.title" type="text" class="form-control" id="addTitle"
......@@ -192,29 +201,7 @@
placeholder="电影时长(分钟)">
</div>
<!-- <form class="form-horizontal">-->
<!-- <div class="form-group">-->
<!-- <label for="inputEmail3" class="col-sm-2 control-label">Email</label>-->
<!-- <div class="col-sm-10">-->
<!-- <input type="email" class="form-control" id="inputEmail3" placeholder="Email">-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="form-group">-->
<!-- <label for="inputPassword3" class="col-sm-2 control-label">Password</label>-->
<!-- <div class="col-sm-10">-->
<!-- <input type="password" class="form-control" id="inputPassword3" placeholder="Password">-->
<!-- </div>-->
<!-- </div>-->
<!-- </form>-->
<!-- <div style="width: 100%" class="form-inline">-->
<!-- <div class="form-group">-->
<!-- <label for="addAreaId" class="col-sm-4 control-label">区域ID</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input v-model="addData.areaId" type="number" class="form-control" id="addAreaId"-->
<!-- placeholder="区域ID">-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label for="addAreaId">区域ID</label>
<input v-model="addData.areaId" type="number" class="form-control" id="addAreaId"
......@@ -290,6 +277,15 @@
</div>
<div class="modal-body">
<div v-if="selectId!==undefined">
<div class="form-group">
<img style="height: 200px;width: 140px" :src="updateData.poster" :alt="updateData.title"
class="img-thumbnail">
<label class="btn-default btn" @click="uploadImg('upd')" for="addPoster">上传图片</label>
<input v-model="updateData.poster" type="text" class="form-control" id="updatePoster"
placeholder="图片地址">
</div>
<div class="form-group">
<label for="updateTitle">电影名</label>
<input v-model="updateData.title" type="text" class="form-control" id="updateTitle"
......@@ -297,12 +293,14 @@
</div>
<div class="form-group">
<label for="updateSubtitles">副标题</label>
<input v-model="updateData.subtitle" type="text" class="form-control" id="updateSubtitles"
<input v-model="updateData.subtitle" type="text" class="form-control"
id="updateSubtitles"
placeholder="副标题">
</div>
<div class="form-group">
<label for="updateDuration">电影时长</label>
<input v-model="updateData.duration" type="number" class="form-control" id="updateDuration"
<input v-model="updateData.duration" type="number" class="form-control"
id="updateDuration"
placeholder="电影时长(分钟)">
</div>
......@@ -356,18 +354,21 @@
<!-- </div>-->
<div class="form-group">
<label for="updateReleaseDate">上映时间</label>
<input v-model="updateData.releaseDate" type="date" class="form-control" id="updateReleaseDate"
<input v-model="updateData.releaseDate" type="date" class="form-control"
id="updateReleaseDate"
placeholder="上映时间">
</div>
<div class="form-group">
<label for="updateDirector">导演</label>
<input v-model="updateData.director" type="text" class="form-control" id="updateDirector"
<input v-model="updateData.director" type="text" class="form-control"
id="updateDirector"
placeholder="导演">
</div>
<div class="form-group">
<label for="updatePerformer">演员</label>
<input v-model="updateData.performer" type="text" class="form-control" id="updatePerformer"
<input v-model="updateData.performer" type="text" class="form-control"
id="updatePerformer"
placeholder="演员">
</div>
<div class="form-group">
......@@ -448,45 +449,58 @@ export default {
queryFieldText: "名字",
queryField: "",
isHaveKey: false,
fileUp: "",
selectId: undefined,
updateData: {
areaId: 13,
boxOffice: 1360582,
createTime: "2022-04-13T05:34:06.000+00:00",
director: "刘若英",
duration: 120,
id: 1,
introduction: "这是一个爱情故事,关于一对异乡漂泊的年轻人。十年前,见清 ( 井柏然 饰)和小晓 ( 周冬雨 饰)偶然地相识在归乡过年的火车上。两人怀揣着共同的梦想,一起项墓虹在北京打拼,并开始了一段相聚相离的情感之路。十年后,见清和小晓在飞机上再次偶然重逢。命运似乎是一个轮回。在一次次的偶然下,平行线交叉,再平行,故事始终有“然后” 。",
performer: "井柏然、周冬雨、田壮壮、苏小明",
poster: "http://海报",
releaseDate: "2018-04-28",
subtitle: "Us and Them",
title: "后来的我们",
typeLessId: null,
typeMainId: 1,
yearId: 26,
areaId: '',
boxOffice: '',
createTime: '',
director: '',
duration: '',
id: '',
introduction: '',
performer: '',
poster: '',
releaseDate: '',
subtitle: '',
title: '',
typeLessId: '',
typeMainId: '',
yearId: '',
},
addData: {
areaId: 13,
boxOffice: 1360582,
createTime: "2022-04-13T05:34:06.000+00:00",
director: "刘若英",
duration: 120,
id: 1,
introduction: "这是一个爱情故事,关于一对异乡漂泊的年轻人。十年前,见清 ( 井柏然 饰)和小晓 ( 周冬雨 饰)偶然地相识在归乡过年的火车上。两人怀揣着共同的梦想,一起项墓虹在北京打拼,并开始了一段相聚相离的情感之路。十年后,见清和小晓在飞机上再次偶然重逢。命运似乎是一个轮回。在一次次的偶然下,平行线交叉,再平行,故事始终有“然后” 。",
performer: "井柏然、周冬雨、田壮壮、苏小明",
poster: "http://海报",
releaseDate: "2018-04-28",
subtitle: "Us and Them",
title: "后来的我们",
typeLessId: null,
typeMainId: 1,
yearId: 26,
areaId: '',
boxOffice: '',
createTime: '',
director: '',
duration: '',
id: '',
introduction: '',
performer: '',
poster: '',
releaseDate: '',
subtitle: '',
title: '',
typeLessId: '',
typeMainId: '',
yearId: '',
},
queryFields: [
{
show: "名字",
para: "name",
para: "title",
},
{
show: "简介",
para: "introduction",
},
{
show: "演员",
para: "performer",
},
{
show: "导演",
para: "director",
}
],
list: {
......@@ -521,6 +535,46 @@ export default {
created() {
},
methods: {
updata() { // 上传文件
let myform = new FormData();
myform.append('file', $('#fileUp')[0].files[0]);
let data = request.request({
url: "/file/upload",
method: 'post',
data: myform,
contentType: false,
processData: false,
});
data.then((response) => {
let result = response.data;
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
// this.getPage(this.list.number + 1);
// 取消选择
if (this.fileUp === 'add') {
this.addData.poster = result.URL;
} else {
this.updateData.poster = result.URL;
}
console.log("更新成功" + result.fileName);
// this.showToast("更新成功");
} else if (response.code === 401) { // 没有登录
this.showToast(response.msg);
this.$parent.logout();
} else {
this.showToast(response.msg);
}
});
},
uploadImg(op) {
$('#fileUp').click();
if (op === 'add') {
this.fileUp = 'add';
} else {
this.fileUp = 'rep';
}
},
selectItem(id) {
console.log("选择了:" + id);
if (this.selectId !== id) {
......@@ -529,86 +583,74 @@ export default {
this.selectId = undefined;
}
}, upd() {
if (this.updateData.id !== undefined && this.updateData.id !== "") {
if (this.updateData.address !== undefined && this.updateData.address !== "") {
if (this.updateData.name !== undefined && this.updateData.name !== "") {
if (this.updateData.phone !== undefined && this.updateData.phone !== "") {
console.log("添加数据:");
console.log(this.updateData);
let data = request.request({
url: "/table/movie",
method: 'put',
data: this.updateData
});
data.then((response) => {
let result = response.data;
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
this.getPage(this.list.number + 1);
// 取消选择
this.selectId = undefined;
console.log("更新成功");
this.$parent.showToast("更新成功");
} else if (response.code === 401) { // 没有登录
this.showToast(response.msg);
this.$parent.logout();
} else {
this.showToast(response.msg);
}
});
} else {
this.showToast("电话号码不能为空");
}
} else {
this.showToast("名字不能为空");
}
console.log("添加数据:");
console.log(this.updateData);
let data = request.request({
url: "/table/movie",
method: 'put',
data: this.updateData
});
data.then((response) => {
let result = response.data;
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
this.getPage(this.list.number + 1);
// 取消选择
this.selectId = undefined;
console.log("更新成功");
this.$parent.showToast("更新成功");
} else if (response.code === 401) { // 没有登录
this.showToast(response.msg);
this.$parent.logout();
} else {
this.showToast("地址不能为空");
this.showToast(response.msg);
}
} else {
this.showToast("系统错误");
}
});
}, add() {
if (this.addData.address !== undefined && this.addData.address !== "") {
if (this.addData.name !== undefined && this.addData.name !== "") {
if (this.addData.phone !== undefined && this.addData.phone !== "") {
console.log("添加数据:");
console.log(this.addData);
let data = request.request({
url: "/table/movie",
method: 'post',
data: this.addData
});
data.then((response) => {
let result = response.data;
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
this.getPage(this.list.number + 1);
// 取消选择
this.selectId = undefined;
console.log("添加成功");
this.showToast("添加成功");
} else if (response.code === 401) { // 没有登录
this.showToast(response.msg);
this.$parent.logout();
} else {
this.showToast(response.msg);
}
});
this.addData.phone = "";
this.addData.name = "";
this.addData.address = "";
} else {
this.showToast("电话号码不能为空");
}
console.log("添加数据:");
console.log(this.addData);
let data = request.request({
url: "/table/movie",
method: 'post',
data: this.addData
});
data.then((response) => {
let result = response.data;
console.log("获取到的数据:");
console.log(result);
if (response.code === 200) {
this.isHaveKey = false;
this.getPage(this.list.number + 1);
// 取消选择
this.selectId = undefined;
console.log("添加成功");
this.showToast("添加成功");
} else if (response.code === 401) { // 没有登录
this.showToast(response.msg);
this.$parent.logout();
} else {
this.showToast("名字不能为空");
this.showToast(response.msg);
}
} else {
this.showToast("地址不能为空");
}
});
this.addData.areaId = '';
this.addData.boxOffice = '';
this.addData.createTime = '';
this.addData.director = '';
this.addData.duration = '';
this.addData.id = '';
this.addData.introduction = '';
this.addData.performer = '';
this.addData.poster = '';
this.addData.releaseDate = '';
this.addData.subtitle = '';
this.addData.title = '';
this.addData.typeLessId = '';
this.addData.typeMainId = '';
this.addData.yearId = '';
}
, del(id) {
if (typeof id === 'number' && id % 1 === 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册