记得上下班打卡 | git大法好,push需谨慎

Commit 925029c2 authored by Administrator's avatar Administrator 🎨

Merge branch 'pre' into 'master'

Pre

See merge request !201
parents b5277267 90b6b426
...@@ -48,7 +48,7 @@ public class GoblinSelfCategoryAdminController extends BaseController { ...@@ -48,7 +48,7 @@ public class GoblinSelfCategoryAdminController extends BaseController {
@ResponseBody @ResponseBody
public TableDataInfo list() { public TableDataInfo list() {
PageHelper.startPage(0, 1000, "mid"); PageHelper.startPage(0, 1000, "mid");
return getDataTable(goblinSelfGoodsCategoryService.listForForMultiGrade()); return getDataTable(goblinSelfGoodsCategoryService.listForMultiGrade());
} }
@ApiOperation(value = "筛选") @ApiOperation(value = "筛选")
...@@ -115,6 +115,11 @@ public class GoblinSelfCategoryAdminController extends BaseController { ...@@ -115,6 +115,11 @@ public class GoblinSelfCategoryAdminController extends BaseController {
switch (grade) { switch (grade) {
case "1": case "1":
selfGoodsCategory.setCatePid(null); selfGoodsCategory.setCatePid(null);
queryWrapper.eq(GoblinSelfGoodsCategory::getGrade, "1");
queryWrapper.eq(GoblinSelfGoodsCategory::getName, name.trim());
if (goblinSelfGoodsCategoryService.count(queryWrapper) > 0) {
return AjaxResult.warn("分类名称重复,请核实");
}
break; break;
case "2": case "2":
queryWrapper.eq(GoblinSelfGoodsCategory::getCateId, catePid).eq(GoblinSelfGoodsCategory::getGrade, "1"); queryWrapper.eq(GoblinSelfGoodsCategory::getCateId, catePid).eq(GoblinSelfGoodsCategory::getGrade, "1");
...@@ -122,6 +127,12 @@ public class GoblinSelfCategoryAdminController extends BaseController { ...@@ -122,6 +127,12 @@ public class GoblinSelfCategoryAdminController extends BaseController {
if (null == catePidObj) { if (null == catePidObj) {
return AjaxResult.warn("父级分类无效"); return AjaxResult.warn("父级分类无效");
} }
if (catePidObj.getName().equals(name.trim())) {
return AjaxResult.warn("分类名称与父级分类重复,请核实");
}
if (goblinSelfGoodsCategoryService.countForMatchName(catePid, name.trim()) > 0) {
return AjaxResult.warn("分类名称重复,请核实");
}
break; break;
case "3": case "3":
queryWrapper.eq(GoblinSelfGoodsCategory::getCateId, catePid).eq(GoblinSelfGoodsCategory::getGrade, "2"); queryWrapper.eq(GoblinSelfGoodsCategory::getCateId, catePid).eq(GoblinSelfGoodsCategory::getGrade, "2");
...@@ -129,16 +140,16 @@ public class GoblinSelfCategoryAdminController extends BaseController { ...@@ -129,16 +140,16 @@ public class GoblinSelfCategoryAdminController extends BaseController {
if (null == catePidObj) { if (null == catePidObj) {
return AjaxResult.warn("父级分类无效"); return AjaxResult.warn("父级分类无效");
} }
if (catePidObj.getName().equals(name.trim())) {
return AjaxResult.warn("分类名称与父级分类重复,请核实");
}
if (goblinSelfGoodsCategoryService.countForMatchName(catePidObj.getCatePid(), name.trim()) > 0) {
return AjaxResult.warn("分类名称重复,请核实");
}
break; break;
default: default:
return AjaxResult.warn("分类层级无效"); return AjaxResult.warn("分类层级无效");
} }
queryWrapper.clear();
queryWrapper.eq(GoblinSelfGoodsCategory::getDelFlg, "0");
queryWrapper.eq(GoblinSelfGoodsCategory::getName, name.trim());
if (goblinSelfGoodsCategoryService.count(queryWrapper) > 0) {
return AjaxResult.warn("分类名称重复,请核实");
}
selfGoodsCategory.setCateId(IDGenerator.nextMilliId2()); selfGoodsCategory.setCateId(IDGenerator.nextMilliId2());
selfGoodsCategory.setDelFlg("0"); selfGoodsCategory.setDelFlg("0");
......
...@@ -16,7 +16,9 @@ import java.util.List; ...@@ -16,7 +16,9 @@ import java.util.List;
*/ */
public interface IGoblinSelfGoodsCategoryService extends IService<GoblinSelfGoodsCategory> { public interface IGoblinSelfGoodsCategoryService extends IService<GoblinSelfGoodsCategory> {
List<GoblinSelfGoodsCategoryDto> listForForMultiGrade(); int countForMatchName(String cateFid, String name);
List<GoblinSelfGoodsCategoryDto> listForMultiGrade();
boolean addSave(GoblinSelfGoodsCategory selfGoodsCategory); boolean addSave(GoblinSelfGoodsCategory selfGoodsCategory);
......
...@@ -46,9 +46,14 @@ public class GoblinSelfGoodsCategoryServiceImpl extends ServiceImpl<GoblinSelfGo ...@@ -46,9 +46,14 @@ public class GoblinSelfGoodsCategoryServiceImpl extends ServiceImpl<GoblinSelfGo
private RedisDataSourceUtil redisDataSourceUtil; private RedisDataSourceUtil redisDataSourceUtil;
@Override @Override
public List<GoblinSelfGoodsCategoryDto> listForForMultiGrade() { public int countForMatchName(String cateFid, String name) {
return goblinSelfGoodsCategoryMapper.countForMatchName(cateFid, name);
}
@Override
public List<GoblinSelfGoodsCategoryDto> listForMultiGrade() {
goblinSelfGoodsCategoryMapper.statsForForMultiGrade(); goblinSelfGoodsCategoryMapper.statsForForMultiGrade();
List<GoblinSelfGoodsCategoryDto> dtos = goblinSelfGoodsCategoryMapper.listForForMultiGrade(); List<GoblinSelfGoodsCategoryDto> dtos = goblinSelfGoodsCategoryMapper.listForMultiGrade();
if (!CollectionUtils.isEmpty(dtos)) { if (!CollectionUtils.isEmpty(dtos)) {
dtos.forEach(dto -> { dtos.forEach(dto -> {
if (StringUtils.isNotEmpty(dto.getTcateId())) { if (StringUtils.isNotEmpty(dto.getTcateId())) {
......
...@@ -28,43 +28,61 @@ public interface GoblinSelfGoodsCategoryMapper extends BaseMapper<GoblinSelfGood ...@@ -28,43 +28,61 @@ public interface GoblinSelfGoodsCategoryMapper extends BaseMapper<GoblinSelfGood
// ) t ON t.cate_id=gsgc.cate_id // ) t ON t.cate_id=gsgc.cate_id
//SET gsgc.counts=t.ct //SET gsgc.counts=t.ct
//WHERE gsgc.del_flg='0' //WHERE gsgc.del_flg='0'
@Update("UPDATE goblin_self_goods_category gsgc\n" + @Update("UPDATE goblin_self_goods_category gsgc " +
"INNER JOIN (\n" + "INNER JOIN (" +
" SELECT cate_fid cate_id,count(1) ct FROM goblin_goods WHERE cate_fid IS NOT NULL AND del_flg='0' group by cate_fid\n" + " SELECT cate_fid cate_id,count(1) ct FROM goblin_goods WHERE cate_fid IS NOT NULL AND del_flg='0' group by cate_fid " +
" UNION ALL\n" + " UNION ALL " +
" SELECT cate_sid cate_id,count(1) ct FROM goblin_goods WHERE cate_sid IS NOT NULL AND del_flg='0' group by cate_sid\n" + " SELECT cate_sid cate_id,count(1) ct FROM goblin_goods WHERE cate_sid IS NOT NULL AND del_flg='0' group by cate_sid " +
" UNION ALL\n" + " UNION ALL " +
" SELECT cate_tid cate_id,count(1) ct FROM goblin_goods WHERE cate_tid IS NOT NULL AND del_flg='0' group by cate_tid\n" + " SELECT cate_tid cate_id,count(1) ct FROM goblin_goods WHERE cate_tid IS NOT NULL AND del_flg='0' group by cate_tid " +
" ) t ON t.cate_id=gsgc.cate_id\n" + " ) t ON t.cate_id=gsgc.cate_id " +
"SET gsgc.counts=t.ct\n" + "SET gsgc.counts=t.ct " +
"WHERE gsgc.del_flg='0'") "WHERE gsgc.del_flg='0'")
int statsForForMultiGrade(); int statsForForMultiGrade();
// SELECT cf.cate_id AS fcateId, cf.name AS fname, cf.icon AS ficon, cf.ne_isbn AS fneIsbn, cf.counts AS fcounts , cs.cate_id AS scateId, cs.name AS sname, cs.icon AS sicon, cs.ne_isbn AS sneIsbn, cs.counts AS scounts , ct.cate_id AS tcateId, ct.name AS tname, ct.icon AS ticon, ct.ne_isbn AS tneIsbn, ct.counts AS tcounts FROM goblin_self_goods_category cf LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '2' AND del_flg = '0' ) cs ON cs.cate_pid = cf.cate_id LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '3' AND del_flg = '0' ) ct ON ct.cate_pid = cs.cate_id WHERE cf.grade = '1' AND del_flg = '0' // SELECT cf.cate_id AS fcateId, cf.name AS fname, cf.icon AS ficon, cf.ne_isbn AS fneIsbn, cf.counts AS fcounts , cs.cate_id AS scateId, cs.name AS sname, cs.icon AS sicon, cs.ne_isbn AS sneIsbn, cs.counts AS scounts , ct.cate_id AS tcateId, ct.name AS tname, ct.icon AS ticon, ct.ne_isbn AS tneIsbn, ct.counts AS tcounts FROM goblin_self_goods_category cf LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '2' AND del_flg = '0' ) cs ON cs.cate_pid = cf.cate_id LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '3' AND del_flg = '0' ) ct ON ct.cate_pid = cs.cate_id WHERE cf.grade = '1' AND del_flg = '0'
@Select({"select cf.cate_id fcateId,\n" + @Select({"select cf.cate_id fcateId," +
" cf.name fname,\n" + " cf.name fname," +
" cf.icon ficon,\n" + " cf.icon ficon," +
" cf.ne_isbn fneIsbn,\n" + " cf.ne_isbn fneIsbn," +
" cf.counts fcounts,\n" + " cf.counts fcounts," +
" cs.cate_id scateId,\n" + " cs.cate_id scateId," +
" cs.name sname,\n" + " cs.name sname," +
" cs.icon sicon,\n" + " cs.icon sicon," +
" cs.ne_isbn sneIsbn,\n" + " cs.ne_isbn sneIsbn," +
" cs.counts scounts,\n" + " cs.counts scounts," +
" ct.cate_id tcateId,\n" + " ct.cate_id tcateId," +
" ct.name tname,\n" + " ct.name tname," +
" ct.icon ticon,\n" + " ct.icon ticon," +
" ct.ne_isbn tneIsbn,\n" + " ct.ne_isbn tneIsbn," +
" ct.counts tcounts\n" + " ct.counts tcounts " +
"from goblin_self_goods_category cf\n" + "from goblin_self_goods_category cf " +
" left join (\n" + " left join (" +
" select cate_id, name, icon, grade, ne_isbn, counts, cate_pid from goblin_self_goods_category where grade = '2' and del_flg = '0'\n" + " select cate_id, name, icon, grade, ne_isbn, counts, cate_pid from goblin_self_goods_category where grade = '2' and del_flg = '0' " +
") cs on cs.cate_pid = cf.cate_id\n" + ") cs on cs.cate_pid = cf.cate_id " +
" left join (\n" + " left join (" +
" select cate_id, name, icon, grade, ne_isbn, counts, cate_pid from goblin_self_goods_category where grade = '3' and del_flg = '0'\n" + " select cate_id, name, icon, grade, ne_isbn, counts, cate_pid from goblin_self_goods_category where grade = '3' and del_flg = '0' " +
") ct on ct.cate_pid = cs.cate_id\n" + ") ct on ct.cate_pid = cs.cate_id " +
"where cf.grade = '1' and del_flg = '0'"}) "where cf.grade = '1' and del_flg = '0'"})
List<GoblinSelfGoodsCategoryDto> listForForMultiGrade(); List<GoblinSelfGoodsCategoryDto> listForMultiGrade();
List<String> listForMultiGradeCateId(@Param("cateIdArr") String[] cateIdArr); List<String> listForMultiGradeCateId(@Param("cateIdArr") String[] cateIdArr);
// SELECT count(1) AS ct FROM ( SELECT gsgc2.cate_id, gsgc2.name, gsgc2.grade, gsgc2.cate_pid FROM goblin_self_goods_category gsgc2 WHERE gsgc2.del_flg = '0' AND gsgc2.cate_pid = '2268131118729' AND gsgc2.name = 'CD' UNION SELECT gsgc3.cate_id, gsgc3.name, gsgc3.grade, gsgc3.cate_pid FROM goblin_self_goods_category gsgc2 LEFT JOIN goblin_self_goods_category gsgc3 ON gsgc2.cate_id = gsgc3.cate_pid AND gsgc3.grade = '3' WHERE gsgc2.del_flg = '0' AND gsgc2.cate_pid = '2268131118729' AND gsgc3.name = 'CD' ) t
@Select({"select count(1) ct " +
"from (" +
" SELECT gsgc2.cate_id, gsgc2.name, gsgc2.grade, gsgc2.cate_pid " +
" from goblin_self_goods_category gsgc2 " +
" where gsgc2.del_flg = '0' " +
" and gsgc2.cate_pid = #{cateFid} " +
" and gsgc2.name = #{name} " +
" union " +
" SELECT gsgc3.cate_id, gsgc3.name, gsgc3.grade, gsgc3.cate_pid " +
" from goblin_self_goods_category gsgc2 " +
" left join goblin_self_goods_category gsgc3 on gsgc2.cate_id = gsgc3.cate_pid and gsgc3.grade = '3' " +
" where gsgc2.del_flg = '0' " +
" and gsgc2.cate_pid = #{cateFid} " +
" and gsgc3.name = #{name} " +
" ) t"})
int countForMatchName(@Param("cateFid") String cateFid, @Param("name") String name);
} }
...@@ -895,10 +895,16 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -895,10 +895,16 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
}); });
LinkedList<String> toMqSqls = CollectionUtil.linkedListString(); LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_goods.update_by_shelves"));
LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
String shelvesStatus = shelvesFlg ? "3" : "1"; String shelvesStatus = shelvesFlg ? "3" : "1";
spuIdList.forEach(spuId -> updateGoodsObjs.add(new Object[]{shelvesStatus, now, uid, now, spuId, storeId})); LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
if (shelvesFlg) {
toMqSqls.add(SqlMapping.get("goblin_goods.update_by_shelves"));
spuIdList.forEach(spuId -> updateGoodsObjs.add(new Object[]{shelvesStatus, now, uid, now, spuId, storeId}));
} else {
toMqSqls.add(SqlMapping.get("goblin_goods.update_by_unshelves"));
spuIdList.forEach(spuId -> updateGoodsObjs.add(new Object[]{"1", shelvesStatus, now, uid, now, spuId, storeId}));
}
toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_shelves")); toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_shelves"));
LinkedList<Object[]> updateGoodsSkuObjs = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> updateGoodsSkuObjs = CollectionUtil.linkedListObjectArr();
spuIdList.forEach(spuId -> updateGoodsSkuObjs.add(new Object[]{shelvesStatus, now, uid, now, spuId, storeId})); spuIdList.forEach(spuId -> updateGoodsSkuObjs.add(new Object[]{shelvesStatus, now, uid, now, spuId, storeId}));
......
...@@ -510,8 +510,12 @@ public class GoblinMongoUtils { ...@@ -510,8 +510,12 @@ public class GoblinMongoUtils {
} }
public boolean updateGoodsInfoVoByShelves(String storeId, List<String> spuIdList, boolean shelvesFlg, String uid, LocalDateTime time) { public boolean updateGoodsInfoVoByShelves(String storeId, List<String> spuIdList, boolean shelvesFlg, String uid, LocalDateTime time) {
Update update = Update.update("shelvesStatus", shelvesFlg ? "3" : "1").set("shelvesAt", time).set("updatedBy", uid).set("updatedAt", time);
if (!shelvesFlg) {
update.set("shelvesHandle", "1");
}
return mongoTemplate.updateMulti(Query.query(Criteria.where("storeId").is(storeId).and("spuId").in(spuIdList.toArray())), return mongoTemplate.updateMulti(Query.query(Criteria.where("storeId").is(storeId).and("spuId").in(spuIdList.toArray())),
Update.update("shelvesStatus", shelvesFlg ? "3" : "1").set("shelvesAt", time).set("updatedBy", uid).set("updatedAt", time), update,
GoblinGoodsInfoVo.class.getSimpleName()).getModifiedCount() > 0; GoblinGoodsInfoVo.class.getSimpleName()).getModifiedCount() > 0;
} }
......
...@@ -36,7 +36,8 @@ goblin_goods_sku_spec_value.update_by_del_sku=UPDATE goblin_goods_sku_spec_value ...@@ -36,7 +36,8 @@ goblin_goods_sku_spec_value.update_by_del_sku=UPDATE goblin_goods_sku_spec_value
#---- 商品信息 #---- 商品信息
goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_price, price_ge,price_le,intro,details,cover_pic, video,spec_mode,store_id,cate_fid,cate_sid, cate_tid,store_cate_fid,store_cate_sid,store_cate_tid,brand_id, shelves_handle,shelves_time,spu_validity,virtual_flg,status, shelves_status,spu_appear,shelves_at,created_by,created_at, logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_price, price_ge,price_le,intro,details,cover_pic, video,spec_mode,store_id,cate_fid,cate_sid, cate_tid,store_cate_fid,store_cate_sid,store_cate_tid,brand_id, shelves_handle,shelves_time,spu_validity,virtual_flg,status, shelves_status,spu_appear,shelves_at,created_by,created_at, logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_goods.update_by_edit=UPDATE goblin_goods SET spu_no=?,name=?,subtitle=?,sell_price=?,intro=?,details=?,cover_pic=?,video=?,spec_mode=?,cate_fid=?,cate_sid=?,cate_tid=?,shelves_handle=?,shelves_time=?,spu_validity=?,virtual_flg=?,logistics_template=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0' goblin_goods.update_by_edit=UPDATE goblin_goods SET spu_no=?,name=?,subtitle=?,sell_price=?,intro=?,details=?,cover_pic=?,video=?,spec_mode=?,cate_fid=?,cate_sid=?,cate_tid=?,shelves_handle=?,shelves_time=?,spu_validity=?,virtual_flg=?,logistics_template=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0'
goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0' goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0'
goblin_goods.update_by_unshelves=UPDATE goblin_goods SET shelves_handle=?,shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0'
goblin_goods.update_by_status=UPDATE goblin_goods SET spu_appear=?,updated_by=?,updated_at=? WHERE store_id=? AND del_flg='0' goblin_goods.update_by_status=UPDATE goblin_goods SET spu_appear=?,updated_by=?,updated_at=? WHERE store_id=? AND del_flg='0'
goblin_goods.update_by_edit_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0' goblin_goods.update_by_edit_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0'
goblin_goods.update_by_del_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0' goblin_goods.update_by_del_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0'
......
...@@ -101,7 +101,53 @@ public class AlOssController { ...@@ -101,7 +101,53 @@ public class AlOssController {
try { try {
if (null == ossFile || (isCutFrame > 0 && ossFile.getVideoImg().isEmpty())) { //保证上传过的文件也能截帧 if (null == ossFile || (isCutFrame > 0 && ossFile.getVideoImg().isEmpty())) { //保证上传过的文件也能截帧
// 上传 // 上传
ossFile = this.uploadOssFile(file, pathName, buckType, resize, fileNew, isCutFrame); ossFile = this.uploadOssFile(file, pathName, buckType, resize, fileNew, isCutFrame, true);
}
} finally {
// 删除临时文件 因为老文件也生成了所以也要删除
FilesUtils.deleteTempFile(fileNew);
}
if (null == ossFile) {
return ResponseDto.failure("上传失败,该文件不合规,请勿上传带有联系方式、色情、涉政、广告等敏感文件");
} else {
BeanUtils.copyProperties(ossFile, uploadVo);
return ResponseDto.success(uploadVo);
}
}
@PostMapping("/upload/unsm")
@ApiOperation("阿里云上传-不鉴黄")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "File", name = "file", value = "文件", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "pathName", value = "归类的文件夹名称 比如banner上传就传 banner 返回的地址就会是bnanner/XXX", defaultValue = "test"),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "buckType", value = "buckType 1正常的任何文件上传 2apk上传", defaultValue = "1"),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "resize", value = "resize", defaultValue = "0"),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "isCutFrame", value = "是否截取帧数 用于视频获取图片 0不需要 1需要", defaultValue = "0"),
})
public ResponseDto<UploadVo> uploadUnSm(
@RequestParam MultipartFile file,
@RequestParam(defaultValue = "other") String pathName,
@RequestParam(defaultValue = "1", required = false) int buckType,
@RequestParam(defaultValue = "0", required = false) int resize,
@RequestParam(defaultValue = "0", required = false) int isCutFrame
) {
if (file.equals("") || file.getSize() <= 0) {
return ResponseDto.failure("不能上传大小为0的文件");
}
File fileNew = FilesUtils.multipartFileToFile(file);
if (null == fileNew) {
return ResponseDto.failure("multipartFileToFile Error");
}
// 是否上传过 有直接返回
PlatformOssFiles ossFile = this.getOldOssFile(fileNew);
UploadVo uploadVo = new UploadVo();
try {
if (null == ossFile || (isCutFrame > 0 && ossFile.getVideoImg().isEmpty())) { //保证上传过的文件也能截帧
// 上传
ossFile = this.uploadOssFile(file, pathName, buckType, resize, fileNew, isCutFrame, false);
} }
} finally { } finally {
// 删除临时文件 因为老文件也生成了所以也要删除 // 删除临时文件 因为老文件也生成了所以也要删除
...@@ -146,7 +192,7 @@ public class AlOssController { ...@@ -146,7 +192,7 @@ public class AlOssController {
* @param fileNew * @param fileNew
* @return * @return
*/ */
private PlatformOssFiles uploadOssFile(MultipartFile file, String pathName, int buckType, int resize, File fileNew, int isCutFrame) { private PlatformOssFiles uploadOssFile(MultipartFile file, String pathName, int buckType, int resize, File fileNew, int isCutFrame, Boolean isShuMei) {
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
int size = 0; int size = 0;
String filename, contentType, uploadPath = ""; String filename, contentType, uploadPath = "";
...@@ -167,10 +213,12 @@ public class AlOssController { ...@@ -167,10 +213,12 @@ public class AlOssController {
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, uploadPath, fileNew); PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, uploadPath, fileNew);
ossClient.putObject(putObjectRequest); ossClient.putObject(putObjectRequest);
if (contentType.contains("image") && !contentType.equals("image/vnd.adobe.photoshop")) { if (isShuMei) {
if (!shumeiUtil.checkImage(IDGenerator.nextSnowId(), imgUrl.concat(uploadPath))) { if (contentType.contains("image") && !contentType.equals("image/vnd.adobe.photoshop")) {
ossClient.deleteObject(bucketName, uploadPath); if (!shumeiUtil.checkImage(IDGenerator.nextSnowId(), imgUrl.concat(uploadPath))) {
return null; ossClient.deleteObject(bucketName, uploadPath);
return null;
}
} }
} }
...@@ -238,7 +286,7 @@ public class AlOssController { ...@@ -238,7 +286,7 @@ public class AlOssController {
private PlatformOssFiles ossFileCutFrame(String ossFileUrl, String pathName, int buckType) { private PlatformOssFiles ossFileCutFrame(String ossFileUrl, String pathName, int buckType) {
String style = "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto"; String style = "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto";
File fileNew = FilesUtils.inputStreamToFile(imgUrl.concat(ossFileUrl).concat(style), System.currentTimeMillis() + ".jpg"); File fileNew = FilesUtils.inputStreamToFile(imgUrl.concat(ossFileUrl).concat(style), System.currentTimeMillis() + ".jpg");
return this.uploadOssFile(null, pathName, buckType, 0, fileNew, 0); return this.uploadOssFile(null, pathName, buckType, 0, fileNew, 0,false);
} }
@PostMapping("/uploadUrl") @PostMapping("/uploadUrl")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment