From da1a5ead936791e9a9494067da7980f7e5144693 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 15 一月 2025 15:03:25 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java | 75 ++++++++++++++++++++++++++++++++++---
1 files changed, 69 insertions(+), 6 deletions(-)
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java
index ae379d3..bd3ec88 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java
@@ -1,13 +1,25 @@
package com.ruoyi.other.controller;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.ServletUtils;
import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.other.api.domain.Banner;
+import com.ruoyi.other.api.domain.Goods;
+import com.ruoyi.other.api.domain.SeckillActivityInfo;
import com.ruoyi.other.service.BannerService;
+import com.ruoyi.other.service.GoodsService;
+import com.ruoyi.other.service.GoodsVipService;
+import com.ruoyi.other.service.SeckillActivityInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -27,41 +39,92 @@
public class BannerController {
@Resource
private BannerService bannerService;
+ @Resource
+ private GoodsService goodsService;
+ @Resource
+ private GoodsVipService goodsVipService;
+ @Resource
+ private SeckillActivityInfoService seckillActivityInfoService;
+ @Resource
+ private TokenService tokenService;
+ @Resource
+ private AppUserClient appUserClient;
+
+
+
@GetMapping("/list")
@ApiOperation(value = "banner列表", tags = {"小程序-banner"})
- public R<List<Banner>> list(String name, Integer jumpType, Integer position){
+ public R<List<Banner>> list(@ApiParam("名称") String name,
+ @ApiParam("跳转类型(1=无跳转,2=外部链接,3=商品详情,4=秒杀商品详情,5=领券中心)") Integer jumpType,
+ @ApiParam("位置(1=首页,2=商城首页)") Integer position){
List<Banner> list = bannerService.lambdaQuery().like(StringUtils.isNotEmpty(name), Banner::getName, name)
.eq(jumpType!=null,Banner::getJumpType, jumpType)
.eq(position!=null,Banner::getPosition, position)
.list();
+ Integer vipId = 0;
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
+ if(StringUtils.isNotEmpty(token)){
+ Long userid = tokenService.getLoginUserApplet().getUserid();
+ AppUser appUser = appUserClient.getAppUserById(userid);
+ vipId = appUser.getVipId();
+ }
+ for (Banner banner : list) {
+ Integer jumpType1 = banner.getJumpType();
+ //商品详情
+ if(null != jumpType1 && 3 == jumpType1){
+ Goods goods = goodsService.getById(banner.getContent());
+ if(null == goods || goods.getDelFlag() == 1){
+ banner.setJumpType(1);
+ }
+ if(!goods.getCommodityAuthority().contains("-1") && !goods.getCommodityAuthority().contains(vipId.toString())){
+ banner.setJumpType(1);
+ }
+ }
+ //秒杀活动
+ if(null != jumpType1 && 4 == jumpType1){
+ SeckillActivityInfo activityInfo = seckillActivityInfoService.getById(banner.getContent());
+ if(null == activityInfo || activityInfo.getDelFlag() == 1){
+ banner.setJumpType(1);
+ }
+ if(!activityInfo.getVipIds().contains(vipId.toString())){
+ banner.setJumpType(1);
+ }
+ }
+ }
return R.ok(list);
}
@PostMapping("/add")
- @ApiOperation(value = "添加", tags = {"后台-广告管理-banner管理"})
+ @ApiOperation(value = "广告管理-banner管理-添加", tags = {"管理后台"})
public R add(@RequestBody Banner banner){
bannerService.save(banner);
return R.ok();
}
@GetMapping("/delete")
- @ApiOperation(value = "删除", tags = {"后台-广告管理-banner管理"})
+ @ApiOperation(value = "广告管理-banner管理-删除", tags = {"管理后台"})
public R delete(@RequestParam Integer id){
bannerService.removeById(id);
return R.ok();
}
@PostMapping("/edit")
- @ApiOperation(value = "修改", tags = {"后台-广告管理-banner管理"})
+ @ApiOperation(value = "广告管理-banner管理-修改", tags = {"管理后台"})
public R edit(@RequestBody Banner banner){
bannerService.updateById(banner);
+ if (banner.getContentType()==2){
+ LambdaUpdateWrapper<Banner> bannerLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+ bannerLambdaUpdateWrapper.set(Banner::getJumpType,null);
+ bannerLambdaUpdateWrapper.eq(Banner::getId,banner.getId());
+ bannerService.update(bannerLambdaUpdateWrapper);
+ }
return R.ok();
}
@GetMapping("/detail")
- @ApiOperation(value = "详情", tags = {"后台-广告管理-banner管理"})
+ @ApiOperation(value = "广告管理-banner管理-详情", tags = {"管理后台"})
public R detail(@RequestParam Integer id){
Banner byId = bannerService.getById(id);
return R.ok(byId);
}
@GetMapping("/page/list")
- @ApiOperation(value = "列表", tags = {"后台-广告管理--banner"})
+ @ApiOperation(value = "广告管理-banner-列表", tags = {"管理后台"})
public R<Page<Banner>> pagelist(String name, Integer jumpType, Integer position,Integer pageNum,Integer pageSize){
Page<Banner> page = bannerService.lambdaQuery().like(StringUtils.isNotEmpty(name), Banner::getName, name)
.eq(jumpType!=null,Banner::getJumpType, jumpType)
--
Gitblit v1.7.1