This commit is contained in:
wangliwen 2022-05-11 10:22:47 +08:00
parent a00007992a
commit 49bf48472a
1 changed files with 10 additions and 14 deletions

View File

@ -15,6 +15,7 @@ import io.renren.modules.resource.dao.ResourceDao;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceCar.dao.ResourceCarDao;
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
@ -72,13 +73,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
});
// wrapper.eq("type", params.get("type").toString())
// .like(StringUtils.isNotBlank(params.get("name").toString()),"name", params.get("name").toString())
// .orderByDesc("create_date")
// .eq(StringUtils.isNotBlank(params.get("creator").toString()),"creator", params.get("creator").toString())
// .eq("del_flag", 0);
wrapper.orderByDesc("create_date");
if (!params.containsKey("creator")) {
if (!params.containsKey("creator")) { // 创建者查询时
wrapper.eq("del_flag", params.get("del_flag") == null ? 0 : Integer.valueOf(params.get("del_flag").toString()));
}
return wrapper;
@ -92,7 +88,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Long resourceID = IdWorker.getId(resourceEntity);
resourceEntity.setId(resourceID);
if (dto.getDelFlag() == null) {
resourceEntity.setDelFlag(0);
resourceEntity.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
}
resourceDao.insert(resourceEntity);
@ -100,7 +96,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> {
item.setDelFlag(0);
item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
item.setDataResourceId(resourceID);
attrDao.insert(item);
});
@ -130,7 +126,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
attrDao.delete4Resource(list);
List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> {
item.setDelFlag(0);
item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
attrDao.insert(item);
});
}
@ -144,7 +140,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
wrapper.eq("data_resource_id", id)
.eq("del_flag", 0);
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag());
List<AttrEntity> attrEntities = attrDao.selectList(wrapper);
resourceDTO.setInfoList(attrEntities == null ? new ArrayList<>() : attrEntities); // npe?
return resourceDTO;
@ -189,7 +185,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public List<AttrEntity> selectAttrsByResourceId(Long resourceId) {
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
wrapper.eq("data_resource_id", resourceId)
.eq("del_flag", 0)
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.orderByDesc("attr_type");
return attrDao.selectList(wrapper);
}
@ -212,7 +208,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("create_date")
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"))
.eq("del_flag", 0);
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag());
IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper);
return entityIPage;
@ -225,7 +221,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap);
page.setRecords(resourceDTOS);
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", 0).eq("type", jsonObject.getString("type"));
queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).eq("type", jsonObject.getString("type"));
Integer count = resourceDao.selectCount(queryWrapper);
page.setTotal(count);
return page;
@ -239,7 +235,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
UpdateWrapper<ResourceEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda()
.eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, 0);
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
resourceDao.update(entity, updateWrapper);
}