package com.ruoyi.projectManagement.service.impl.handle;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ruoyi.projectManagement.dto.ShippingAddressDto;
|
import com.ruoyi.projectManagement.mapper.ShippingAddressMapper;
|
import com.ruoyi.projectManagement.pojo.ShippingAddress;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Component;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Nullable;
|
import javax.validation.constraints.NotNull;
|
|
/**
|
* @author buhuazhen
|
* @date 2026/3/9
|
* @email 3038525872@qq.com
|
*/
|
@Component
|
@RequiredArgsConstructor
|
@Transactional(rollbackFor = Exception.class,readOnly = true)
|
public class ShippingAddressHandleService {
|
|
private final ShippingAddressMapper shippingAddressMapper;
|
|
@Transactional(rollbackFor = Exception.class)
|
public void save(@Nullable Long infoId,@NotNull ShippingAddressDto shippingAddressDto){
|
ShippingAddress shippingAddress = BeanUtil.copyProperties(shippingAddressDto, ShippingAddress.class);
|
shippingAddress.setProjectManagementInfoId(infoId);
|
if (shippingAddressDto.getId() == null) {
|
shippingAddressMapper.insert(shippingAddress);
|
}else {
|
shippingAddressMapper.updateById(shippingAddress);
|
}
|
}
|
|
|
public ShippingAddressDto getByInfoId(@NotNull Long id) {
|
LambdaQueryWrapper<ShippingAddress> queryWrapper = new LambdaQueryWrapper<ShippingAddress>();
|
queryWrapper.eq(ShippingAddress::getProjectManagementInfoId, id);
|
queryWrapper.eq(ShippingAddress::getIsDelete, 0);
|
queryWrapper.last("limit 1");
|
ShippingAddress shippingAddress = shippingAddressMapper.selectOne(queryWrapper);
|
return BeanUtil.copyProperties(shippingAddress, ShippingAddressDto.class);
|
}
|
}
|