Skip to content

Commit 303e297

Browse files
committed
update
1 parent 9489337 commit 303e297

File tree

28 files changed

+618
-124
lines changed

28 files changed

+618
-124
lines changed

yiying-service-api/yiying-service-api-movie/src/main/java/com/yiying/movie/service/MMovieVideoService.java

+2
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ public interface MMovieVideoService extends IService<MMovieVideo> {
2828

2929

3030
MMovieVideo getByMovieId(String movieId);
31+
32+
String getPlayPath(String videoId);
3133
}

yiying-service-api/yiying-service-api-movie/src/main/java/com/yiying/movie/vo/MovieVo.java

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ public class MovieVo implements Serializable {
2929
private String[] date;
3030
private BigDecimal price;
3131
private String subjectHallId;
32+
private int[][] seat;
3233

3334
}

yiying-service-api/yiying-service-api-oss/pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
<artifactId>yiying-service-api-oss</artifactId>
1313

14-
14+
<dependencies>
15+
<dependency>
16+
<groupId>net.oschina.zcx7878</groupId>
17+
<artifactId>fastdfs-client-java</artifactId>
18+
<version>1.27.0.0</version>
19+
</dependency>
20+
</dependencies>
1521

1622
</project>

yiying-service-api/yiying-service-api-oss/src/main/java/com/yiying/oss/service/FileService.java

