Commit be5c1e0d authored by lixinglin's avatar lixinglin

轮播添加视频类型

parent 69fd50ba
package com.ruoyi.system.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;
import lombok.Data;
/**
* 轮播图信息对象 sys_carousel_info
*
* 【请填写功能名称】对象 sys_carousel_info
*
* @author ruoyi
* @date 2023-10-19
* @date 2023-11-28
*/
@Data
public class SysCarouselInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -23,15 +23,15 @@ public class SysCarouselInfo extends BaseEntity
private String imgUrl;
/** 图片描述 */
@Excel(name = "图片描述")
@Excel(name = "描述")
private String description;
/** 图片状态(0-禁用;1-可用) */
@Excel(name = "图片状态", readConverterExp = "0=-禁用;1-可用")
@Excel(name = "状态", readConverterExp = "0=-禁用;1-可用")
private Integer status;
/** 类型(0 -都市圈、1-开发区、2-园区、3-首页) */
@Excel(name = "类型", readConverterExp = "0=,-=都市圈、1-开发区、2-园区、3-首页")
@Excel(name = "资源所属类型", readConverterExp = "0=,-=都市圈、1-开发区、2-园区、3-首页")
private Integer type;
/** 排序 */
......@@ -50,102 +50,8 @@ public class SysCarouselInfo extends BaseEntity
@Excel(name = "转跳链接")
private String linkUrl;
public void setId(Long id)
{
this.id = id;
}
/** 类型 1-图片 2-视频 3-其他 */
@Excel(name = "类型 1-图片 2-视频 3-其他")
private Integer urlType;
public Long getId()
{
return id;
}
public void setImgUrl(String imgUrl)
{
this.imgUrl = imgUrl;
}
public String getImgUrl()
{
return imgUrl;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDescription()
{
return description;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
public void setType(Integer type)
{
this.type = type;
}
public Integer getType()
{
return type;
}
public void setOrderNumber(Integer orderNumber)
{
this.orderNumber = orderNumber;
}
public Integer getOrderNumber()
{
return orderNumber;
}
public void setAssociationId(Long associationId)
{
this.associationId = associationId;
}
public Long getAssociationId()
{
return associationId;
}
public void setAssociationName(String associationName)
{
this.associationName = associationName;
}
public String getAssociationName()
{
return associationName;
}
public void setLinkUrl(String linkUrl)
{
this.linkUrl = linkUrl;
}
public String getLinkUrl()
{
return linkUrl;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("imgUrl", getImgUrl())
.append("description", getDescription())
.append("status", getStatus())
.append("type", getType())
.append("orderNumber", getOrderNumber())
.append("associationId", getAssociationId())
.append("associationName", getAssociationName())
.append("linkUrl", getLinkUrl())
.toString();
}
}
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysCarouselInfoMapper;
import com.ruoyi.system.domain.SysCarouselInfo;
import com.ruoyi.system.mapper.SysCarouselInfoMapper;
import com.ruoyi.system.service.ISysCarouselInfoService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 轮播图信息Service业务层处理
*
*
* @author ruoyi
* @date 2023-10-19
*/
@Service
public class SysCarouselInfoServiceImpl implements ISysCarouselInfoService
{
public class SysCarouselInfoServiceImpl implements ISysCarouselInfoService {
@Autowired
private SysCarouselInfoMapper sysCarouselInfoMapper;
/**
* 查询轮播图信息
*
*
* @param id 轮播图信息主键
* @return 轮播图信息
*/
@Override
public SysCarouselInfo selectSysCarouselInfoById(Long id)
{
public SysCarouselInfo selectSysCarouselInfoById(Long id) {
return sysCarouselInfoMapper.selectSysCarouselInfoById(id);
}
/**
* 查询轮播图信息列表
*
*
* @param sysCarouselInfo 轮播图信息
* @return 轮播图信息
*/
@Override
public List<SysCarouselInfo> selectSysCarouselInfoList(SysCarouselInfo sysCarouselInfo)
{
public List<SysCarouselInfo> selectSysCarouselInfoList(SysCarouselInfo sysCarouselInfo) {
return sysCarouselInfoMapper.selectSysCarouselInfoList(sysCarouselInfo);
}
/**
* 新增轮播图信息
*
*
* @param sysCarouselInfo 轮播图信息
* @return 结果
*/
@Override
public int insertSysCarouselInfo(SysCarouselInfo sysCarouselInfo)
{
public int insertSysCarouselInfo(SysCarouselInfo sysCarouselInfo) {
sysCarouselInfo.setCreateTime(DateUtils.getNowDate());
setLinkType(sysCarouselInfo);
return sysCarouselInfoMapper.insertSysCarouselInfo(sysCarouselInfo);
}
private static void setLinkType(SysCarouselInfo sysCarouselInfo) {
String imgUrl = sysCarouselInfo.getImgUrl();
boolean imageFile = isImageFile(imgUrl);
boolean videoFile = isVideoFile(imgUrl);
if (imageFile) {
sysCarouselInfo.setUrlType(1);
} else if (videoFile) {
sysCarouselInfo.setUrlType(2);
} else {
sysCarouselInfo.setUrlType(3);
}
}
public static boolean isImageFile(String fileName) {
String fileExtension = getFileExtension(fileName);
return fileExtension.equalsIgnoreCase("jpg") || fileExtension.equalsIgnoreCase("jpeg") ||
fileExtension.equalsIgnoreCase("png") || fileExtension.equalsIgnoreCase("gif");
}
public static boolean isVideoFile(String fileName) {
String fileExtension = getFileExtension(fileName);
return fileExtension.equalsIgnoreCase("mp4") || fileExtension.equalsIgnoreCase("avi") ||
fileExtension.equalsIgnoreCase("mov");
}
public static String getFileExtension(String fileName) {
int dotIndex = fileName.lastIndexOf(".");
if (dotIndex == -1) {
return "";
}
return fileName.substring(dotIndex + 1);
}
/**
* 修改轮播图信息
*
*
* @param sysCarouselInfo 轮播图信息
* @return 结果
*/
@Override
public int updateSysCarouselInfo(SysCarouselInfo sysCarouselInfo)
{
public int updateSysCarouselInfo(SysCarouselInfo sysCarouselInfo) {
sysCarouselInfo.setUpdateTime(DateUtils.getNowDate());
setLinkType(sysCarouselInfo);
return sysCarouselInfoMapper.updateSysCarouselInfo(sysCarouselInfo);
}
/**
* 批量删除轮播图信息
*
*
* @param ids 需要删除的轮播图信息主键
* @return 结果
*/
@Override
public int deleteSysCarouselInfoByIds(String ids)
{
public int deleteSysCarouselInfoByIds(String ids) {
return sysCarouselInfoMapper.deleteSysCarouselInfoByIds(Convert.toStrArray(ids));
}
/**
* 删除轮播图信息信息
*
*
* @param id 轮播图信息主键
* @return 结果
*/
@Override
public int deleteSysCarouselInfoById(Long id)
{
public int deleteSysCarouselInfoById(Long id) {
return sysCarouselInfoMapper.deleteSysCarouselInfoById(id);
}
}
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysCarouselInfoMapper">
<resultMap type="SysCarouselInfo" id="SysCarouselInfoResult">
<result property="id" column="id" />
<result property="createTime" column="create_time" />
......@@ -16,15 +16,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="associationId" column="association_id" />
<result property="associationName" column="association_name" />
<result property="linkUrl" column="link_url" />
<result property="urlType" column="url_type" />
</resultMap>
<sql id="selectSysCarouselInfoVo">
select id, create_time, update_time, img_url, description, status, type, order_number, association_id, association_name, link_url from sys_carousel_info
select id, create_time, update_time, img_url, description, status, type, order_number, association_id, association_name, link_url, url_type from sys_carousel_info
</sql>
<select id="selectSysCarouselInfoList" parameterType="SysCarouselInfo" resultMap="SysCarouselInfoResult">
<include refid="selectSysCarouselInfoVo"/>
<where>
<where>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="status != null "> and status = #{status}</if>
......@@ -33,14 +34,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="associationId != null "> and association_id = #{associationId}</if>
<if test="associationName != null and associationName != ''"> and association_name like concat('%', #{associationName}, '%')</if>
<if test="linkUrl != null and linkUrl != ''"> and link_url = #{linkUrl}</if>
<if test="urlType != null and urlType != ''"> and url_type = #{urlType}</if>
</where>
</select>
<select id="selectSysCarouselInfoById" parameterType="Long" resultMap="SysCarouselInfoResult">
<include refid="selectSysCarouselInfoVo"/>
where id = #{id}
</select>
<insert id="insertSysCarouselInfo" parameterType="SysCarouselInfo" useGeneratedKeys="true" keyProperty="id">
insert into sys_carousel_info
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -54,7 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="associationId != null">association_id,</if>
<if test="associationName != null">association_name,</if>
<if test="linkUrl != null">link_url,</if>
</trim>
<if test="urlType != null">url_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
......@@ -66,7 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="associationId != null">#{associationId},</if>
<if test="associationName != null">#{associationName},</if>
<if test="linkUrl != null">#{linkUrl},</if>
</trim>
<if test="urlType != null">#{urlType},</if>
</trim>
</insert>
<update id="updateSysCarouselInfo" parameterType="SysCarouselInfo">
......@@ -82,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="associationId != null">association_id = #{associationId},</if>
<if test="associationName != null">association_name = #{associationName},</if>
<if test="linkUrl != null">link_url = #{linkUrl},</if>
<if test="urlType != null">url_type = #{urlType},</if>
</trim>
where id = #{id}
</update>
......@@ -91,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteSysCarouselInfoByIds" parameterType="String">
delete from sys_carousel_info where id in
delete from sys_carousel_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
......
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('轮播图信息列表')" />
<th:block th:include="include :: header('轮播图信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<!-- <li>-->
<!-- <label>图片地址链接:</label>-->
<!-- <input type="text" name="imgUrl"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>图片描述:</label>-->
<!-- <input type="text" name="description"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>排序:</label>-->
<!-- <input type="text" name="orderNumber"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>关联id:</label>-->
<!-- <input type="text" name="associationId"/>-->
<!-- </li>-->
<li>
<label>名称:</label>
<input type="text" name="associationName"/>
</li>
<li>
<!-- <label>类型:</label>-->
<!-- <input type="type" name="type"/>-->
类型:<select name="type" th:with="type=${@dict.getType('lyy_business_type')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<!-- <li>-->
<!-- <label>转跳链接:</label>-->
<!-- <input type="text" name="linkUrl"/>-->
<!-- </li>-->
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<!-- <li>-->
<!-- <label>图片地址链接:</label>-->
<!-- <input type="text" name="imgUrl"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>图片描述:</label>-->
<!-- <input type="text" name="description"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>排序:</label>-->
<!-- <input type="text" name="orderNumber"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>关联id:</label>-->
<!-- <input type="text" name="associationId"/>-->
<!-- </li>-->
<li>
<label>名称:</label>
<input type="text" name="associationName"/>
</li>
<li>
<!-- <label>类型:</label>-->
<!-- <input type="type" name="type"/>-->
类型:<select name="type" th:with="type=${@dict.getType('lyy_business_type')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select>
</li>
<!-- <li>-->
<!-- <label>转跳链接:</label>-->
<!-- <input type="text" name="linkUrl"/>-->
<!-- </li>-->
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="carousel:info:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="carousel:info:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="carousel:info:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="carousel:info:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="carousel:info:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()"
shiro:hasPermission="carousel:info:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
shiro:hasPermission="carousel:info:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="carousel:info:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('carousel:info:edit')}]];
var removeFlag = [[${@permission.hasPermi('carousel:info:remove')}]];
var datas = [[${@dict.getType('sys_carousel_status')}]];
var datasType = [[${@dict.getType('lyy_business_type')}]];
var prefix = ctx + "carousel/info";
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('carousel:info:edit')}]];
var removeFlag = [[${@permission.hasPermi('carousel:info:remove')}]];
var datas = [[${@dict.getType('sys_carousel_status')}]];
var datasType = [[${@dict.getType('lyy_business_type')}]];
var prefix = ctx + "carousel/info";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "轮播图信息",
columns: [{
checkbox: true
},
$(function () {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "轮播图信息",
columns: [{
checkbox: true
},
{
field: 'id',
title: '主键id',
......@@ -96,7 +101,36 @@
},
{
field: 'imgUrl',
title: '图片地址链接'
formatter: function (value, row, index) {
let urlType = row.urlType;
var actions = [];
if (urlType == 1) {
actions.push('<img style="width:50px;height:50px" src=' + value + '>');
} else if (urlType == 2) {
actions.push
('<video width="50px" height="50px" controls>' +
'<source src="' + value + '" type="video/mp4">' +
' 您的浏览器不支持Video标签。' +
'</video>');
}
return actions.join('');
},
title: '链接地址'
}, {
field: 'urlType',
title: '资源类型',
formatter: function (value, row, index) {
var actions = [];
if (value == 1) {
actions.push('图片');
} else if (value == 2) {
actions.push('视频');
} else {
actions.push('其他');
}
return actions.join('');
}
},
{
field: 'description',
......@@ -105,14 +139,14 @@
{
field: 'status',
title: '图片状态',
formatter: function(value, row, index) {
formatter: function (value, row, index) {
return $.table.selectDictLabel(datas, value);
}
},
{
field: 'type',
title: '类型',
formatter: function(value, row, index) {
formatter: function (value, row, index) {
return $.table.selectDictLabel(datasType, value);
}
},
......@@ -135,16 +169,16 @@
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
};
$.table.init(options);
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment