小程序获取弹窗接口

This commit is contained in:
GYJ
2024-08-19 15:30:14 +08:00
parent 538fc8f91b
commit 22c04c61f5
7 changed files with 256 additions and 0 deletions

View File

@@ -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<TbShopAd> tbShopAds = tbShopAdService.shopAdList(shopId);
return Result.success(CodeEnum.ENCRYPT, TbShopAdDto.convertShopAdDoToDtoList(tbShopAds));
}
}

View File

@@ -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<TbShopAd> shopAdList(Integer shopId);
}

View File

@@ -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;
}

View File

@@ -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<TbShopAdDto> convertShopAdDoToDtoList(List<TbShopAd> 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;
}
}

View File

@@ -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<TbShopAd> shopAdList(Integer shopId);
}

View File

@@ -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<TbShopAd> shopAdList(Integer shopId) {
System.out.println("shopId = " + shopId);
return tbShopAdDao.shopAdList(shopId);
}
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopAdDao">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbShopAd" id="TbShopAdMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="imgUrl" column="img_url" jdbcType="VARCHAR"/>
<result property="linkPath" column="link_path" jdbcType="VARCHAR"/>
<result property="borderRadius" column="border_radius" jdbcType="INTEGER"/>
<result property="showPosition" column="show_position" jdbcType="VARCHAR"/>
<result property="frequency" column="frequency" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
</mapper>