From b2eef9a43641c090ff6d9befceb9b8193e3f17c7 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 25 Mar 2025 23:01:26 +0800 Subject: [PATCH] this is 3.24 update --- .../controller/global/GlobalController.java | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/global/GlobalController.java b/src/main/java/com/cultural/heritage/controller/global/GlobalController.java index 430ea6b..87d149f 100644 --- a/src/main/java/com/cultural/heritage/controller/global/GlobalController.java +++ b/src/main/java/com/cultural/heritage/controller/global/GlobalController.java @@ -4,9 +4,11 @@ import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; +import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; +import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.entity.*; import com.cultural.heritage.model.vo.clothes.ClothesLabelVO; import com.cultural.heritage.model.vo.good.GoodLabelVO; @@ -27,12 +29,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; @RestController @@ -82,6 +83,12 @@ public class GlobalController { private ClothesRentOrderService clothesRentOrderService; + @Resource + private RedisTemplate redisTemplate; + + + // 节日集合的键 + private static final String COUPON_PRICER_KEY = "couponPrice"; @@ -292,4 +299,37 @@ public class GlobalController { + + /** + * web端管理员修改商品优惠价格参数 + * @return 当前类别的商品列表 + */ + @GetMapping("/update/coupon/price") + @Operation(summary = "web端管理员修改商品优惠价格参数", description = "参数:无,方法名:updateCouponPrice") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse updateCouponPrice(@RequestParam BigDecimal bigDecimal) { + + redisTemplate.opsForValue().set(COUPON_PRICER_KEY, bigDecimal.toString()); + + return ResultUtils.success(true); + } + + + + + /** + * web端(小程序端)查看商品优惠价格参数 + * @return 当前类别的商品列表 + */ + @GetMapping("/query/coupon/price") + @Operation(summary = "web端(小程序端)查看商品优惠价格参数", description = "参数:无,方法名:queryCouponPrice") + public BaseResponse queryCouponPrice() { + + String couponPrice = (String) redisTemplate.opsForValue().get(COUPON_PRICER_KEY); + ThrowUtils.throwIf(couponPrice == null, ErrorCode.OPERATION_ERROR, "参数不存在"); + return ResultUtils.success(new BigDecimal(couponPrice).setScale(2, RoundingMode.HALF_UP)); + } + + + }