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.pricing.service.VoucherCodeService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/pricing/voucher")
|
@RequestMapping("/api/pricing/voucher")
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class VoucherManagementController {
|
public class VoucherManagementController {
|
||||||
|
@Autowired
|
||||||
private final VoucherBatchService voucherBatchService;
|
@Lazy
|
||||||
private final VoucherCodeService voucherCodeService;
|
private VoucherBatchService voucherBatchService;
|
||||||
|
@Autowired
|
||||||
|
@Lazy
|
||||||
|
private VoucherCodeService voucherCodeService;
|
||||||
|
|
||||||
@PostMapping("/batch/create")
|
@PostMapping("/batch/create")
|
||||||
public ApiResponse<Long> createBatch(@RequestBody VoucherBatchCreateReq req) {
|
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 com.ycwl.basic.pricing.service.VoucherCodeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -22,11 +24,12 @@ import org.springframework.util.StringUtils;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class VoucherBatchServiceImpl implements VoucherBatchService {
|
public class VoucherBatchServiceImpl implements VoucherBatchService {
|
||||||
|
@Autowired
|
||||||
private final PriceVoucherBatchConfigMapper voucherBatchMapper;
|
private PriceVoucherBatchConfigMapper voucherBatchMapper;
|
||||||
private final VoucherCodeService voucherCodeService;
|
@Autowired
|
||||||
|
@Lazy
|
||||||
|
private VoucherCodeService voucherCodeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@@ -16,6 +16,8 @@ import com.ycwl.basic.pricing.service.VoucherBatchService;
|
|||||||
import com.ycwl.basic.pricing.service.VoucherCodeService;
|
import com.ycwl.basic.pricing.service.VoucherCodeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -26,12 +28,15 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class VoucherCodeServiceImpl implements VoucherCodeService {
|
public class VoucherCodeServiceImpl implements VoucherCodeService {
|
||||||
|
|
||||||
private final PriceVoucherCodeMapper voucherCodeMapper;
|
@Autowired
|
||||||
private final PriceVoucherBatchConfigMapper voucherBatchMapper;
|
private PriceVoucherCodeMapper voucherCodeMapper;
|
||||||
private final VoucherBatchService voucherBatchService;
|
@Autowired
|
||||||
|
private PriceVoucherBatchConfigMapper voucherBatchMapper;
|
||||||
|
@Autowired
|
||||||
|
@Lazy
|
||||||
|
private VoucherBatchService voucherBatchService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateVoucherCodes(Long batchId, Long scenicId, Integer count) {
|
public void generateVoucherCodes(Long batchId, Long scenicId, Integer count) {
|
||||||
|
Reference in New Issue
Block a user