From 046b12aebefbaed81cb3289dcb44c6c72b82a65d Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 07 八月 2024 16:21:19 +0800 Subject: [PATCH] 管理后台代码生成 --- ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java | 1 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TGoodsMapper.java | 8 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TAdvertisingServiceImpl.java | 13 ++ ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TActivity.java | 4 ruoyi-service/ruoyi-other/src/main/resources/mapper/TActivityMapper.xml | 19 +++ ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java | 27 ++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TAdvertisingController.java | 12 +- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java | 1 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java | 48 +++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TActivityServiceImpl.java | 24 ++++ /dev/null | 15 -- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TActivityController.java | 45 ++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TGoodsService.java | 4 ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 3 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TGoods.java | 4 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java | 1 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TActivityMapper.java | 7 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TActivityService.java | 3 ruoyi-service/ruoyi-other/src/main/resources/mapper/TGoodsMapper.xml | 19 +++ ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java | 21 +++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java | 27 ++++ ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/GoodsDTO.java | 19 +++ 22 files changed, 290 insertions(+), 35 deletions(-) diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java new file mode 100644 index 0000000..165973b --- /dev/null +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java @@ -0,0 +1,27 @@ +package com.ruoyi.order.api.factory; + +import com.ruoyi.order.api.feignClient.ChargingOrderClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 充电订单服务降级处理 + * + * @author ruoyi + */ +@Component +public class OrderFallbackFactory implements FallbackFactory<ChargingOrderClient> +{ + private static final Logger log = LoggerFactory.getLogger(OrderFallbackFactory.class); + + + @Override + public ChargingOrderClient create(Throwable cause) { + log.error("商品订单调用失败:{}", cause.getMessage()); + return new ChargingOrderClient() { + + }; + } +} diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java new file mode 100644 index 0000000..c763d67 --- /dev/null +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java @@ -0,0 +1,21 @@ +package com.ruoyi.order.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory; +import com.ruoyi.order.api.factory.OrderFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +/** + * 后台订单服务 + * @author ruoyi + */ +@FeignClient(contextId = "OrderClient", value = ServiceNameConstants.CONTRACT_ORDER, fallbackFactory = OrderFallbackFactory.class) +public interface OrderClient { + + @PostMapping("/t-exchange-order/getSalesCountByGoodsIds") + R<List<Integer>> getSalesCountByGoodsId(String goodsIds); +} diff --git a/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 110ae30..cb88519 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,2 @@ -com.ruoyi.order.api.factory.ChargingOrderFallbackFactory \ No newline at end of file +com.ruoyi.order.api.factory.ChargingOrderFallbackFactory +com.ruoyi.order.api.factory.OrderFallbackFactory \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TActivity.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TActivity.java index 51772f3..cc4c040 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TActivity.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TActivity.java @@ -58,7 +58,9 @@ @TableField("status") private Integer status; - + @ApiModelProperty(value = "活动状态 1未开始 2已开始 3已结束") + @TableField(exist = false) + private Integer startState; } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TGoods.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TGoods.java index 6b9bfdf..2e32a95 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TGoods.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TGoods.java @@ -100,6 +100,8 @@ private Integer status; - + @ApiModelProperty(value = "销量") + @TableField(exist = false) + private Integer salesCount; } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/GoodsDTO.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/GoodsDTO.java new file mode 100644 index 0000000..ea83f00 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/GoodsDTO.java @@ -0,0 +1,19 @@ +package com.ruoyi.other.api.dto; + +import com.ruoyi.common.core.web.page.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("商品管理列表查询DTO") +public class GoodsDTO extends BasePage { + @ApiModelProperty(value = "商品状态 1上架 2下架") + private Integer status; + @ApiModelProperty(value = "商品名称") + private String name; + @ApiModelProperty(value = "1现金购买 2积分兑换 ") + private Integer type; + @ApiModelProperty(value = "1全部 2已售罄 ") + private Integer otherState; +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java index f257843..551ff23 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java @@ -1,6 +1,5 @@ package com.ruoyi.other.api.factory; -import com.ruoyi.other.api.feignClient.GoodsClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java index 75aafe1..60627de 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java @@ -4,7 +4,6 @@ import com.ruoyi.account.api.dto.UnitListQueryDto; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.TCompany; -import com.ruoyi.other.api.feignClient.GoodsClient; import com.ruoyi.other.api.feignClient.OtherClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java deleted file mode 100644 index d8d8ac1..0000000 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.ruoyi.other.api.feignClient; - -import com.ruoyi.common.core.constant.ServiceNameConstants; -import com.ruoyi.other.api.factory.GoodsFallbackFactory; -import org.springframework.cloud.openfeign.FeignClient; - -/** - * 商品服务 - * @author ruoyi - */ -@FeignClient(contextId = "GoodsClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = GoodsFallbackFactory.class) -public interface GoodsClient { - - -} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java index 1057250..91ba605 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java @@ -35,4 +35,5 @@ * 车辆合同的serviceid */ public static final String CONTRACT_SERVICE = "ruoyi-contract"; + public static final String CONTRACT_ORDER = "ruoyi-order"; } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TActivityController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TActivityController.java index c3ffe4b..cd4eb1c 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TActivityController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TActivityController.java @@ -1,9 +1,16 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TActivity; +import com.ruoyi.other.api.domain.TAdvertising; +import com.ruoyi.other.api.dto.AdvertisingDTO; +import com.ruoyi.other.service.TActivityService; +import com.ruoyi.other.service.TAdvertisingService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; /** * <p> @@ -14,8 +21,38 @@ * @since 2024-08-06 */ @RestController -@RequestMapping("/t-activity") +@RequestMapping("/activity") public class TActivityController { + @Autowired + private TActivityService activityService; + @PostMapping("/saveActivity") + @ApiOperation(tags = {"管理后台-活动管理"},value = "活动添加") + public AjaxResult saveActivity(@RequestBody TActivity dto) { + activityService.save(dto); + return AjaxResult.success(); + } + @GetMapping("/delete") + @ApiOperation(tags = {"管理后台-活动管理"},value = "活动删除") + public AjaxResult delete(Integer id) { + activityService.removeById(id); + return AjaxResult.success(); + } + @PostMapping("/updateVip") + @ApiOperation(tags = {"管理后台-活动管理"},value = "活动修改") + public AjaxResult updateActivity(@RequestBody TActivity dto) { + activityService.updateById(dto); + return AjaxResult.success(); + } + @GetMapping("/getInfo") + @ApiOperation(tags = {"管理后台-活动管理"},value = "活动查看详情") + public AjaxResult<TActivity> getInfo(Integer id) { + return AjaxResult.ok(activityService.getById(id)); + } + @ApiOperation(tags = {"管理后台-活动管理"},value = "活动列表分页查询") + @PostMapping(value = "/pageList") + public AjaxResult<PageInfo<TActivity>> pageList(@RequestBody AdvertisingDTO dto) { + return AjaxResult.ok(activityService.pageList(dto)); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TAdvertisingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TAdvertisingController.java index 4e75bca..98ae556 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TAdvertisingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TAdvertisingController.java @@ -29,31 +29,31 @@ @Autowired private TAdvertisingService advertisingService; @PostMapping("/saveAdvertising") - @ApiOperation(value = "广告添加") + @ApiOperation(tags = {"管理后台-广告管理"},value = "广告添加") public AjaxResult saveAdvertising(@RequestBody TAdvertising dto) { advertisingService.save(dto); return AjaxResult.success(); } @GetMapping("/delete") - @ApiOperation(value = "广告删除") + @ApiOperation(tags = {"管理后台-广告管理"},value = "广告删除") public AjaxResult delete(Integer id) { advertisingService.removeById(id); return AjaxResult.success(); } @PostMapping("/updateVip") - @ApiOperation(value = "广告修改") + @ApiOperation(tags = {"管理后台-广告管理"},value = "广告修改") public AjaxResult updateVip(@RequestBody TAdvertising dto) { advertisingService.updateById(dto); return AjaxResult.success(); } @GetMapping("/getInfo") - @ApiOperation(value = "广告查看详情") + @ApiOperation(tags = {"管理后台-广告管理"},value = "广告查看详情") public AjaxResult<TAdvertising> getInfo(Integer id) { return AjaxResult.ok(advertisingService.getById(id)); } - @ApiOperation(value = "广告列表分页查询") + @ApiOperation(tags = {"管理后台-广告管理"},value = "广告列表分页查询") @PostMapping(value = "/pageList") - public AjaxResult<PageInfo<TAdvertising>> pageList(AdvertisingDTO dto) { + public AjaxResult<PageInfo<TAdvertising>> pageList(@RequestBody AdvertisingDTO dto) { return AjaxResult.ok(advertisingService.pageList(dto)); } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java index 839b382..f714570 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java @@ -1,9 +1,18 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TActivity; +import com.ruoyi.other.api.domain.TGoods; +import com.ruoyi.other.api.dto.AdvertisingDTO; +import com.ruoyi.other.api.dto.GoodsDTO; +import com.ruoyi.other.service.TActivityService; +import com.ruoyi.other.service.TAdvertisingService; +import com.ruoyi.other.service.TGoodsService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; /** * <p> @@ -16,6 +25,37 @@ @RestController @RequestMapping("/t-goods") public class TGoodsController { - + @Autowired + private TGoodsService goodsService; + @Autowired + private TActivityService activityService; + @PostMapping("/saveGoods") + @ApiOperation(tags = {"管理后台-商品管理"},value = "商品添加") + public AjaxResult saveActivity(@RequestBody TGoods dto) { + goodsService.save(dto); + return AjaxResult.success(); + } + @GetMapping("/delete") + @ApiOperation(tags = {"管理后台-商品管理"},value = "商品删除") + public AjaxResult delete(Integer id) { + goodsService.removeById(id); + return AjaxResult.success(); + } + @PostMapping("/updateVip") + @ApiOperation(tags = {"管理后台-商品管理"},value = "商品修改") + public AjaxResult updateActivity(@RequestBody TGoods dto) { + goodsService.updateById(dto); + return AjaxResult.success(); + } + @GetMapping("/getInfo") + @ApiOperation(tags = {"管理后台-商品管理"},value = "商品查看详情") + public AjaxResult<TGoods> getInfo(Integer id) { + return AjaxResult.ok(goodsService.getById(id)); + } + @ApiOperation(tags = {"管理后台-商品管理"},value = "商品列表分页查询") + @PostMapping(value = "/pageList") + public AjaxResult<PageInfo<TGoods>> pageList(@RequestBody GoodsDTO dto) { + return AjaxResult.ok(goodsService.pageList(dto)); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TActivityMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TActivityMapper.java index f8940d8..a79d154 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TActivityMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TActivityMapper.java @@ -1,7 +1,13 @@ package com.ruoyi.other.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TActivity; +import com.ruoyi.other.api.domain.TAdvertising; +import com.ruoyi.other.api.dto.AdvertisingDTO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -13,4 +19,5 @@ */ public interface TActivityMapper extends BaseMapper<TActivity> { + List<TActivity> pageList(@Param("pageInfo")PageInfo<TActivity> pageInfo, @Param("req") AdvertisingDTO dto); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TGoodsMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TGoodsMapper.java index 8b0b3e7..2f73928 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TGoodsMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TGoodsMapper.java @@ -1,7 +1,13 @@ package com.ruoyi.other.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TActivity; import com.ruoyi.other.api.domain.TGoods; +import com.ruoyi.other.api.dto.GoodsDTO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -13,4 +19,6 @@ */ public interface TGoodsMapper extends BaseMapper<TGoods> { + List<TGoods> pageList(@Param("pageInfo")PageInfo<TGoods> pageInfo, @Param("req") GoodsDTO dto); + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TActivityService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TActivityService.java index e3be327..20bb463 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TActivityService.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TActivityService.java @@ -1,7 +1,9 @@ package com.ruoyi.other.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TActivity; +import com.ruoyi.other.api.dto.AdvertisingDTO; /** * <p> @@ -13,4 +15,5 @@ */ public interface TActivityService extends IService<TActivity> { + PageInfo<TActivity> pageList(AdvertisingDTO dto); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TGoodsService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TGoodsService.java index 80af36e..99d40ec 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TGoodsService.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TGoodsService.java @@ -1,7 +1,9 @@ package com.ruoyi.other.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TGoods; +import com.ruoyi.other.api.dto.GoodsDTO; /** * <p> @@ -13,4 +15,6 @@ */ public interface TGoodsService extends IService<TGoods> { + PageInfo<TGoods> pageList(GoodsDTO dto); + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TActivityServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TActivityServiceImpl.java index 79fbc75..d6de6b8 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TActivityServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TActivityServiceImpl.java @@ -1,10 +1,16 @@ package com.ruoyi.other.service.impl; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TActivity; +import com.ruoyi.other.api.domain.TAdvertising; +import com.ruoyi.other.api.dto.AdvertisingDTO; import com.ruoyi.other.mapper.TActivityMapper; import com.ruoyi.other.service.TActivityService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; /** * <p> @@ -17,4 +23,22 @@ @Service public class TActivityServiceImpl extends ServiceImpl<TActivityMapper, TActivity> implements TActivityService { + @Override + public PageInfo<TActivity> pageList(AdvertisingDTO dto) { + + PageInfo<TActivity> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); + List<TActivity> list = this.baseMapper.pageList(pageInfo,dto); + for (TActivity tAdvertising : list) { + // 如果开始时间大于当前时间 那么设置状态startState为1 未开始 + if (tAdvertising.getStartTime().isAfter(LocalDateTime.now())) { + tAdvertising.setStartState(1); + } else if (tAdvertising.getEndTime().isBefore(LocalDateTime.now())) { + tAdvertising.setStartState(3); + } else { + tAdvertising.setStartState(2); + } + } + pageInfo.setRecords(list); + return pageInfo; + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TAdvertisingServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TAdvertisingServiceImpl.java index 219aaed..eb228f2 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TAdvertisingServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TAdvertisingServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.List; /** @@ -25,8 +26,18 @@ @Override public PageInfo<TAdvertising> pageList(AdvertisingDTO dto) { - PageInfo<TAdvertising> pageInfo = new PageInfo<>(dto.getStartState(),dto.getPageSize()); + PageInfo<TAdvertising> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); List<TAdvertising> list = this.baseMapper.pageList(pageInfo,dto); + for (TAdvertising tAdvertising : list) { + // 如果开始时间大于当前时间 那么设置状态startState为1 未开始 + if (tAdvertising.getStartTime().isAfter(LocalDateTime.now())) { + tAdvertising.setStartState(1); + } else if (tAdvertising.getEndTime().isBefore(LocalDateTime.now())) { + tAdvertising.setStartState(3); + } else { + tAdvertising.setStartState(2); + } + } pageInfo.setRecords(list); return pageInfo; } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java index c3e86ce..52dfdb0 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java @@ -1,10 +1,16 @@ package com.ruoyi.other.service.impl; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TGoods; +import com.ruoyi.other.api.dto.GoodsDTO; import com.ruoyi.other.mapper.TGoodsMapper; import com.ruoyi.other.service.TGoodsService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; /** * <p> @@ -17,4 +23,25 @@ @Service public class TGoodsServiceImpl extends ServiceImpl<TGoodsMapper, TGoods> implements TGoodsService { + @Autowired + private OrderClient goodsClient; + @Override + public PageInfo<TGoods> pageList(GoodsDTO dto) { + PageInfo<TGoods> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); + List<TGoods> list = this.baseMapper.pageList(pageInfo,dto); + + StringBuilder stringBuilder = new StringBuilder(); + for (TGoods temp : list) { + stringBuilder.append(temp.getId()).append(","); + } + if (StringUtils.hasLength(stringBuilder)){ + // 去除最后一个字符 + stringBuilder.deleteCharAt(stringBuilder.length()-1); + } + String string = stringBuilder.toString(); +// goodsClient + // 远程调用cha'xun + pageInfo.setRecords(list); + return pageInfo; + } } diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TActivityMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TActivityMapper.xml index 1c7f204..835fed1 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TActivityMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TActivityMapper.xml @@ -20,5 +20,24 @@ <sql id="Base_Column_List"> id, name, img, start_time, end_time, jump_type, jump_url, status, create_time, del_flag </sql> + <select id="pageList" resultType="com.ruoyi.other.api.domain.TActivity"> + select * from t_activity + <where> + <if test="req.name != null and req.name != ''"> + AND `name` LIKE concat('%',#{req.name}, '%') + </if> + <if test="req.state == 1"> + AND start_time >= NOW() + </if> + <if test="req.state == 2"> + AND start_time <= NOW() AND end_time >= NOW() + </if> + <if test="req.state == 3"> + AND end_time <= NOW() + </if> + AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} + </where> + ORDER BY create_time DESC + </select> </mapper> diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TGoodsMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TGoodsMapper.xml index 4c1ebd8..a602e33 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TGoodsMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TGoodsMapper.xml @@ -30,5 +30,24 @@ <sql id="Base_Column_List"> id, type, name, cover_picture, details_picture, dispatch_address, service_description, original_price, preferential_price, vip_price, redeem_points, limit_exchange_times, inventory, underlying_sales, describe, introduce, explain, status, create_time, del_flag </sql> + <select id="pageList" resultType="com.ruoyi.other.api.domain.TGoods"> + select * from t_goods + <where> + <if test="req.name != null and req.name != ''"> + AND `name` LIKE concat('%',#{req.name}, '%') + </if> + <if test="req.type != null"> + AND `type` = #{req.type} + </if> + <if test="req.status != null"> + AND status = #{req.status} + </if> + <if test="req.otherState != null and req.otherState = 2"> + AND inventory = 0 + </if> + AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} + </where> + ORDER BY create_time DESC + </select> </mapper> -- Gitblit v1.7.1