|
@@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 素材信息
|
|
@@ -46,9 +48,21 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public boolean imgLocation(String fileName) throws IOException {
|
|
|
+ String reg = "(mp4|flv|avi|rm|rmvb|wmv)";
|
|
|
+ Pattern p = Pattern.compile(reg);
|
|
|
+ return p.matcher(fileName).find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String reg = "(mp4|flv|avi|rm|rmvb|wmv)";
|
|
|
+ Pattern p = Pattern.compile(reg);
|
|
|
+ System.out.println(p.matcher("https://ctop-media.oss-cn-beijing.aliyuncs.com/video/2019-10-30/ios%E6%8E%A8%E5%B9%BF%E8%A7%86%E9%A2%91-1572437289724.mp4").find());
|
|
|
+ }
|
|
|
@Override
|
|
|
- public Map<String, Object> insert(String userId, String code, String url) {
|
|
|
+ public Map<String, Object> insert(String userId, String code, String url) throws IOException {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ Boolean isVideo = imgLocation(url);
|
|
|
MaterialInfo info = new MaterialInfo();
|
|
|
info.setId(code);
|
|
|
info.setCode(code);
|
|
@@ -57,6 +71,11 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
info.setUserId(userId);
|
|
|
info.setCreateTime(new Date());
|
|
|
info.setUpdateTime(new Date());
|
|
|
+ if (isVideo) {
|
|
|
+ info.setType("VIDEO");
|
|
|
+ } else {
|
|
|
+ info.setType("IMAGE");
|
|
|
+ }
|
|
|
this.save(info);
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
|
|
|
return resultMap;
|