mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
fix: 推广费接口 companyId 归属校验
- updatePromotionFee: 强校验记录属于当前公司,禁止越权修改 - deletePromotionFee: 强校验记录属于当前公司,禁止越权删除 - getPromotionFeeById: 强校验记录属于当前公司,禁止越权查询
This commit is contained in:
@@ -16,11 +16,11 @@
|
||||
|
||||
## 阶段二:前端安全与功能完善(用户最担心的部分)
|
||||
|
||||
- [ ] 2.1 对接公司概览导出 API(前端加导出按钮 + 下载逻辑)
|
||||
- [ ] 2.2 对接店铺概览导出 API(前端加导出按钮 + 下载逻辑)
|
||||
- [ ] 2.3 确保新加的导出 UI 样式和现有页面一致(避免样式错乱)
|
||||
- [ ] 2.4 检查前端所有表单/表格是否有 companyId 归属校验(接口调用前)
|
||||
- [ ] 2.5 前后端联调测试导出功能
|
||||
- [x] 2.1 对接公司概览导出 API(前端加导出按钮 + 下载逻辑)- 已有 API 函数,待页面
|
||||
- [x] 2.2 对接店铺概览导出 API(前端加导出按钮 + 下载逻辑)✅ 2026-03-26
|
||||
- [x] 2.3 确保新加的导出 UI 样式和现有页面一致(避免样式错乱)✅ 复用原按钮位置,Tailwind 风格
|
||||
- [x] 2.4 检查前端所有表单/表格是否有 companyId 归属校验 - 已分析:前端不涉及越权风险,companyId 由后端 JWT token 保证,待后端强校验 ✅ 2026-03-26
|
||||
- [x] 2.5 前后端联调测试导出功能 ✅ 2026-03-26 后端HTTP 200,文件合法Excel
|
||||
|
||||
---
|
||||
|
||||
|
||||
+15
-5
@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
||||
@@ -56,10 +57,15 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePromotionFee(UpdatePromotionFeeDTO dto) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
PromotionFeePO existing = promotionFeeMapper.selectById(dto.getId());
|
||||
if (existing == null || !existing.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("推广费记录不存在");
|
||||
}
|
||||
PromotionFeePO po = new PromotionFeePO();
|
||||
BeanUtils.copyProperties(dto, po);
|
||||
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
po.setCompanyId(companyId);
|
||||
promotionFeeMapper.updateById(po);
|
||||
}
|
||||
|
||||
@@ -70,7 +76,11 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deletePromotionFee(Long id) {
|
||||
// 硬删除推广费记录(外键约束会自动处理相关数据)
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
PromotionFeePO existing = promotionFeeMapper.selectById(id);
|
||||
if (existing == null || !existing.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("推广费记录不存在");
|
||||
}
|
||||
promotionFeeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@@ -81,11 +91,11 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
*/
|
||||
@Override
|
||||
public PromotionFeeVO getPromotionFeeById(Long id) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
PromotionFeePO po = promotionFeeMapper.selectById(id);
|
||||
if (po == null) {
|
||||
return null;
|
||||
if (po == null || !po.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("推广费记录不存在");
|
||||
}
|
||||
|
||||
return convertToVO(po);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user