mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 05:09:21 +08:00
fix: 推广费接口 companyId 归属校验
- updatePromotionFee: 强校验记录属于当前公司,禁止越权修改 - deletePromotionFee: 强校验记录属于当前公司,禁止越权删除 - getPromotionFeeById: 强校验记录属于当前公司,禁止越权查询
This commit is contained in:
+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