+6
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ public interface FileService {
99
* @return
1010
*/
1111
String upload(MultipartFile file);
12+
/**
13+
* 输出文件到fastdfs
14+
* @param fileStr
15+
* @return
16+
*/
17+
String uploadToFastDfs(String fileStr);
1218
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
package com.yiying.oss.util;
2+
3+
import org.csource.common.NameValuePair;
4+
import org.csource.fastdfs.*;
5+
import org.springframework.core.io.ClassPathResource;
6+
7+
import java.io.ByteArrayInputStream;
8+
import java.io.IOException;
9+
import java.io.InputStream;
10+
11+
/**
12+
* 描述
13+
*
14+
* @since 1.0
15+
*/
16+
public class FastDFSClient {
17+
18+
static {
19+
//从classpath下获取文件对象获取路径
20+
String path = new ClassPathResource("fdfs_client.conf").getPath();
21+
try {
22+
ClientGlobal.init(path);
23+
} catch (Exception e) {
24+
e.printStackTrace();
25+
}
26+
}
27+
28+
//图片上传
29+
public static String[] upload(FastDFSFile file) {
30+
try {
31+
TrackerClient trackerClient = new TrackerClient();
32+
TrackerServer trackerServer = trackerClient.getConnection();
33+
StorageClient storageClient = new StorageClient(trackerServer, null);
34+
//参数1 字节数组
35+
//参数2 扩展名(不带点)
36+
//参数3 元数据( 文件的大小,文件的作者,文件的创建时间戳)
37+
NameValuePair[] meta_list = new NameValuePair[]{new NameValuePair(file.getAuthor()), new NameValuePair(file.getName())};
38+
39+
String[] strings = storageClient.upload_file(file.getContent(), file.getExt(), meta_list);
40+
41+
return strings;// strings[0]==group1 strings[1]=M00/00/00/wKjThF1aW9CAOUJGAAClQrJOYvs424.jpg
42+
} catch (Exception e) {
43+
e.printStackTrace();
44+
}
45+
return null;
46+
}
47+
48+
49+
//图片下载
50+
public static InputStream downFile(String groupName, String remoteFileName) {
51+
ByteArrayInputStream byteArrayInputStream = null;
52+
try {
53+
//3.创建trackerclient对象
54+
TrackerClient trackerClient = new TrackerClient();
55+
//4.创建trackerserver 对象
56+
TrackerServer trackerServer = trackerClient.getConnection();
57+
//5.创建stroageserver 对象
58+
//6.创建storageclient 对象
59+
StorageClient storageClient = new StorageClient(trackerServer, null);
60+
//7.根据组名 和 文件名 下载图片
61+
62+
//参数1:指定组名
63+
//参数2 :指定远程的文件名
64+
byte[] bytes = storageClient.download_file(groupName, remoteFileName);
65+
byteArrayInputStream = new ByteArrayInputStream(bytes);
66+
return byteArrayInputStream;
67+
} catch (Exception e) {
68+
e.printStackTrace();
69+
} finally {
70+
try {
71+
if (byteArrayInputStream != null) {
72+
byteArrayInputStream.close();
73+
}
74+
} catch (IOException e) {
75+
e.printStackTrace();
76+
}
77+
}
78+
return null;
79+
}
80+
81+
82+
//图片删除
83+
84+
public static void deleteFile(String groupName, String remoteFileName) {
85+
try {
86+
//3.创建trackerclient对象
87+
TrackerClient trackerClient = new TrackerClient();
88+
//4.创建trackerserver 对象
89+
TrackerServer trackerServer = trackerClient.getConnection();
90+
//5.创建stroageserver 对象
91+
//6.创建storageclient 对象
92+
StorageClient storageClient = new StorageClient(trackerServer, null);
93+
int i = storageClient.delete_file(groupName, remoteFileName);
94+
if (i == 0) {
95+
System.out.println("删除成功");
96+
} else {
97+
System.out.println("删除失败");
98+
}
99+
} catch (Exception e) {
100+
e.printStackTrace();
101+
}
102+
}
103+
104+
//根据组名获取组的信息
105+
106+
public static StorageServer getStorages(String groupName) {
107+
try {
108+
TrackerClient trackerClient = new TrackerClient();
109+
//4.创建trackerserver 对象
110+
TrackerServer trackerServer = trackerClient.getConnection();
111+
112+
//参数1 指定traqckerserver 对象
113+
//参数2 指定组名
114+
StorageServer group1 = trackerClient.getStoreStorage(trackerServer, groupName);
115+
return group1;
116+
} catch (IOException e) {
117+
e.printStackTrace();
118+
}
119+
return null;
120+
}
121+
122+
//根据文件名和组名获取文件的信息
123+
124+
public static FileInfo getFile(String groupName, String remoteFileName) {
125+
try {
126+
TrackerClient trackerClient = new TrackerClient();
127+
//4.创建trackerserver 对象
128+
TrackerServer trackerServer = trackerClient.getConnection();
129+
130+
StorageClient storageClient = new StorageClient(trackerServer, null);
131+
132+
//参数1 指定组名
133+
//参数2 指定文件的路径
134+
FileInfo fileInfo = storageClient.get_file_info(groupName, remoteFileName);
135+
return fileInfo;
136+
} catch (Exception e) {
137+
e.printStackTrace();
138+
}
139+
return null;
140+
}
141+
142+
143+
//根据文件名和组名 获取组信息的数组信息
144+
public static ServerInfo[] getServerInfo(String groupName, String remoteFileName){
145+
try {
146+
//3.创建trackerclient对象
147+
TrackerClient trackerClient = new TrackerClient();
148+
//4.创建trackerserver 对象
149+
TrackerServer trackerServer = trackerClient.getConnection();
150+
151+
ServerInfo[] group1s = trackerClient.getFetchStorages(trackerServer, groupName, remoteFileName);
152+
return group1s;
153+
} catch (IOException e) {
154+
e.printStackTrace();
155+
}
156+
return null;
157+
158+
}
159+
160+
//获取tracker 的ip和端口的信息
161+
//http://192.168.211.132:8080
162+
public static String getTrackerUrl(){
163+
try {
164+
//3.创建trackerclient对象
165+
TrackerClient trackerClient = new TrackerClient();
166+
//4.创建trackerserver 对象
167+
TrackerServer trackerServer = trackerClient.getConnection();
168+
//tracker 的ip的信息
169+
String hostString = trackerServer.getInetSocketAddress().getHostString();
170+
171+
//http://192.168.211.132:8080/group1/M00/00/00/wKjThF1aW9CAOUJGAAClQrJOYvs424.jpg img
172+
int g_tracker_http_port = ClientGlobal.getG_tracker_http_port();
173+
return "http://" + hostString + ":" + g_tracker_http_port;
174+
} catch (IOException e) {
175+
e.printStackTrace();
176+
}
177+
return null;
178+
}
179+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.yiying.oss.util;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
*/
7+
public class FastDFSFile implements Serializable {
8+
9+
//文件名字
10+
private String name;
11+
//文件内容
12+
private byte[] content;
13+
//文件扩展名
14+
private String ext;
15+
//文件MD5摘要值
16+
private String md5;
17+
//文件创建作者
18+
private String author;
19+
20+
public FastDFSFile(String name, byte[] content, String ext, String md5, String author) {
21+
this.name = name;
22+
this.content = content;
23+
this.ext = ext;
24+
this.md5 = md5;
25+
this.author = author;
26+
}
27+
28+
public FastDFSFile(String name, byte[] content, String ext) {
29+
this.name = name;
30+
this.content = content;
31+
this.ext = ext;
32+
}
33+
34+
public FastDFSFile() {
35+
}
36+
37+
public String getName() {
38+
return name;
39+
}
40+
41+
public void setName(String name) {
42+
this.name = name;
43+
}
44+
45+
public byte[] getContent() {
46+
return content;
47+
}
48+
49+
public void setContent(byte[] content) {
50+
this.content = content;
51+
}
52+
53+
public String getExt() {
54+
return ext;
55+
}
56+
57+
public void setExt(String ext) {
58+
this.ext = ext;
59+
}
60+
61+
public String getMd5() {
62+
return md5;
63+
}
64+
65+
public void setMd5(String md5) {
66+
this.md5 = md5;
67+
}
68+
69+
public String getAuthor() {
70+
return author;
71+
}
72+
73+
public void setAuthor(String author) {
74+
this.author = author;
75+
}
76+
}

yiying-service/service-movie/src/main/java/com/yiying/movie/controller/MMovieVideoController.java

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public Result getVideoById(@PathVariable String movieId) {
5555
return Result.ok().data("video", video);
5656
}
5757

58+
@GetMapping("getPlayPath/{videoId}")
59+
public Result getPlayPath(@PathVariable String videoId) {
60+
61+
String path = videoService.getPlayPath(videoId);
62+
return Result.ok().data("path",path);
63+
}
5864

5965

6066
}

yiying-service/service-movie/src/main/java/com/yiying/movie/service/impl/MMovieServiceImpl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
55
import com.baomidou.mybatisplus.core.metadata.IPage;
66
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7-
import com.yiying.VodService;
87
import com.yiying.config.QiException;
98
import com.yiying.movie.dto.PlayHallSeat;
109
import com.yiying.movie.entity.*;
@@ -15,12 +14,14 @@
1514
import com.yiying.movie.vo.MoviePublishVo;
1615
import com.yiying.movie.vo.MovieQuery;
1716
import com.yiying.movie.vo.MovieVo;
17+
import com.yiying.vod.service.VodService;
1818
import org.apache.commons.lang3.StringUtils;
1919
import org.apache.dubbo.config.annotation.Reference;
2020
import org.apache.dubbo.config.annotation.Service;
2121
import org.springframework.beans.BeanUtils;
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.cache.annotation.CacheEvict;
24+
import org.springframework.cache.annotation.Cacheable;
2425
import org.springframework.transaction.annotation.Transactional;
2526

2627
import java.math.BigDecimal;
@@ -350,7 +351,7 @@ public boolean removeByMovieId(String id) {
350351
*
351352
* @return
352353
*/
353-
@Cacheable(value = "movie",key = "TopEightMovie")
354+
@Cacheable(value = "movie",key = "'TopEightMovie'")
354355
@Override
355356
public List<MMovie> getTopEightMovie() {
356357
LambdaQueryWrapper<MMovie> wrapper = new LambdaQueryWrapper<>();

yiying-service/service-movie/src/main/java/com/yiying/movie/service/impl/MMovieVideoServiceImpl.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.yiying.movie.service.impl;
22

33
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4-
import com.yiying.VodService;
4+
import com.yiying.vod.service.VodService;
55
import com.yiying.movie.entity.MMovie;
66
import com.yiying.movie.entity.MMovieVideo;
77
import com.yiying.movie.mapper.MMovieVideoMapper;
@@ -67,4 +67,13 @@ public MMovieVideo getByMovieId(String movieId) {
6767
MMovieVideo mMovieVideo = baseMapper.selectOne(wrapper);
6868
return mMovieVideo;
6969
}
70+
71+
@Override
72+
public String getPlayPath(String videoId) {
73+
74+
LambdaQueryWrapper<MMovieVideo> wrapper = new LambdaQueryWrapper<>();
75+
wrapper.eq(MMovieVideo::getVideoSourceId,videoId);
76+
MMovieVideo one = this.getOne(wrapper);
77+
return one.getVideoOriginalName();
78+
}
7079
}

yiying-service/service-order/src/main/java/com/yiying/order/service/MOrderServiceImpl.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.yiying.order.service;
22

3-
import cn.hutool.Hutool;
43
import cn.hutool.core.util.RandomUtil;
54
import com.alibaba.fastjson.JSON;
65
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -87,7 +86,7 @@ public OrderVo getByOrderNo(String orderNo) {
8786
* @return
8887
*/
8988
@Override
90-
public String queryByOutTradeNo(String out_trade_no) {
89+
public HashMap<String, String> queryByOutTradeNo(String out_trade_no) {
9190

9291
LambdaQueryWrapper<MOrder> wrapper = new LambdaQueryWrapper<>();
9392
wrapper.eq(MOrder::getOrderId, out_trade_no);
@@ -98,7 +97,11 @@ public int compare(T o1, T o2) {
9897
return 0;
9998
}
10099
});*/
101-
return order.getMovieId();
100+
String memberId = order.getMemberId();
101+
HashMap<String, String> map = new HashMap<>();
102+
map.put("memberId",memberId);
103+
map.put("movieId",order.getMovieId());
104+
return map;
102105
}
103106

104107
/**

0 commit comments

Comments
 (0)