Administrator 1 жил өмнө
parent
commit
26b9688375

+ 114 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/banner/BannerController.java

@@ -0,0 +1,114 @@
+package com.ruoyi.web.controller.banner;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.banner.domain.Banner;
+import com.ruoyi.banner.service.IBannerService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 轮播图Controller
+ * 
+ * @author boman
+ * @date 2024-01-22
+ */
+@RestController
+@RequestMapping("/banner/banner")
+public class BannerController extends BaseController
+{
+    @Autowired
+    private IBannerService bannerService;
+
+    /**
+     * 查询轮播图列表
+     */
+    @PreAuthorize("@ss.hasPermi('banner:banner:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Banner banner)
+    {
+        startPage();
+        List<Banner> list = bannerService.selectBannerList(banner);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询轮播图列表不分页
+     */
+    @GetMapping("/listNoPage")
+    public TableDataInfo listNoPage(Banner banner)
+    {
+        List<Banner> list = bannerService.selectBannerList(banner);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出轮播图列表
+     */
+    @PreAuthorize("@ss.hasPermi('banner:banner:export')")
+    @Log(title = "轮播图", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Banner banner)
+    {
+        List<Banner> list = bannerService.selectBannerList(banner);
+        ExcelUtil<Banner> util = new ExcelUtil<Banner>(Banner.class);
+        util.exportExcel(response, list, "轮播图数据");
+    }
+
+    /**
+     * 获取轮播图详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('banner:banner:query')")
+    @GetMapping(value = "/{bannerId}")
+    public AjaxResult getInfo(@PathVariable("bannerId") Long bannerId)
+    {
+        return success(bannerService.selectBannerByBannerId(bannerId));
+    }
+
+    /**
+     * 新增轮播图
+     */
+    @PreAuthorize("@ss.hasPermi('banner:banner:add')")
+    @Log(title = "轮播图", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Banner banner)
+    {
+        return toAjax(bannerService.insertBanner(banner));
+    }
+
+    /**
+     * 修改轮播图
+     */
+    @PreAuthorize("@ss.hasPermi('banner:banner:edit')")
+    @Log(title = "轮播图", businessType = BusinessType.UPDATE)
+    @PostMapping("/put")
+    public AjaxResult edit(@RequestBody Banner banner)
+    {
+        return toAjax(bannerService.updateBanner(banner));
+    }
+
+    /**
+     * 删除轮播图
+     */
+    @PreAuthorize("@ss.hasPermi('banner:banner:remove')")
+    @Log(title = "轮播图", businessType = BusinessType.DELETE)
+	@GetMapping("/delete/{bannerIds}")
+    public AjaxResult remove(@PathVariable Long[] bannerIds)
+    {
+        return toAjax(bannerService.deleteBannerByBannerIds(bannerIds));
+    }
+}

+ 154 - 0
ruoyi-system/src/main/java/com/ruoyi/banner/domain/Banner.java

@@ -0,0 +1,154 @@
+package com.ruoyi.banner.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 轮播图对象 banner
+ * 
+ * @author boman
+ * @date 2024-01-22
+ */
+public class Banner extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long bannerId;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String title;
+
+    /** 排序 */
+    @Excel(name = "排序")
+    private Integer sort;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private String isDel;
+
+    /** 图片地址 */
+    @Excel(name = "图片地址")
+    private String imgUrl;
+
+    /** 三方链接 */
+    @Excel(name = "三方链接")
+    private String linkUrl;
+
+    /** 内容 */
+    @Excel(name = "内容")
+    private String content;
+
+    /** 类型  */
+    @Excel(name = "类型 ")
+    private Integer type;
+
+    /** 状态 1:启用 2:不启用 */
+    @Excel(name = "状态 1:启用 2:不启用")
+    private String status;
+
+    public void setBannerId(Long bannerId) 
+    {
+        this.bannerId = bannerId;
+    }
+
+    public Long getBannerId() 
+    {
+        return bannerId;
+    }
+    public void setTitle(String title) 
+    {
+        this.title = title;
+    }
+
+    public String getTitle() 
+    {
+        return title;
+    }
+    public void setSort(Integer sort) 
+    {
+        this.sort = sort;
+    }
+
+    public Integer getSort() 
+    {
+        return sort;
+    }
+    public void setIsDel(String isDel) 
+    {
+        this.isDel = isDel;
+    }
+
+    public String getIsDel() 
+    {
+        return isDel;
+    }
+    public void setImgUrl(String imgUrl) 
+    {
+        this.imgUrl = imgUrl;
+    }
+
+    public String getImgUrl() 
+    {
+        return imgUrl;
+    }
+    public void setLinkUrl(String linkUrl) 
+    {
+        this.linkUrl = linkUrl;
+    }
+
+    public String getLinkUrl() 
+    {
+        return linkUrl;
+    }
+    public void setContent(String content) 
+    {
+        this.content = content;
+    }
+
+    public String getContent() 
+    {
+        return content;
+    }
+    public void setType(Integer type) 
+    {
+        this.type = type;
+    }
+
+    public Integer getType() 
+    {
+        return type;
+    }
+    public void setStatus(String status) 
+    {
+        this.status = status;
+    }
+
+    public String getStatus() 
+    {
+        return status;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("bannerId", getBannerId())
+            .append("title", getTitle())
+            .append("sort", getSort())
+            .append("isDel", getIsDel())
+            .append("imgUrl", getImgUrl())
+            .append("linkUrl", getLinkUrl())
+            .append("content", getContent())
+            .append("type", getType())
+            .append("status", getStatus())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/banner/mapper/BannerMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.banner.mapper;
+
+import java.util.List;
+import com.ruoyi.banner.domain.Banner;
+
+/**
+ * 轮播图Mapper接口
+ * 
+ * @author boman
+ * @date 2024-01-22
+ */
+public interface BannerMapper 
+{
+    /**
+     * 查询轮播图
+     * 
+     * @param bannerId 轮播图主键
+     * @return 轮播图
+     */
+    public Banner selectBannerByBannerId(Long bannerId);
+
+    /**
+     * 查询轮播图列表
+     * 
+     * @param banner 轮播图
+     * @return 轮播图集合
+     */
+    public List<Banner> selectBannerList(Banner banner);
+
+    /**
+     * 新增轮播图
+     * 
+     * @param banner 轮播图
+     * @return 结果
+     */
+    public int insertBanner(Banner banner);
+
+    /**
+     * 修改轮播图
+     * 
+     * @param banner 轮播图
+     * @return 结果
+     */
+    public int updateBanner(Banner banner);
+
+    /**
+     * 删除轮播图
+     * 
+     * @param bannerId 轮播图主键
+     * @return 结果
+     */
+    public int deleteBannerByBannerId(Long bannerId);
+
+    /**
+     * 批量删除轮播图
+     * 
+     * @param bannerIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteBannerByBannerIds(Long[] bannerIds);
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/banner/service/IBannerService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.banner.service;
+
+import java.util.List;
+import com.ruoyi.banner.domain.Banner;
+
+/**
+ * 轮播图Service接口
+ * 
+ * @author boman
+ * @date 2024-01-22
+ */
+public interface IBannerService 
+{
+    /**
+     * 查询轮播图
+     * 
+     * @param bannerId 轮播图主键
+     * @return 轮播图
+     */
+    public Banner selectBannerByBannerId(Long bannerId);
+
+    /**
+     * 查询轮播图列表
+     * 
+     * @param banner 轮播图
+     * @return 轮播图集合
+     */
+    public List<Banner> selectBannerList(Banner banner);
+
+    /**
+     * 新增轮播图
+     * 
+     * @param banner 轮播图
+     * @return 结果
+     */
+    public int insertBanner(Banner banner);
+
+    /**
+     * 修改轮播图
+     * 
+     * @param banner 轮播图
+     * @return 结果
+     */
+    public int updateBanner(Banner banner);
+
+    /**
+     * 批量删除轮播图
+     * 
+     * @param bannerIds 需要删除的轮播图主键集合
+     * @return 结果
+     */
+    public int deleteBannerByBannerIds(Long[] bannerIds);
+
+    /**
+     * 删除轮播图信息
+     * 
+     * @param bannerId 轮播图主键
+     * @return 结果
+     */
+    public int deleteBannerByBannerId(Long bannerId);
+}

+ 96 - 0
ruoyi-system/src/main/java/com/ruoyi/banner/service/impl/BannerServiceImpl.java

@@ -0,0 +1,96 @@
+package com.ruoyi.banner.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.banner.mapper.BannerMapper;
+import com.ruoyi.banner.domain.Banner;
+import com.ruoyi.banner.service.IBannerService;
+
+/**
+ * 轮播图Service业务层处理
+ * 
+ * @author boman
+ * @date 2024-01-22
+ */
+@Service
+public class BannerServiceImpl implements IBannerService 
+{
+    @Autowired
+    private BannerMapper bannerMapper;
+
+    /**
+     * 查询轮播图
+     * 
+     * @param bannerId 轮播图主键
+     * @return 轮播图
+     */
+    @Override
+    public Banner selectBannerByBannerId(Long bannerId)
+    {
+        return bannerMapper.selectBannerByBannerId(bannerId);
+    }
+
+    /**
+     * 查询轮播图列表
+     * 
+     * @param banner 轮播图
+     * @return 轮播图
+     */
+    @Override
+    public List<Banner> selectBannerList(Banner banner)
+    {
+        return bannerMapper.selectBannerList(banner);
+    }
+
+    /**
+     * 新增轮播图
+     * 
+     * @param banner 轮播图
+     * @return 结果
+     */
+    @Override
+    public int insertBanner(Banner banner)
+    {
+        banner.setCreateTime(DateUtils.getNowDate());
+        return bannerMapper.insertBanner(banner);
+    }
+
+    /**
+     * 修改轮播图
+     * 
+     * @param banner 轮播图
+     * @return 结果
+     */
+    @Override
+    public int updateBanner(Banner banner)
+    {
+        banner.setUpdateTime(DateUtils.getNowDate());
+        return bannerMapper.updateBanner(banner);
+    }
+
+    /**
+     * 批量删除轮播图
+     * 
+     * @param bannerIds 需要删除的轮播图主键
+     * @return 结果
+     */
+    @Override
+    public int deleteBannerByBannerIds(Long[] bannerIds)
+    {
+        return bannerMapper.deleteBannerByBannerIds(bannerIds);
+    }
+
+    /**
+     * 删除轮播图信息
+     * 
+     * @param bannerId 轮播图主键
+     * @return 结果
+     */
+    @Override
+    public int deleteBannerByBannerId(Long bannerId)
+    {
+        return bannerMapper.deleteBannerByBannerId(bannerId);
+    }
+}

+ 111 - 0
ruoyi-system/src/main/resources/mapper.banner/BannerMapper.xml

@@ -0,0 +1,111 @@
+<?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.ruoyi.banner.mapper.BannerMapper">
+    
+    <resultMap type="Banner" id="BannerResult">
+        <result property="bannerId"    column="banner_id"    />
+        <result property="title"    column="title"    />
+        <result property="sort"    column="sort"    />
+        <result property="isDel"    column="is_del"    />
+        <result property="imgUrl"    column="img_url"    />
+        <result property="linkUrl"    column="link_url"    />
+        <result property="content"    column="content"    />
+        <result property="type"    column="type"    />
+        <result property="status"    column="status"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectBannerVo">
+        select banner_id, title, sort, is_del, img_url, link_url, content, type, status, create_by, create_time, update_by, update_time, remark from banner
+    </sql>
+
+    <select id="selectBannerList" parameterType="Banner" resultMap="BannerResult">
+        <include refid="selectBannerVo"/>
+        <where>  
+            <if test="title != null  and title != ''"> and title = #{title}</if>
+            <if test="sort != null "> and sort = #{sort}</if>
+            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
+            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
+            <if test="linkUrl != null  and linkUrl != ''"> and link_url = #{linkUrl}</if>
+            <if test="content != null  and content != ''"> and content = #{content}</if>
+            <if test="type != null "> and type = #{type}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+        </where>
+    </select>
+    
+    <select id="selectBannerByBannerId" parameterType="Long" resultMap="BannerResult">
+        <include refid="selectBannerVo"/>
+        where banner_id = #{bannerId}
+    </select>
+        
+    <insert id="insertBanner" parameterType="Banner" useGeneratedKeys="true" keyProperty="bannerId">
+        insert into banner
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="title != null">title,</if>
+            <if test="sort != null">sort,</if>
+            <if test="isDel != null and isDel != ''">is_del,</if>
+            <if test="imgUrl != null">img_url,</if>
+            <if test="linkUrl != null">link_url,</if>
+            <if test="content != null">content,</if>
+            <if test="type != null">type,</if>
+            <if test="status != null">status,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="title != null">#{title},</if>
+            <if test="sort != null">#{sort},</if>
+            <if test="isDel != null and isDel != ''">#{isDel},</if>
+            <if test="imgUrl != null">#{imgUrl},</if>
+            <if test="linkUrl != null">#{linkUrl},</if>
+            <if test="content != null">#{content},</if>
+            <if test="type != null">#{type},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateBanner" parameterType="Banner">
+        update banner
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">title = #{title},</if>
+            <if test="sort != null">sort = #{sort},</if>
+            <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
+            <if test="imgUrl != null">img_url = #{imgUrl},</if>
+            <if test="linkUrl != null">link_url = #{linkUrl},</if>
+            <if test="content != null">content = #{content},</if>
+            <if test="type != null">type = #{type},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where banner_id = #{bannerId}
+    </update>
+
+    <delete id="deleteBannerByBannerId" parameterType="Long">
+        delete from banner where banner_id = #{bannerId}
+    </delete>
+
+    <delete id="deleteBannerByBannerIds" parameterType="String">
+        delete from banner where banner_id in 
+        <foreach item="bannerId" collection="array" open="(" separator="," close=")">
+            #{bannerId}
+        </foreach>
+    </delete>
+</mapper>