From bc9c010094c750ad4f2111bb81099882fc03fffe Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Fri, 27 Sep 2024 11:13:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/banner/controller/BannerAPI.java | 38 ++++++++ .../admin/DlBaseBannerController.java | 84 +++++++++++++++++ .../module/banner/entity/DlBaseBanner.java | 48 ++++++++++ .../banner/mapper/DlBaseBannerMapper.java | 32 +++++++ .../banner/service/DlBaseBannerService.java | 63 +++++++++++++ .../service/impl/DlBaseBannerServiceImpl.java | 91 +++++++++++++++++++ .../yudao/module/banner/vo/DlBannerReqVO.java | 14 +++ .../module/banner/vo/DlBannerRespVO.java | 14 +++ .../mapper/banner/DlBaseBannerMapper.xml | 32 +++++++ 9 files changed, 416 insertions(+) create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/banner/controller/BannerAPI.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/controller/admin/DlBaseBannerController.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/entity/DlBaseBanner.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/mapper/DlBaseBannerMapper.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/DlBaseBannerService.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/impl/DlBaseBannerServiceImpl.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerReqVO.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerRespVO.java create mode 100644 dl-module-base/src/main/resources/mapper/banner/DlBaseBannerMapper.xml diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/banner/controller/BannerAPI.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/banner/controller/BannerAPI.java new file mode 100644 index 00000000..fe42e48a --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/banner/controller/BannerAPI.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.app.banner.controller; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.banner.service.DlBaseBannerService; +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 javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 取banner + * + * @author 小李 + * @date 11:05 2024/9/27 +**/ +@RestController +@RequestMapping("/userClient/banner") +public class BannerAPI { + + @Resource + private DlBaseBannerService baseBannerService; + + /** + * 不同小程序用不同的banner,用type分 + * + * @author 小李 + * @date 11:07 2024/9/27 + * @param type type + **/ + @GetMapping("/get") + public CommonResult getBannerByType(@RequestParam("type") String type) { + return success(baseBannerService.getBannerByType(type)); + } +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/controller/admin/DlBaseBannerController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/controller/admin/DlBaseBannerController.java new file mode 100644 index 00000000..2e5efe65 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/controller/admin/DlBaseBannerController.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.banner.controller.admin; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.banner.entity.DlBaseBanner; +import cn.iocoder.yudao.module.banner.service.DlBaseBannerService; +import cn.iocoder.yudao.module.banner.vo.DlBannerReqVO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * banner图基础库(DlBaseBanner)表控制层 + * + * @author makejava + * @since 2024-09-27 09:09:08 + */ +@RestController +@RequestMapping("/base/banner") +public class DlBaseBannerController { + /** + * 服务对象 + */ + @Resource + private DlBaseBannerService dlBaseBannerService; + + /** + * 分页查询 + * + * @author 小李 + * @date 9:17 2024/9/27 + * @param bannerReqVO 查询对象 + * @param pageNo 页码 + * @param pageSize 条数 + **/ + @GetMapping("/page") + public CommonResult queryByPage(DlBannerReqVO bannerReqVO, + @RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize) { + Page page = new Page<>(pageNo, pageSize); + return success(dlBaseBannerService.queryByPage(bannerReqVO, page)); + } + + /** + * 新增、修改 + * + * @author 小李 + * @date 9:23 2024/9/27 + * @param bannerReqVO 请求对象 + **/ + @PostMapping("/update") + public CommonResult updateBanner(@RequestBody DlBannerReqVO bannerReqVO) { + dlBaseBannerService.updateBanner(bannerReqVO); + return CommonResult.ok(); + } + + /** + * 通过主键查询单条数据 + * + * @author 小李 + * @date 9:25 2024/9/27 + * @param id 记录ID + **/ + @GetMapping("/get") + public CommonResult getBannerById(@RequestParam("id") String id) { + return success(dlBaseBannerService.getBannerById(id)); + } + + /** + * 删除数据 + * + * @author 小李 + * @date 9:28 2024/9/27 + * @param id 记录ID + **/ + @DeleteMapping("/remove") + public CommonResult deleteBannerById(@RequestParam("id") String id) { + dlBaseBannerService.deleteBannerById(id); + return CommonResult.ok(); + } +} + diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/entity/DlBaseBanner.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/entity/DlBaseBanner.java new file mode 100644 index 00000000..10257122 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/entity/DlBaseBanner.java @@ -0,0 +1,48 @@ +package cn.iocoder.yudao.module.banner.entity; + +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * banner图基础库 + * + * @author 小李 + * @date 9:09 2024/9/27 +**/ +@TableName(value ="dl_base_banner") +@Data +@EqualsAndHashCode(callSuper = true) +public class DlBaseBanner extends TenantBaseDO { + /** + * 主键标识 + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + + /** + * 图片名称 + */ + private String title; + + /** + * 图片地址 + */ + private String url; + + /** + * 图片顺序 + */ + private String sort; + + /** + * 图片类别(属于什么服务的,表system_service_package表的id) + */ + private String typeId; + + /** 跳转链接 */ + private String toUrl; +} \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/mapper/DlBaseBannerMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/mapper/DlBaseBannerMapper.java new file mode 100644 index 00000000..b7871e01 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/mapper/DlBaseBannerMapper.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.banner.mapper; + +import cn.iocoder.yudao.module.banner.entity.DlBaseBanner; +import cn.iocoder.yudao.module.banner.vo.DlBannerReqVO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 针对表【dl_base_banner(banner图基础库)】的数据库操作Mapper + * + * @author 小李 + * @date 9:11 2024/9/27 +**/ +@Mapper +public interface DlBaseBannerMapper extends BaseMapper { + + /** + * 分页查询 + * + * @author 小李 + * @date 9:17 2024/9/27 + * @param bannerReqVO 查询对象 + **/ + IPage queryByPage(@Param("map") DlBannerReqVO bannerReqVO, Page page); +} + + + + diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/DlBaseBannerService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/DlBaseBannerService.java new file mode 100644 index 00000000..9b0ad4ae --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/DlBaseBannerService.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.banner.service; + +import cn.iocoder.yudao.module.banner.entity.DlBaseBanner; +import cn.iocoder.yudao.module.banner.vo.DlBannerReqVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * 针对表【dl_base_banner(banner图基础库)】的数据库操作Service + * + * @author 小李 + * @date 9:12 2024/9/27 +**/ +public interface DlBaseBannerService extends IService { + + /** + * 分页查询 + * + * @author 小李 + * @date 9:17 2024/9/27 + * @param bannerReqVO 查询对象 + **/ + IPage queryByPage(DlBannerReqVO bannerReqVO, Page page); + + /** + * 新增、修改 + * + * @author 小李 + * @date 9:23 2024/9/27 + * @param bannerReqVO 请求对象 + **/ + void updateBanner(DlBannerReqVO bannerReqVO); + + /** + * 通过主键查询单条数据 + * + * @author 小李 + * @date 9:25 2024/9/27 + * @param id 记录ID + **/ + DlBaseBanner getBannerById(String id); + + /** + * 删除数据 + * + * @author 小李 + * @date 9:28 2024/9/27 + * @param id 记录ID + **/ + void deleteBannerById(String id); + + /** + * 不同小程序用不同的banner,用type分 + * + * @author 小李 + * @date 11:07 2024/9/27 + * @param type type + **/ + List getBannerByType(String type); +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/impl/DlBaseBannerServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/impl/DlBaseBannerServiceImpl.java new file mode 100644 index 00000000..ae029a72 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/service/impl/DlBaseBannerServiceImpl.java @@ -0,0 +1,91 @@ +package cn.iocoder.yudao.module.banner.service.impl; + +import cn.iocoder.yudao.module.banner.entity.DlBaseBanner; +import cn.iocoder.yudao.module.banner.mapper.DlBaseBannerMapper; +import cn.iocoder.yudao.module.banner.service.DlBaseBannerService; +import cn.iocoder.yudao.module.banner.vo.DlBannerReqVO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 针对表【dl_base_banner(banner图基础库)】的数据库操作Service实现 + * + * @author 小李 + * @date 9:21 2024/9/27 + **/ +@Service +public class DlBaseBannerServiceImpl extends ServiceImpl + implements DlBaseBannerService { + + /** + * 分页查询 + * + * @param bannerReqVO 查询对象 + * @author 小李 + * @date 9:17 2024/9/27 + **/ + @Override + public IPage queryByPage(DlBannerReqVO bannerReqVO, Page page) { + return baseMapper.queryByPage(bannerReqVO, page); + } + + /** + * 新增、修改 + * + * @param bannerReqVO 请求对象 + * @author 小李 + * @date 9:23 2024/9/27 + **/ + @Override + public void updateBanner(DlBannerReqVO bannerReqVO) { + baseMapper.insertOrUpdate(bannerReqVO); + } + + /** + * 通过主键查询单条数据 + * + * @param id 记录ID + * @author 小李 + * @date 9:25 2024/9/27 + **/ + @Override + public DlBaseBanner getBannerById(String id) { + return baseMapper.selectById(id); + } + + /** + * 删除数据 + * + * @param id 记录ID + * @author 小李 + * @date 9:28 2024/9/27 + **/ + @Override + public void deleteBannerById(String id) { + baseMapper.deleteById(id); + } + + /** + * 不同小程序用不同的banner,用type分 + * + * @param type type + * @author 小李 + * @date 11:07 2024/9/27 + **/ + @Override + public List getBannerByType(String type) { + List dlBaseBanners = baseMapper.selectList(new LambdaQueryWrapper().eq(DlBaseBanner::getTypeId, type)); + return dlBaseBanners.stream().sorted(Comparator.comparing(DlBaseBanner::getSort)).collect(Collectors.toList()); + } +} + + + + diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerReqVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerReqVO.java new file mode 100644 index 00000000..3aba9a5a --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.banner.vo; + +import cn.iocoder.yudao.module.banner.entity.DlBaseBanner; +import lombok.Data; + +/** + * banner图基础库 请求VO + * + * @author 小李 + * @date 9:11 2024/9/27 +**/ +@Data +public class DlBannerReqVO extends DlBaseBanner { +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerRespVO.java new file mode 100644 index 00000000..2a94644f --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/banner/vo/DlBannerRespVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.banner.vo; + +import cn.iocoder.yudao.module.banner.entity.DlBaseBanner; +import lombok.Data; + +/** + * banner图基础库 响应VO + * + * @author 小李 + * @date 9:11 2024/9/27 +**/ +@Data +public class DlBannerRespVO extends DlBaseBanner { +} diff --git a/dl-module-base/src/main/resources/mapper/banner/DlBaseBannerMapper.xml b/dl-module-base/src/main/resources/mapper/banner/DlBaseBannerMapper.xml new file mode 100644 index 00000000..37326392 --- /dev/null +++ b/dl-module-base/src/main/resources/mapper/banner/DlBaseBannerMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + select id, + title, + url, + sort, + type_id, + to_url + from dl_base_banner dbb where dbb.deleted = '0' + + + +