|
@@ -73,24 +73,15 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result removes(String ids) {
|
|
|
- String[] split = StrUtil.split(ids, ",");
|
|
|
- for (String s : split) {
|
|
|
- Long id = Long.valueOf(s);
|
|
|
- GoodsEntity entity = this.findById(id);
|
|
|
- if (entity != null) {
|
|
|
- // 删除物理文件
|
|
|
- List<FileEntity> files = fileService.findByModuleId(id, TypeCode.MODULE_GOODS);
|
|
|
- for (FileEntity file : files) {
|
|
|
- fileService.remove(file.getId());
|
|
|
- }
|
|
|
-
|
|
|
- entity.setIsDelete(1);
|
|
|
- this.update(entity);
|
|
|
- }
|
|
|
+ public void removes(String ids) {
|
|
|
+ if (StringUtils.isBlank(ids)){
|
|
|
+ log.warn("参数为空,不需要更新");
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
- return Result.success();
|
|
|
+ // 防止sql注入
|
|
|
+ RegexUtil.regSql(ids);
|
|
|
+ String sql = StrUtil.format("update tb_goods set is_delete=1, update_time=NOW() where is_delete=0 and id in ({})", ids);
|
|
|
+ entityMapper.strSql(sql);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -115,6 +106,7 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public Result detail(Long id) {
|
|
|
GoodsEntity entity = this.findById(id);
|
|
@@ -136,10 +128,7 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
|
|
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
- public Result<SceneEntity> projectId(Long projectId) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -195,27 +184,7 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 保存文件且保存文件信息
|
|
|
- * @param projectId 项目id
|
|
|
- * @param type 文物类型 doc, model
|
|
|
- * @param files 文件
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void saveAndUpload(Long projectId, String type, List<MultipartFile> files) {
|
|
|
- String savePath = PREFIX_PATH + "/" + projectId + "/" + type;
|
|
|
- GoodsEntity entity;
|
|
|
- String fileName;
|
|
|
- for (MultipartFile file : files) {
|
|
|
- fileName = fileUtils.upload(file, savePath, true);
|
|
|
- entity = new GoodsEntity();
|
|
|
- entity.setProjectId(projectId);
|
|
|
- entity.setName(file.getOriginalFilename());
|
|
|
- entity.setType(type);
|
|
|
- entity.setFilePath(savePath + "/" + fileName);
|
|
|
- this.save(entity);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 封面图默认是第一张(若果文件id没有index值时),只有前端设置了封面,才会更新文件封面
|
|
@@ -256,25 +225,23 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
|
|
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void bindingProjectIdToEntity(Long projectId, String goodsIds) {
|
|
|
|
|
|
+ if (StringUtils.isBlank(goodsIds)){
|
|
|
+ log.warn("不需要更新");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result modelUpload(MultipartFile file, String projectId) {
|
|
|
- String savePath = PREFIX_PATH + "/" + projectId + "/" + TypeCode.GOODS_MODEL;
|
|
|
- String newFileName = fileUtils.upload(file, savePath, true);
|
|
|
- savePath = savePath + "/" + newFileName;
|
|
|
- Long id = fileService.saveFile(savePath, file.getOriginalFilename(), TypeCode.MODULE_GOODS, TypeCode.GOODS_MODEL);
|
|
|
- HashMap<Object, Object> result = new HashMap<>();
|
|
|
- result.put("id", id);
|
|
|
- result.put("filePath", savePath);
|
|
|
- return Result.success(result);
|
|
|
+ // 防止sql注入
|
|
|
+ RegexUtil.regSql(goodsIds);
|
|
|
+ String sql = StrUtil.format("update tb_goods set project_id={}, update_time=NOW() where is_delete=0 and id in ({})", projectId, goodsIds);
|
|
|
+ entityMapper.strSql(sql);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result modelBinding(String projectId, String goodsIds) {
|
|
|
- projectMapper.setGoodsIdsById(projectId, goodsIds);
|
|
|
- return Result.success();
|
|
|
+ public List<GoodsEntity> findByProjectId(Long projectId) {
|
|
|
+ return entityMapper.findByProjectId(projectId);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -283,4 +250,9 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|