You've already forked FrameTour-BE
refactor(pricing): 重构优惠券管理相关代码
- 替换 Lombok 的 @RequiredArgsConstructor 注解为 Spring 的 @Autowired 和 @Lazy 注解 - 更新 VoucherManagementController、VoucherBatchServiceImpl 和 VoucherCodeServiceImpl 类的依赖注入方式 - 优化代码结构,提高可读性和可维护性
This commit is contained in:
@@ -12,17 +12,21 @@ import com.ycwl.basic.pricing.service.VoucherBatchService;
|
||||
import com.ycwl.basic.pricing.service.VoucherCodeService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/pricing/voucher")
|
||||
@RequiredArgsConstructor
|
||||
public class VoucherManagementController {
|
||||
|
||||
private final VoucherBatchService voucherBatchService;
|
||||
private final VoucherCodeService voucherCodeService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private VoucherBatchService voucherBatchService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private VoucherCodeService voucherCodeService;
|
||||
|
||||
@PostMapping("/batch/create")
|
||||
public ApiResponse<Long> createBatch(@RequestBody VoucherBatchCreateReq req) {
|
||||
|
@@ -15,6 +15,8 @@ import com.ycwl.basic.pricing.service.VoucherBatchService;
|
||||
import com.ycwl.basic.pricing.service.VoucherCodeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -22,11 +24,12 @@ import org.springframework.util.StringUtils;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VoucherBatchServiceImpl implements VoucherBatchService {
|
||||
|
||||
private final PriceVoucherBatchConfigMapper voucherBatchMapper;
|
||||
private final VoucherCodeService voucherCodeService;
|
||||
@Autowired
|
||||
private PriceVoucherBatchConfigMapper voucherBatchMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private VoucherCodeService voucherCodeService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
|
@@ -16,6 +16,8 @@ import com.ycwl.basic.pricing.service.VoucherBatchService;
|
||||
import com.ycwl.basic.pricing.service.VoucherCodeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -26,12 +28,15 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VoucherCodeServiceImpl implements VoucherCodeService {
|
||||
|
||||
private final PriceVoucherCodeMapper voucherCodeMapper;
|
||||
private final PriceVoucherBatchConfigMapper voucherBatchMapper;
|
||||
private final VoucherBatchService voucherBatchService;
|
||||
|
||||
@Autowired
|
||||
private PriceVoucherCodeMapper voucherCodeMapper;
|
||||
@Autowired
|
||||
private PriceVoucherBatchConfigMapper voucherBatchMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private VoucherBatchService voucherBatchService;
|
||||
|
||||
@Override
|
||||
public void generateVoucherCodes(Long batchId, Long scenicId, Integer count) {
|
||||
|
Reference in New Issue
Block a user