更新代码
This commit is contained in:
parent
7f1e499e89
commit
bc9c010094
@ -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));
|
||||
}
|
||||
}
|
@ -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<DlBaseBanner> 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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -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<DlBaseBanner> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @author 小李
|
||||
* @date 9:17 2024/9/27
|
||||
* @param bannerReqVO 查询对象
|
||||
**/
|
||||
IPage<DlBaseBanner> queryByPage(@Param("map") DlBannerReqVO bannerReqVO, Page<DlBaseBanner> page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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<DlBaseBanner> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @author 小李
|
||||
* @date 9:17 2024/9/27
|
||||
* @param bannerReqVO 查询对象
|
||||
**/
|
||||
IPage<DlBaseBanner> queryByPage(DlBannerReqVO bannerReqVO, Page<DlBaseBanner> 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<DlBaseBanner> getBannerByType(String type);
|
||||
}
|
@ -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<DlBaseBannerMapper, DlBaseBanner>
|
||||
implements DlBaseBannerService {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param bannerReqVO 查询对象
|
||||
* @author 小李
|
||||
* @date 9:17 2024/9/27
|
||||
**/
|
||||
@Override
|
||||
public IPage<DlBaseBanner> queryByPage(DlBannerReqVO bannerReqVO, Page<DlBaseBanner> 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<DlBaseBanner> getBannerByType(String type) {
|
||||
List<DlBaseBanner> dlBaseBanners = baseMapper.selectList(new LambdaQueryWrapper<DlBaseBanner>().eq(DlBaseBanner::getTypeId, type));
|
||||
return dlBaseBanners.stream().sorted(Comparator.comparing(DlBaseBanner::getSort)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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 {
|
||||
}
|
@ -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 {
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?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="cn.iocoder.yudao.module.banner.mapper.DlBaseBannerMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.banner.entity.DlBaseBanner">
|
||||
<id property="id" column="id" jdbcType="VARCHAR"/>
|
||||
<result property="title" column="title" jdbcType="VARCHAR"/>
|
||||
<result property="url" column="url" jdbcType="VARCHAR"/>
|
||||
<result property="sort" column="sort" jdbcType="VARCHAR"/>
|
||||
<result property="typeId" column="type_id" jdbcType="VARCHAR"/>
|
||||
<result property="toUrl" column="to_url" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_SQL">
|
||||
select id,
|
||||
title,
|
||||
url,
|
||||
sort,
|
||||
type_id,
|
||||
to_url
|
||||
from dl_base_banner dbb where dbb.deleted = '0'
|
||||
</sql>
|
||||
|
||||
<select id="queryByPage" resultMap="BaseResultMap">
|
||||
<include refid="Base_SQL" />
|
||||
<if test="map.typeId != null and map.typeId != ''">
|
||||
and dbb.type_id = #{map.typeId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user