|
@@ -69,16 +69,27 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public MaterialInfo getMaterialInfoByCodeAndProjectId(String code, Long projectId) {
|
|
|
+ QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("code", code);
|
|
|
+ queryWrapper.eq("project_id", projectId);
|
|
|
+ queryWrapper.orderByDesc("id").last("limit 1");
|
|
|
+ return this.getOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
public MaterialInfo getMaterialInfoByCode(String code) {
|
|
|
QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("code", code).orderByDesc("id").last("limit 1");
|
|
|
+ queryWrapper.eq("code", code);
|
|
|
+ queryWrapper.orderByDesc("id").last("limit 1");
|
|
|
return this.getOne(queryWrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> checkMaterialInfo(String code) {
|
|
|
+ public Map<String, Object> checkMaterialInfo(String code, Long projectId) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
- MaterialInfo info = this.getMaterialInfoByCode(code);
|
|
|
+ MaterialInfo info = this.getMaterialInfoByCodeAndProjectId(code, projectId);
|
|
|
if (null != info) {
|
|
|
//文件已存在
|
|
|
ResultMapUtils.setResultMap(result, StatusCode.FILE_HAS_UPLOAD.getCode());
|
|
@@ -166,15 +177,16 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
|
|
|
private void insertMaterialInfo(String url, String type, JSONObject jsonObject) {
|
|
|
MaterialInfo info = new MaterialInfo();
|
|
|
- info.setId(jsonObject.getString("code"));
|
|
|
- info.setCode(jsonObject.getString("code"));
|
|
|
-
|
|
|
+ Long projectId = jsonObject.getLong("projectId");
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ info.setId(code + projectId);
|
|
|
+ info.setCode(code);
|
|
|
if (!Check.isNull(jsonObject.getString("watermarkUrl"))) {
|
|
|
info.setWatermarkUrl(jsonObject.getString("watermarkUrl"));
|
|
|
}
|
|
|
info.setUrl(url);
|
|
|
info.setUserId(jsonObject.getString("userId"));
|
|
|
- info.setProjectId(jsonObject.getLong("projectId"));
|
|
|
+ info.setProjectId(projectId);
|
|
|
info.setWatermarkCode(jsonObject.getString("watermarkCode"));
|
|
|
info.setStatus(0);
|
|
|
info.setMaterialName(jsonObject.getString("materialName"));
|
|
@@ -184,10 +196,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
info.setUpdateTime(new Date());
|
|
|
info.setType(type);
|
|
|
this.save(info);
|
|
|
-
|
|
|
Map<String, Object> deleteMap = new HashMap<>();
|
|
|
deleteMap.put("material_id", info.getId());
|
|
|
-
|
|
|
JSONObject ascription = jsonObject.getJSONObject("ascription");
|
|
|
if (!Check.isNull(ascription)) {
|
|
|
MaterialAscription materialAscription = new MaterialAscription();
|