fix(oa): 修复产品列表查询问题

- 在 GearProductMapper.xml 中添加产品分类的删除标志过滤条件
- 在 GearProductServiceImpl 中添加产品删除标志的查询条件
- 优化产品插入和更新逻辑,使用 Hutool 的 BeanUtil 进行对象转换
- 新增 validEntityBeforeSave 方法用于保存前的数据校验
This commit is contained in:
2025-09-02 16:53:32 +08:00
parent bb28f02aa8
commit d64a66e0fe
2 changed files with 15 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import java.util.Collection;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import com.gear.common.utils.StringUtils;
@@ -80,6 +81,7 @@ public class GearProductServiceImpl implements IGearProductService {
if (bo.getIsEnabled() != null) {
queryWrapper.eq("p.is_enabled", bo.getIsEnabled());
}
queryWrapper.eq("p.del_flag", 0);
return queryWrapper;
}
@@ -113,9 +115,8 @@ public class GearProductServiceImpl implements IGearProductService {
*/
@Override
public Boolean insertByBo(GearProductBo bo) {
GearProduct add = new GearProduct();
// 设置属性
// ...
GearProduct add = BeanUtil.toBean(bo, GearProduct.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setProductId(add.getProductId());
@@ -123,16 +124,23 @@ public class GearProductServiceImpl implements IGearProductService {
return flag;
}
/**
* 修改产品
*/
@Override
public Boolean updateByBo(GearProductBo bo) {
GearProduct update = new GearProduct();
// 设置属性
// ...
GearProduct update = BeanUtil.toBean(bo, GearProduct.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(GearProduct entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除产品

View File

@@ -41,7 +41,7 @@
p.remark AS remark
FROM
gear_product p
Left join gear_product_category c on p.category_id = c.category_id
Left join gear_product_category c on p.category_id = c.category_id and c.del_flag = 0
${ew.customSqlSegment}
</select>