From 22c04c61f5b928e80f527fcbcaa8c69b211e9ebb Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Mon, 19 Aug 2024 15:30:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopAdController.java | 40 ++++++++++++ .../cashierservice/dao/TbShopAdDao.java | 23 +++++++ .../cashierservice/entity/TbShopAd.java | 63 +++++++++++++++++++ .../entity/dto/TbShopAdDto.java | 61 ++++++++++++++++++ .../service/TbShopAdService.java | 20 ++++++ .../service/impl/TbShopAdServiceImpl.java | 27 ++++++++ src/main/resources/mapper/TbShopAdDao.xml | 22 +++++++ 7 files changed, 256 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java create mode 100644 src/main/resources/mapper/TbShopAdDao.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java new file mode 100644 index 0000000..faabacf --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java @@ -0,0 +1,40 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import com.chaozhanggui.system.cashierservice.entity.dto.TbShopAdDto; +import com.chaozhanggui.system.cashierservice.service.TbShopAdService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * (TbShopAd)表控制层 + * + * @author GYJ + * @since 2024-08-19 14:25:09 + */ +@RestController +@RequestMapping("tbShopAd") +public class TbShopAdController { + + private final TbShopAdService tbShopAdService; + + public TbShopAdController(@Qualifier("tbShopAdServiceImpl") TbShopAdService tbShopAdService) { + this.tbShopAdService = tbShopAdService; + } + + + @GetMapping("/list") + public Result list(@RequestParam(value = "shopId") Integer shopId) { + List tbShopAds = tbShopAdService.shopAdList(shopId); + return Result.success(CodeEnum.ENCRYPT, TbShopAdDto.convertShopAdDoToDtoList(tbShopAds)); + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java new file mode 100644 index 0000000..3030d0f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java @@ -0,0 +1,23 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * (TbShopAd)表数据库访问层 + * + * @author GYJ + * @since 2024-08-19 14:25:09 + */ +public interface TbShopAdDao { + /** + * 查询指定行数据 + * + * @return 对象列表 + */ + @Select("select * from fycashier.tb_shop_ad where (shop_id = #{songId} or shop_id = 1) and status=1") + List shopAdList(Integer shopId); +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java new file mode 100644 index 0000000..ffb7e8d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java @@ -0,0 +1,63 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * (TbShopAd)实体类 + * + * @author GYJ + * @since 2024-08-19 14:25:09 + */ +@Data +public class TbShopAd implements Serializable { + private static final long serialVersionUID = -34028307481923067L; +/** + * 自增id + */ + private Integer id; +/** + * 店铺id,如果是通用广告则为0 + */ + private Integer shopId; +/** + * 广告图片地址 + */ + private String imgUrl; +/** + * 跳转页面路径 + */ + private String linkPath; +/** + * 广告展示圆角 + */ + private Integer borderRadius; +/** + * 弹窗展示位置:home首页,make_order点餐页 + */ + private String showPosition; +/** + * 显示频率:only_one 仅首次展示, every_show 每次打开都展示,every_day 每天展示一次,three_day 每三天展示一次, seven_day 每七天展示一次, thirty_day 没30天展示一次 + */ + private String frequency; +/** + * 广告状态:0未启用,1已启用 + */ + private Integer status; +/** + * 排序 + */ + private Integer sort; +/** + * 创建时间 + */ + private Date createTime; +/** + * 更新时间 + */ + private Date updateTime; + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java new file mode 100644 index 0000000..006ce6f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java @@ -0,0 +1,61 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import lombok.Data; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author GYJ + */ +@Data +public class TbShopAdDto { + private Integer id; + /** + * 店铺id,如果是通用广告则为0 + */ + private Integer shopId; + /** + * 广告图片地址 + */ + private String imgUrl; + /** + * 跳转页面路径 + */ + private String linkPath; + /** + * 广告展示圆角 + */ + private Integer borderRadius; + /** + * 弹窗展示位置:home首页,make_order点餐页 + */ + private String showPosition; + /** + * 显示频率:only_one 仅首次展示, every_show 每次打开都展示,every_day 每天展示一次,three_day 每三天展示一次, seven_day 每七天展示一次, thirty_day 没30天展示一次 + */ + private String frequency; + + /** + * 更新时间 + */ + private Long updateTime; + + public static List convertShopAdDoToDtoList(List adList) { + return adList.stream().map(TbShopAdDto::convertShopAdDoToDto).collect(Collectors.toList()); + } + + public static TbShopAdDto convertShopAdDoToDto(TbShopAd ad) { + TbShopAdDto dto = new TbShopAdDto(); + dto.setId(ad.getId()); + dto.setShopId(ad.getShopId()); + dto.setImgUrl(ad.getImgUrl()); + dto.setLinkPath(ad.getLinkPath()); + dto.setBorderRadius(ad.getBorderRadius()); + dto.setShowPosition(ad.getShowPosition()); + dto.setFrequency(ad.getFrequency()); + dto.setUpdateTime(ad.getUpdateTime().getTime()); + return dto; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java new file mode 100644 index 0000000..9cad181 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java @@ -0,0 +1,20 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; + +import java.util.List; + +/** + * (TbShopAd)表服务接口 + * + * @author GYJ + * @since 2024-08-19 14:25:17 + */ +public interface TbShopAdService { + /** + * 分页查询 + * + * @return 查询结果 + */ + List shopAdList(Integer shopId); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java new file mode 100644 index 0000000..ad9ebb7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java @@ -0,0 +1,27 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.chaozhanggui.system.cashierservice.dao.TbShopAdDao; +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import com.chaozhanggui.system.cashierservice.service.TbShopAdService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * (TbShopAd)表服务实现类 + * + * @author GYJ + * @since 2024-08-19 14:25:17 + */ +@Service +public class TbShopAdServiceImpl implements TbShopAdService { + @Autowired + private TbShopAdDao tbShopAdDao; + + @Override + public List shopAdList(Integer shopId) { + System.out.println("shopId = " + shopId); + return tbShopAdDao.shopAdList(shopId); + } +} diff --git a/src/main/resources/mapper/TbShopAdDao.xml b/src/main/resources/mapper/TbShopAdDao.xml new file mode 100644 index 0000000..799d46a --- /dev/null +++ b/src/main/resources/mapper/TbShopAdDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + +