zss
4 天以前 43113d6b1670530dfb4348836fd491c79f36af0a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.ruoyi.projectManagement.service.impl.handle;
 
import cn.hutool.core.bean.BeanUtil;
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);
        }
    }
}